diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 202b104..ec9360c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 }} @@ -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 @@ -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: @@ -113,13 +73,14 @@ 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() @@ -127,33 +88,6 @@ jobs: 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 }} \ No newline at end of file + run: git push origin HEAD:main diff --git a/.github/workflows/reusable-workflows.yml b/.github/workflows/reusable-workflows.yml index e9d5bec..e8d03e1 100644 --- a/.github/workflows/reusable-workflows.yml +++ b/.github/workflows/reusable-workflows.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml new file mode 100644 index 0000000..5902d5c --- /dev/null +++ b/.github/workflows/staging.yml @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 222550e..c21d646 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/release.config.js b/release.config.js index 3638e2c..1383e81 100644 --- a/release.config.js +++ b/release.config.js @@ -1,5 +1,5 @@ module.exports = { - branches: ['main'], + branches: ['staging'], tagFormat: 'v${version}', repositoryUrl: 'https://github.com/mparticle-integrations/mparticle-javascript-integration-rokt',