Release Kit #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Kit | |
on: | |
workflow_dispatch: | |
inputs: | |
dryRun: | |
description: 'Do a dry run to preview instead of a real release [true/false]' | |
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@v3 | |
- name: NPM install | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20.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@v3 | |
if: failure() | |
with: | |
name: npm-logs | |
path: ~/.npm/_logs | |
create-release-branch: | |
name: Create release branch | |
runs-on: ubuntu-latest | |
needs: | |
- build-and-test | |
- confirm-public-repo-main-branch | |
steps: | |
- name: Checkout development branch | |
uses: actions/checkout@v3 | |
with: | |
repository: mparticle-integrations/mparticle-javascript-integration-id5 | |
ref: development | |
- name: Create and push release branch | |
run: | | |
git checkout -b release/${{ github.run_number }} | |
git push origin release/${{ github.run_number }} | |
release: | |
name: Perform Release | |
runs-on: ubuntu-latest | |
needs: | |
- build-and-test | |
- create-release-branch | |
- confirm-public-repo-main-branch | |
env: | |
GITHUB_TOKEN: ${{ secrets.MP_INTEGRATIONS_SEMANTIC_RELEASE_BOT }} | |
GIT_AUTHOR_NAME: mparticle-automation | |
GIT_AUTHOR_EMAIL: [email protected] | |
GIT_COMMITTER_NAME: mparticle-automation | |
GIT_COMMITTER_EMAIL: [email protected] | |
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
steps: | |
- name: Checkout public main branch | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: main | |
- name: Import GPG Key | |
uses: crazy-max/ghaction-import-gpg@v4 | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
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@v3 | |
with: | |
node-version: 16.x | |
- name: Install dependencies | |
run: npm ci | |
- name: Release --dry-run | |
if: ${{ github.event.inputs.dryRun == 'true'}} | |
run: | | |
npx semantic-release --dry-run | |
- name: Release | |
if: ${{ github.event.inputs.dryRun == 'false'}} | |
run: | | |
npx semantic-release | |
- name: Archive npm failure logs | |
uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: npm-logs | |
path: ~/.npm/_logs | |
- name: Push automated release commits to release branch | |
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@v3 | |
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 HEADmain: | |
- name: Delete release branch | |
if: ${{ github.event.inputs.dryRun == 'false' }} | |
run: | | |
git push --delete origin release/${{ github.run_number }} |