Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 30 additions & 96 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,72 +8,34 @@ on:
required: true
default: 'true'

jobs:
# Kit release is done from main branch.
confirm-public-repo-main-branch:
name: 'Confirm release is run from public/main branch'
uses: mParticle/mparticle-workflows/.github/workflows/sdk-release-repo-branch-check.yml@stable

build-and-test:
name: Build and Test
runs-on: ubuntu-latest
needs: confirm-public-repo-main-branch
steps:
- name: Checkout
uses: actions/checkout@v6

- name: NPM install
uses: actions/setup-node@v6
with:
node-version: 24.x

- name: Run NPM CI
run: npm ci

- name: Build Files
run: npm run build
# Prevent race between staging and release workflows
concurrency:
group: staging-pipeline
cancel-in-progress: false

- name: Run Core tests
run: npm run test

- name: Archive npm failure logs
uses: actions/upload-artifact@v6
if: failure()
with:
name: npm-logs
path: ~/.npm/_logs

create-release-branch:
name: Create release branch
jobs:
confirm-staging-branch:
name: Confirm release is run from staging
runs-on: ubuntu-latest
needs:
- build-and-test
- confirm-public-repo-main-branch
steps:
- name: Checkout development branch
uses: actions/checkout@v6
with:
repository: mparticle-integrations/mparticle-javascript-integration-rokt
ref: development

- name: Create and push release branch
- name: Branch Check
run: |
git checkout -b release/${{ github.run_number }}
git push origin release/${{ github.run_number }}
if [ "${{ github.ref_name }}" != "staging" ]; then
echo "Release must be run from the staging branch, not '${{ github.ref_name }}'"
exit 1
fi

release:
name: Perform Release
runs-on: ubuntu-latest
needs:
- build-and-test
- create-release-branch
- confirm-public-repo-main-branch
needs: confirm-staging-branch

# OIDC permissions for npm trusted publishing
permissions:
contents: write
issues: write
pull-requests: write
id-token: write # Required for OIDC authentication with npm
contents: write
issues: write
pull-requests: write
id-token: write

env:
GITHUB_TOKEN: ${{ secrets.MP_INTEGRATIONS_SEMANTIC_RELEASE_BOT }}
Expand All @@ -83,11 +45,12 @@ jobs:
GIT_COMMITTER_EMAIL: developers@mparticle.com

steps:
- name: Checkout public main branch
- name: Checkout staging branch
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: main
ref: staging
token: ${{ secrets.MP_INTEGRATIONS_SEMANTIC_RELEASE_BOT }}

- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v4
Expand All @@ -97,9 +60,6 @@ jobs:
git_user_signingkey: true
git_commit_gpgsign: true

- name: Merge release branch into main branch
run: |
git pull origin release/${{ github.run_number }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
Expand All @@ -113,47 +73,21 @@ jobs:
run: npm install -g npm@latest

- name: Release --dry-run
if: ${{ github.event.inputs.dryRun == 'true'}}
run: |
npx semantic-release --dry-run
if: ${{ github.event.inputs.dryRun == 'true' }}
run: npx semantic-release --dry-run

# NPM Publish happens here via OIDC trusted publishing
- name: Release
if: ${{ github.event.inputs.dryRun == 'false'}}
run: |
npx semantic-release
if: ${{ github.event.inputs.dryRun == 'false' }}
run: npx semantic-release

- name: Archive npm failure logs
uses: actions/upload-artifact@v6
if: failure()
with:
name: npm-logs
path: ~/.npm/_logs

- name: Push automated release commits to release branch
- name: Push release commits to main
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git push origin HEAD:release/${{ github.run_number }}
sync-repository:
name: Sync repositories
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v6
with:
fetch-depth: 0
repository: ${{ github.repository }}
token: ${{ secrets.MP_INTEGRATIONS_SEMANTIC_RELEASE_BOT }}
ref: main

- name: Merge release branch into main branch
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git pull origin release/${{ github.run_number }}
- name: Push release commits to main and development branches
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git push origin HEAD:development
git push origin HEAD:main
- name: Delete release branch
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git push --delete origin release/${{ github.run_number }}
run: git push origin HEAD:main
3 changes: 0 additions & 3 deletions .github/workflows/reusable-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,3 @@ jobs:
pr-title-check:
name: Check PR for semantic title
uses: mParticle/mparticle-workflows/.github/workflows/pr-title-check.yml@stable
pr-branch-target-gitflow:
name: Check PR for semantic target branch
uses: mParticle/mparticle-workflows/.github/workflows/pr-branch-target-gitflow.yml@stable
86 changes: 86 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Staging Pipeline

on:
push:
branches: [main]

# Prevent race between staging and release workflows
concurrency:
group: staging-pipeline
cancel-in-progress: false

jobs:
# Guard: skip when release commits land on main (they contain [skip ci])
check-skip:
name: Check for skip ci
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- run: echo "Proceeding with staging pipeline"

build-and-test:
name: Build and Test
runs-on: ubuntu-latest
needs: check-skip
steps:
- name: Checkout
uses: actions/checkout@v6

- name: NPM install
uses: actions/setup-node@v6
with:
node-version: 24.x

- name: Run NPM CI
run: npm ci

- name: Build Files
run: npm run build

- name: Run Core tests
run: npm run test

- name: Archive npm failure logs
uses: actions/upload-artifact@v6
if: failure()
with:
name: npm-logs
path: ~/.npm/_logs

# After tests pass, reset staging branch to main + built dist/
update-staging:
name: Update Staging Branch
runs-on: ubuntu-latest
needs: build-and-test

env:
GIT_AUTHOR_NAME: mparticle-automation
GIT_AUTHOR_EMAIL: developers@mparticle.com
GIT_COMMITTER_NAME: mparticle-automation
GIT_COMMITTER_EMAIL: developers@mparticle.com

steps:
- name: Checkout main
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: main
token: ${{ secrets.MP_INTEGRATIONS_SEMANTIC_RELEASE_BOT }}

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24.x

- name: Install dependencies
run: npm ci

- name: Build distribution bundle
run: npm run build

- name: Reset staging to main and add dist
run: |
git checkout -B staging
git add dist -f
git commit -m 'chore(build): Generate latest bundle [skip ci]'
git push origin staging --force
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Thanks for contributing! Please read this document to follow our conventions for
## Setting Up

- Fork the repository and then clone down your fork
- Commit your code per the conventions below, and PR into the mParticle SDK `master` branch
- Commit your code per the conventions below, and PR into the mParticle SDK `main` branch
- Your PR title will be checked automatically against the below convention (view the commit history to see examples of a proper commit/PR title). If it fails, you must update your title.
- Our engineers will work with you to get your code change implemented once a PR is up

Expand Down
2 changes: 1 addition & 1 deletion release.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
branches: ['main'],
branches: ['staging'],
tagFormat: 'v${version}',
repositoryUrl:
'https://github.com/mparticle-integrations/mparticle-javascript-integration-rokt',
Expand Down
Loading