|
| 1 | +name: Release Kit |
| 2 | + |
| 3 | +# NOTE: The release/publish pipeline runs in mParticle's org once the kit is accepted. |
| 4 | +# It depends on mParticle-owned secrets (MP_INTEGRATIONS_SEMANTIC_RELEASE_BOT, NPM_AUTH_TOKEN, |
| 5 | +# GPG_PRIVATE_KEY, GPG_PASSPHRASE), the reusable workflow mParticle/mparticle-workflows, and |
| 6 | +# publish rights to the @mparticle npm scope. Those do not exist in the ROKT org, so this |
| 7 | +# workflow mirrors the target pipeline; it is not expected to run from this repository. |
| 8 | + |
| 9 | +on: |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + dryRun: |
| 13 | + description: 'Do a dry run to preview instead of a real release [true/false]' |
| 14 | + required: true |
| 15 | + default: 'true' |
| 16 | + |
| 17 | +jobs: |
| 18 | + confirm-public-repo-main-branch: |
| 19 | + name: 'Confirm release is run from public/main branch' |
| 20 | + uses: mParticle/mparticle-workflows/.github/workflows/sdk-release-repo-branch-check.yml@stable |
| 21 | + |
| 22 | + build-and-test: |
| 23 | + name: Build and Test |
| 24 | + runs-on: ubuntu-latest |
| 25 | + needs: confirm-public-repo-main-branch |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: NPM install |
| 31 | + uses: actions/setup-node@v4 |
| 32 | + with: |
| 33 | + node-version: 20.x |
| 34 | + |
| 35 | + - name: Run NPM CI |
| 36 | + run: npm ci |
| 37 | + |
| 38 | + - name: Build Files |
| 39 | + run: npm run build |
| 40 | + |
| 41 | + - name: Run Core tests |
| 42 | + run: npm run test |
| 43 | + |
| 44 | + - name: Archive npm failure logs |
| 45 | + uses: actions/upload-artifact@v4 |
| 46 | + if: failure() |
| 47 | + with: |
| 48 | + name: npm-logs |
| 49 | + path: ~/.npm/_logs |
| 50 | + |
| 51 | + create-release-branch: |
| 52 | + name: Create release branch |
| 53 | + runs-on: ubuntu-latest |
| 54 | + needs: |
| 55 | + - build-and-test |
| 56 | + - confirm-public-repo-main-branch |
| 57 | + steps: |
| 58 | + - name: Checkout development branch |
| 59 | + uses: actions/checkout@v4 |
| 60 | + with: |
| 61 | + repository: ROKT/mparticle-javascript-integration-roktpayplus |
| 62 | + ref: development |
| 63 | + |
| 64 | + - name: Create and push release branch |
| 65 | + run: | |
| 66 | + git checkout -b release/${{ github.run_number }} |
| 67 | + git push origin release/${{ github.run_number }} |
| 68 | +
|
| 69 | + release: |
| 70 | + name: Perform Release |
| 71 | + runs-on: ubuntu-latest |
| 72 | + needs: |
| 73 | + - build-and-test |
| 74 | + - create-release-branch |
| 75 | + - confirm-public-repo-main-branch |
| 76 | + |
| 77 | + # OIDC permissions for npm trusted publishing |
| 78 | + permissions: |
| 79 | + contents: write |
| 80 | + issues: write |
| 81 | + pull-requests: write |
| 82 | + id-token: write # Required for OIDC authentication with npm |
| 83 | + |
| 84 | + env: |
| 85 | + GITHUB_TOKEN: ${{ secrets.MP_INTEGRATIONS_SEMANTIC_RELEASE_BOT }} |
| 86 | + GIT_AUTHOR_NAME: mparticle-automation |
| 87 | + GIT_AUTHOR_EMAIL: developers@mparticle.com |
| 88 | + GIT_COMMITTER_NAME: mparticle-automation |
| 89 | + GIT_COMMITTER_EMAIL: developers@mparticle.com |
| 90 | + NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |
| 91 | + |
| 92 | + steps: |
| 93 | + - name: Checkout public main branch |
| 94 | + uses: actions/checkout@v4 |
| 95 | + with: |
| 96 | + fetch-depth: 0 |
| 97 | + ref: main |
| 98 | + |
| 99 | + - name: Import GPG Key |
| 100 | + uses: crazy-max/ghaction-import-gpg@v4 |
| 101 | + with: |
| 102 | + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} |
| 103 | + passphrase: ${{ secrets.GPG_PASSPHRASE }} |
| 104 | + git_user_signingkey: true |
| 105 | + git_commit_gpgsign: true |
| 106 | + |
| 107 | + - name: Merge release branch into main branch |
| 108 | + run: | |
| 109 | + git pull origin release/${{ github.run_number }} |
| 110 | + - name: Setup Node.js |
| 111 | + uses: actions/setup-node@v4 |
| 112 | + with: |
| 113 | + node-version: 20.x |
| 114 | + |
| 115 | + - name: Install dependencies |
| 116 | + run: npm ci |
| 117 | + |
| 118 | + - name: Release --dry-run |
| 119 | + if: ${{ github.event.inputs.dryRun == 'true'}} |
| 120 | + run: | |
| 121 | + npx semantic-release --dry-run |
| 122 | + - name: Release |
| 123 | + if: ${{ github.event.inputs.dryRun == 'false'}} |
| 124 | + run: | |
| 125 | + npx semantic-release |
| 126 | +
|
| 127 | + - name: Archive npm failure logs |
| 128 | + uses: actions/upload-artifact@v4 |
| 129 | + if: failure() |
| 130 | + with: |
| 131 | + name: npm-logs |
| 132 | + path: ~/.npm/_logs |
| 133 | + |
| 134 | + - name: Push automated release commits to release branch |
| 135 | + if: ${{ github.event.inputs.dryRun == 'false' }} |
| 136 | + run: | |
| 137 | + git push origin HEAD:release/${{ github.run_number }} |
| 138 | +
|
| 139 | + sync-repository: |
| 140 | + name: Sync repositories |
| 141 | + needs: release |
| 142 | + runs-on: ubuntu-latest |
| 143 | + steps: |
| 144 | + - name: Checkout main branch |
| 145 | + uses: actions/checkout@v4 |
| 146 | + with: |
| 147 | + fetch-depth: 0 |
| 148 | + repository: ${{ github.repository }} |
| 149 | + token: ${{ secrets.MP_INTEGRATIONS_SEMANTIC_RELEASE_BOT }} |
| 150 | + ref: main |
| 151 | + |
| 152 | + - name: Merge release branch into main branch |
| 153 | + if: ${{ github.event.inputs.dryRun == 'false' }} |
| 154 | + run: | |
| 155 | + git pull origin release/${{ github.run_number }} |
| 156 | +
|
| 157 | + - name: Push release commits to main and development branches |
| 158 | + if: ${{ github.event.inputs.dryRun == 'false' }} |
| 159 | + run: | |
| 160 | + git push origin HEAD:development |
| 161 | + git push origin HEAD:main |
| 162 | + - name: Delete release branch |
| 163 | + if: ${{ github.event.inputs.dryRun == 'false' }} |
| 164 | + run: | |
| 165 | + git push --delete origin release/${{ github.run_number }} |
0 commit comments