From 68716a68076f96dcb440d765b208ce4978faee8f Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Mon, 20 Nov 2023 16:00:13 -0500 Subject: [PATCH] update workflow --- .github/workflows/pre-release.yml | 139 +++++++++++++++++------------- 1 file changed, 77 insertions(+), 62 deletions(-) diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index be2d53c5..3230b2cd 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -1,71 +1,86 @@ -name: Pre-release SDK - +name: Publish SDK Pre-Release on: - pull_request - # workflow_dispatch: - # inputs: - # dryRun: - # description: 'Do a dry run to preview instead of a real release [true/false]' - # required: true - # default: 'true' - # release-order: - # description: 'Which Phase are you releaseing? [release-order-a/release-order-b/release-order-c]' - # required: true + workflow_dispatch: + inputs: + dryRun: + description: 'Do a dry run to preview instead of a real release [true/false]' + required: true + type: boolean + default: true + versionNumber: + description: 'Which SDK version to publish? [X.XX.XX]' + required: true + type: string + releaseOrderBranch: + description: 'Which Release Order Branch are you targeting? [release-order-a/release-order-b/release-order-c]' + required: true + type: choice + default: release-order-a + options: + - release-order-a + - release-order-b + - release-order-c jobs: + verify-version-number: + name: Verify SDK Version (${{ github.event.inputs.versionNumber}}) + runs-on: ubuntu-latest + steps: + # As a safe guard, if a valid version number does not exist, + # this step will fail and throw an error + - name: Checkout SDK Version (${{ github.event.inputs.versionNumber}}) + uses: actions/checkout@v3 + with: + ref: release/${{ github.event.inputs.versionNumber}} - # TODO: Steps - # 1. Check if input string for release order branch - # 2. Check if input string for release/tag branch exists - - # TODO: Maybe Refactor into reusable job verify-release-order-branch: - name: Verify Release Order Branch - runs-on: ubuntu-latest - steps: - # TODO: Replace with input string - - name: Checkout Release Order () - uses: actions/checkout@v3 - with: - # TODO: Replace with input - ref: release-order-a + name: Verify Release Order Branch + runs-on: ubuntu-latest + steps: + # As a safe guard, if a valid release branch does not exist, + # this step will fail and throw an error + - name: Checkout Release Order (${{ github.event.inputs.releaseOrderBranch }}) + uses: actions/checkout@v3 + with: + ref: ${{ github.event.inputs.releaseOrderBranch }} + + push-release-branch: + name: Deploy v${{ github.event.inputs.versionNumber}} to ${{ github.event.inputs.releaseOrderBranch}} + needs: + - verify-version-number + - verify-release-order-branch + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }} + 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 master branch + uses: actions/checkout@v3 + with: + fetch-depth: 0 + repository: ${{ github.repository }} + token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }} + ref: master - verify-sdk-version-branch: - name: Verify SDK Version - runs-on: ubuntu-latest - steps: - # TODO: Replace with input string - - name: Checkout SKD Version () - uses: actions/checkout@v3 - with: - # TODO: Replace with input - ref: release/2.23.4 + - 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 - push-pre-release-branch: - # TODO: Replace with branch name - name: Deploy Pre-Release to () - needs: - - verify-release-order-branch - - verify-sdk-version-branch - runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }} - GIT_AUTHOR_NAME: mparticle-automation - GIT_AUTHOR_EMAIL: developers@mparticle.com - GIT_COMMITTER_NAME: mparticle-automation - GIT_COMMITTER_EMAIL: developers@mparticle.com + - name: Merge release/${{ github.event.inputs.versionNumber}} into master branch + if: ${{ github.event.inputs.dryRun == false }} + run: | + git pull origin release/${{ github.event.inputs.versionNumber}} - steps: - # TODO: Replace with input string - - name: Checkout SDK Version () - uses: actions/checkout@v3 - with: - # TODO: Replace with input - ref: release/2.23.4 - - - name: Force Push Pre-Release Branch - # TODO: Add when dryRun is enabled - # if: ${{ github.event.inputs.dryRun == 'false' }} - run: | - git push origin HEAD:release-order-a -f \ No newline at end of file + - name: Push v${{ github.event.inputs.versionNumber}} to ${{ github.event.inputs.releaseOrderBranch }} + if: ${{ github.event.inputs.dryRun == false }} + run: | + git push origin HEAD:${{ github.event.inputs.releaseOrderBranch }}