From 265c0d7bb0c86500c586d0f319aa2240eb31b358 Mon Sep 17 00:00:00 2001 From: Levi Bostian Date: Mon, 25 Sep 2023 11:04:00 -0500 Subject: [PATCH 1/2] ci: refactor manual deployment CI config into 1 workflow --- .github/workflows/deploy-sdk.yml | 23 ++++- .github/workflows/manual-deployment.yml | 107 ------------------------ 2 files changed, 22 insertions(+), 108 deletions(-) delete mode 100644 .github/workflows/manual-deployment.yml diff --git a/.github/workflows/deploy-sdk.yml b/.github/workflows/deploy-sdk.yml index 47d55aeff..e52e2ca1a 100644 --- a/.github/workflows/deploy-sdk.yml +++ b/.github/workflows/deploy-sdk.yml @@ -6,6 +6,13 @@ on: push: branches: [beta, main] # all branches where deployments currently occur. Make sure this list matches list of branches in `.releaserc` file. + workflow_dispatch: # manually run this workflow. convenient way to retry a deployment. + inputs: + existing-git-tag: + description: 'Type name of existing git tag (example: 1.0.3) to checkout and manually deploy' + required: true + type: string + permissions: contents: write # access to push the git tag issues: write # Bot creates an issue if there is an issue during deployment process @@ -16,6 +23,7 @@ jobs: name: Deploy git tag runs-on: ubuntu-latest outputs: + new_release_git_head: ${{ steps.semantic-release.outputs.new_release_git_head }} new_release_published: ${{ steps.semantic-release.outputs.new_release_published }} new_release_version: ${{ steps.semantic-release.outputs.new_release_version }} steps: @@ -125,9 +133,22 @@ jobs: deploy-sonatype: name: Deploy SDK to Maven Central needs: [deploy-git-tag] - if: needs.deploy-git-tag.outputs.new_release_published == 'true' # only run if a git tag was made. + # Only run if we can find a git tag to checkout. + if: ${{ needs.deploy-git-tag.outputs.new_release_published == 'true' || github.event_name == 'workflow_dispatch' }} runs-on: ubuntu-latest steps: + - name: Checkout git tag that got created in previous step + uses: actions/checkout@v4 + if: ${{ needs.deploy-git-tag.outputs.new_release_published == 'true' }} + with: + ref: ${{ needs.deploy-git-tag.outputs.new_release_git_head }} + + - name: Checkout git tag that was previously created + uses: actions/checkout@v4 + if: ${{ github.event_name == 'workflow_dispatch' }} + with: + ref: ${{ inputs.existing-git-tag }} + - uses: actions/checkout@v4 - name: Set up JDK uses: actions/setup-java@v3 diff --git a/.github/workflows/manual-deployment.yml b/.github/workflows/manual-deployment.yml deleted file mode 100644 index 71f591b33..000000000 --- a/.github/workflows/manual-deployment.yml +++ /dev/null @@ -1,107 +0,0 @@ -name: Manual Deploy to Maven Central -# Trigger this manual deployment in scenarios where: -# A git tag exists, but the initial deployment failed and fix has been pushed to main. -# This avoids the need to recreate the tag for redeployment. -on: - workflow_dispatch: # allows for manual triggering - -jobs: - deploy-sonatype: - name: Deploy SDK to Maven Central - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: main - fetch-depth: 0 # fetches all history for all tags and branches - - - name: Get latest tag - id: get-latest-tag - run: | - echo '::group::Get latest tag' - TAG=$(git describe --tags --abbrev=0) - echo "TAG=$TAG" >> $GITHUB_ENV - echo '::endgroup::' - - - name: Set up JDK - uses: actions/setup-java@v3 - with: - distribution: adopt - java-version: 11 - - - name: Push to Sonatype servers - run: MODULE_VERSION=${{ env.TAG }} ./scripts/deploy-code.sh - env: - OSSRH_USERNAME: ${{ secrets.GRADLE_PUBLISH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.GRADLE_PUBLISH_PASSWORD }} - SIGNING_KEY_ID: ${{ secrets.GRADLE_SIGNING_KEYID }} - SIGNING_PASSWORD: ${{ secrets.GRADLE_SIGNING_PASSPHRASE }} - SIGNING_KEY: ${{ secrets.GRADLE_SIGNING_PRIVATE_KEY }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} - - - name: Notify team of successful deployment - uses: slackapi/slack-github-action@v1.24.0 - if: ${{ success() }} - with: - payload: | - { - "text": "Android SDK deployed to Maven Central", - "username": "Android deployment bot", - "icon_url": "https://media.pocketgamer.com/artwork/na-qulrguj/android.jpg", - "channel": "#mobile-deployments", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Android* SDK deployed to Maven Central! (manual deployment)" - } - }, - { - "type": "divider" - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Version:* ${{ env.TAG }}\n\nAndroid SDK deployment progress:\n~1. Git tag already created~\n~2. Manual deploy to maven central~\n\n" - } - } - ] - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFY_RELEASES_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - - name: Notify team of failure - uses: slackapi/slack-github-action@v1.24.0 - if: ${{ failure() }} - with: - payload: | - { - "text": "Android SDK deployment failure", - "username": "Android deployment bot", - "icon_url": "https://media.pocketgamer.com/artwork/na-qulrguj/android.jpg", - "channel": "#mobile-deployments", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Android* SDK deployment :warning: failure :warning:" - } - }, - { - "type": "divider" - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "Android SDK failed deployment during step *deploy to maven central*. View to learn why and fix the issue. ." - } - } - ] - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFY_RELEASES_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK \ No newline at end of file From 3b3ed4e50ac488838973961ec62f9edd5e87593e Mon Sep 17 00:00:00 2001 From: Levi Bostian Date: Mon, 25 Sep 2023 11:09:19 -0500 Subject: [PATCH 2/2] Update deploy-sdk.yml --- .github/workflows/deploy-sdk.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy-sdk.yml b/.github/workflows/deploy-sdk.yml index 7e5b6f3d2..097eb6fb2 100644 --- a/.github/workflows/deploy-sdk.yml +++ b/.github/workflows/deploy-sdk.yml @@ -149,7 +149,6 @@ jobs: with: ref: ${{ inputs.existing-git-tag }} - - uses: actions/checkout@v4 - uses: ./.github/actions/setup-android - name: Push to Sonatype servers run: MODULE_VERSION=${{ needs.deploy-git-tag.outputs.new_release_version }} ./scripts/deploy-code.sh