From fb4224f09ef97c8620e65ad494bc93865e25f81e Mon Sep 17 00:00:00 2001 From: Kenton Duprey Date: Sun, 30 Jun 2024 19:56:05 -0400 Subject: [PATCH] feat: Updating workflows to use main branch for trigger and versioning logic to be simplified --- .github/workflows/cut-major-release.yml | 55 ++++++++++++++++++ .github/workflows/cut-minor-release.yml | 75 ++++++------------------- .github/workflows/cut-patch-release.yml | 75 ++++++------------------- 3 files changed, 90 insertions(+), 115 deletions(-) create mode 100644 .github/workflows/cut-major-release.yml diff --git a/.github/workflows/cut-major-release.yml b/.github/workflows/cut-major-release.yml new file mode 100644 index 00000000..5144b554 --- /dev/null +++ b/.github/workflows/cut-major-release.yml @@ -0,0 +1,55 @@ +name: Cut Major Release + +on: + pull_request: + types: [closed] + branches: + - main + +# when a push is made to develop branch by kduprey, and the merge branch does not include hotfix, and merge branch has label 'major version', it will cut a major release + +jobs: + cutMajorRelease: + if: github.actor == 'kduprey' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'major version') + runs-on: ubuntu-latest + permissions: + contents: write + name: Cut Major Release + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: main + + - name: Get previous tag + id: previoustag + uses: WyriHaximus/github-action-get-previous-tag@v1.4.0 + with: + prefix: "v" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get next version + id: semvers + uses: WyriHaximus/github-action-next-semvers@v1.2.1 + with: + version: ${{ steps.previoustag.outputs.tag }} + + - name: Create release + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ steps.semvers.outputs.v_major }} + generateReleaseNotes: true + commit: "main" + + - name: Create Sentry release + uses: getsentry/action-release@v1 + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_ORG: ${{ secrets.SENTRY_ORG }} + SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} + with: + environment: production + version: ${{ steps.semvers.outputs.v_major }} diff --git a/.github/workflows/cut-minor-release.yml b/.github/workflows/cut-minor-release.yml index 95d7cae1..fe9c90bf 100644 --- a/.github/workflows/cut-minor-release.yml +++ b/.github/workflows/cut-minor-release.yml @@ -3,7 +3,7 @@ name: Cut Minor Release on: push: branches: - - develop + - main # when a push is made to develop branch by kduprey, and the merge branch does not include hotfix, it will cut a minor release @@ -12,14 +12,12 @@ jobs: if: github.actor == 'kduprey' && !contains(github.event.head_commit.message, 'hotfix') runs-on: ubuntu-latest name: Cut Minor Release - outputs: - v_minor: ${{ steps.semvers.outputs.v_minor }} steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - ref: develop + ref: main - name: Get previous tag id: previoustag @@ -35,59 +33,20 @@ jobs: with: version: ${{ steps.previoustag.outputs.tag }} - - name: Create release branch - run: git checkout -b release/${{ steps.semvers.outputs.v_minor }} - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - - name: Publish tag - run: git tag ${{ steps.semvers.outputs.v_minor }} && git push origin ${{ steps.semvers.outputs.v_minor }} - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - - name: Push release branch - run: git push origin release/${{ steps.semvers.outputs.v_minor }} - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - - name: Cut release branch - run: gh release create ${{ steps.semvers.outputs.v_minor }} --generate-notes - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create pull request to production - uses: vsoch/pull-request-action@master - id: pr - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH_PREFIX: release/v - PULL_REQUEST_FROM_BRANCH: release/${{ steps.semvers.outputs.v_minor }} - PULL_REQUEST_BRANCH: main - PULL_REQUEST_TITLE: release/${{ steps.semvers.outputs.v_minor }} - - - name: Wait 10 seconds for PR Deployments to be created - run: sleep 10 + - name: Create release + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ steps.semvers.outputs.v_minor }} + generateReleaseNotes: true + commit: "main" - - name: Enable pull request auto merge - run: gh pr merge ${{ steps.pr.outputs.pull_request_number }} --auto --merge + - name: Create Sentry release + uses: getsentry/action-release@v1 env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # submitSentryPreviewRelease: - # needs: cutMinorRelease - # if: github.ref == 'refs/heads/develop' - # runs-on: ubuntu-latest - # name: Submit Sentry Minor Release - # steps: - # - uses: actions/checkout@v4 - # with: - # fetch-depth: 0 - # - name: Create Sentry release - # uses: getsentry/action-release@v1 - # env: - # SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - # SENTRY_ORG: ${{ secrets.SENTRY_ORG }} - # SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} - # with: - # environment: preview - # version: ${{ needs.cutMinorRelease.outputs.v_minor }} + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_ORG: ${{ secrets.SENTRY_ORG }} + SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} + with: + environment: production + version: ${{ steps.semvers.outputs.v_minor }} diff --git a/.github/workflows/cut-patch-release.yml b/.github/workflows/cut-patch-release.yml index f9002b54..74d21b4f 100644 --- a/.github/workflows/cut-patch-release.yml +++ b/.github/workflows/cut-patch-release.yml @@ -3,7 +3,7 @@ name: Cut Patch Release on: push: branches: - - develop + - main permissions: write-all @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - ref: develop + ref: main - name: Get previous tag id: previoustag @@ -37,60 +37,21 @@ jobs: with: version: ${{ steps.previoustag.outputs.tag }} - - name: Create release branch - run: git checkout -b release/${{ steps.semvers.outputs.v_patch }} - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - - name: Publish tag - run: git tag ${{ steps.semvers.outputs.v_patch }} && git push origin ${{ steps.semvers.outputs.v_patch }} - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - - name: Push release branch - run: git push origin release/${{ steps.semvers.outputs.v_patch }} - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - - name: Cut release branch - run: gh release create ${{ steps.semvers.outputs.v_patch }} --generate-notes - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create pull request to production - uses: vsoch/pull-request-action@master - id: pr - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH_PREFIX: release/v - PULL_REQUEST_FROM_BRANCH: release/${{ steps.semvers.outputs.v_patch }} - PULL_REQUEST_BRANCH: main - PULL_REQUEST_TITLE: release/${{ steps.semvers.outputs.v_patch }} - - - name: Wait 10 seconds for PR Deployments to be created - run: sleep 10 + - name: Create release + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ steps.semvers.outputs.v_patch }} + generateReleaseNotes: true + commit: "main" - - name: Enable pull request auto merge - run: gh pr merge ${{ steps.pr.outputs.pull_request_number }} --auto --merge + - name: Create Sentry release + uses: getsentry/action-release@v1 env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # submitSentryPreviewRelease: - # needs: cutPatchRelease - # if: github.ref == 'refs/heads/develop' - # runs-on: ubuntu-latest - # name: Submit Sentry Patch Release - # steps: - # - uses: actions/checkout@v4 - # with: - # fetch-depth: 0 - # - name: Create Sentry release - # uses: getsentry/action-release@v1 - # env: - # SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - # SENTRY_ORG: ${{ secrets.SENTRY_ORG }} - # SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} - # with: - # environment: preview - # version: ${{ needs.cutPatchRelease.outputs.v_patch }} - # ignore_missing: true + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_ORG: ${{ secrets.SENTRY_ORG }} + SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} + with: + environment: production + version: ${{ steps.semvers.outputs.v_patch }} + ignore_missing: true