Skip to content

Commit

Permalink
Merge pull request #745 from kduprey/feature/update-release-workflows
Browse files Browse the repository at this point in the history
feat: Updating workflows to use main branch for trigger and versionin…
  • Loading branch information
kduprey authored Jun 30, 2024
2 parents 4ac60ba + fb4224f commit 2abbf8a
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 115 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/cut-major-release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
prefix: "v"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get next version
id: semvers
uses: WyriHaximus/[email protected]
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 }}
75 changes: 17 additions & 58 deletions .github/workflows/cut-minor-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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 }}
75 changes: 18 additions & 57 deletions .github/workflows/cut-patch-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Cut Patch Release
on:
push:
branches:
- develop
- main

permissions: write-all

Expand All @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: develop
ref: main

- name: Get previous tag
id: previoustag
Expand All @@ -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

0 comments on commit 2abbf8a

Please sign in to comment.