Skip to content

Commit

Permalink
improvements: support branch fixes, removed set-output
Browse files Browse the repository at this point in the history
  • Loading branch information
tiller1010 committed Dec 7, 2022
1 parent 7692176 commit 378970e
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 130 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/changelog.yml

This file was deleted.

32 changes: 11 additions & 21 deletions .github/workflows/draftrelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ jobs:
continue-on-error: true
run: |
FILTEREDBRANCHNAME=$(git branch | grep "\* release")
echo "::set-output name=filtered_branch_name::$FILTEREDBRANCHNAME"
echo "filtered_branch_name=$FILTEREDBRANCHNAME" >> $GITHUB_OUTPUT
# Get the release tag
- name: Get release Tag
id: get_release_tag
if: steps.is_release_branch.outputs.filtered_branch_name != ''
run: |
RELEASETAG=$(git branch | grep \* | sed -re "s/release\///;s/\*//;s/\s*//g")
echo "::set-output name=release_tag::$RELEASETAG"
echo "release_tag=$RELEASETAG" >> $GITHUB_OUTPUT
# Draft Release with release branch
- name: Draft Release with release branch
Expand All @@ -56,41 +56,31 @@ jobs:
continue-on-error: true
run: |
FILTEREDBRANCHNAME=$(git branch | grep "\* hotfix")
echo "::set-output name=filtered_branch_name::$FILTEREDBRANCHNAME"
echo "filtered_branch_name=$FILTEREDBRANCHNAME" >> $GITHUB_OUTPUT
# Get the hotfix tag
- name: Get hotfix Tag
id: get_hotfix_tag
if: steps.is_hotfix_branch.outputs.filtered_branch_name != ''
run: |
RELEASETAG=$(git branch | grep \* | sed -re "s/hotfix\///;s/\*//;s/\s*//g")
echo "::set-output name=release_tag::$RELEASETAG"
echo "release_tag=$RELEASETAG" >> $GITHUB_OUTPUT
# Draft Release with hotfix branch
- name: Draft Release with hotfix branch
id: update_release_draft_with_hotfix_branch
if: steps.is_hotfix_branch.outputs.filtered_branch_name != ''
uses: tiller1010/release-drafter@master
with:
tag: ${{ steps.get_hotfix_tag.outputs.release_tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


# RELEASE BRANCHING (NOT GIT-FLOW)
# Get the last tag created on this branch
- name: Get Last Tag
id: last_tag
if: steps.is_hotfix_branch.outputs.filtered_branch_name != ''
run: |
LASTTAG=$(git describe --tags | sed -re "s/-.+//")
echo "::set-output name=last_tag_on_branch::$LASTTAG"
echo "last_tag_on_branch=$LASTTAG" >> $GITHUB_OUTPUT
# Draft Release with Previous Tag
- name: Draft Release with Previous Tag
id: update_release_draft
if: steps.is_release_branch.outputs.filtered_branch_name == '' && steps.is_hotfix_branch.outputs.filtered_branch_name == ''
# Draft Release with hotfix branch
- name: Draft Release with hotfix branch
id: update_release_draft_with_hotfix_branch
if: steps.is_hotfix_branch.outputs.filtered_branch_name != ''
uses: tiller1010/release-drafter@master
with:
tag: ${{ steps.get_hotfix_tag.outputs.release_tag }}
last_tag: ${{ steps.last_tag.outputs.last_tag_on_branch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105 changes: 84 additions & 21 deletions .github/workflows/publish_release_draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,76 @@ jobs:
if: ${{ github.event.pull_request.merged }}
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 0

- name: Get release id
id: get_release_id
run: |
TOKEN=${{ secrets.GITHUB_TOKEN }}
RELEASEID=$(curl -H "Accept: application/vnd.github+json" -H "Authorization: token $TOKEN" https://api.github.com/repos/werkbot/silverstripe-module-newsletter/releases)
RELEASEID=$(echo "$RELEASEID" | grep \"id\" | head -n 1 | sed -re "s/[a-z]*//g;s/[-|,|:|'\"]//g;s/\s//g")
echo "::set-output name=release_id::$RELEASEID"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish release
uses: eregon/publish-release@v1
echo "release_id=$RELEASEID" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.get_release_id.outputs.release_id }}

- name: Payload info
id: payload_info
uses: Dovyski/payload-info-action@master
continue-on-error: true

# Generate changelog, changelog.yml is not triggered by other actions
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ steps.payload_info.outputs.pull_request.base.ref }}

# Check if this is a support branch
- name: Check For support branch
# START SUPPORT RELEASE RE-DRAFT
- name: Check if releasing for a support branch
id: is_support_branch
continue-on-error: true
run: |
FILTEREDBRANCHNAME=$(git branch | grep "\* support")
echo "::set-output name=filtered_branch_name::$FILTEREDBRANCHNAME"
echo "filtered_branch_name=$FILTEREDBRANCHNAME" >> $GITHUB_OUTPUT
- name: Get hotfix Tag from branch name
id: get_hotfix_tag
if: steps.is_support_branch.outputs.filtered_branch_name != ''
run: |
HOTFIXBRANCH=${{ steps.payload_info.outputs.branch }}
RELEASETAG=$(echo "$HOTFIXBRANCH" | grep \* | sed -re "s/hotfix\///;s/\*//;s/\s*//g")
echo "release_tag=$RELEASETAG" >> $GITHUB_OUTPUT
- name: Get Last Tag created on this branch
id: last_tag
if: steps.is_support_branch.outputs.filtered_branch_name != ''
run: |
LASTTAG=$(git describe --tags | sed -re "s/-.+//")
echo "last_tag_on_branch=$LASTTAG" >> $GITHUB_OUTPUT
# Re-Draft Release with hotfix tag
# "release-drafter" works by checking the changes of merged pull requests.
# For support branches, there is only one merged hotfix PR, which is only now available,
# so we need to re-draft the release with the recently merged PR for release notes.
- name: Draft Release with hotfix tag
id: update_release_draft_with_hotfix_branch
if: steps.is_support_branch.outputs.filtered_branch_name != ''
uses: tiller1010/release-drafter@master
with:
tag: ${{ steps.get_hotfix_tag.outputs.release_tag }}
last_tag: ${{ steps.last_tag.outputs.last_tag_on_branch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# END SUPPORT RELEASE RE-DRAFT


- name: Publish release
uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.get_release_id.outputs.release_id }}


# START CHANGELOG PORTION
- name: Generate Changelog
id: changelog
if: steps.is_support_branch.outputs.filtered_branch_name == ''
Expand All @@ -63,16 +97,45 @@ jobs:
if: steps.is_support_branch.outputs.filtered_branch_name == ''
run: TAGCONTENT="${{ steps.changelog.outputs.changelog }}";CHANGELOG=$(cat CHANGELOG.md);CHANGELOG=$(echo "$CHANGELOG" | sed -e "s/# Changelog//");echo -e "# Changelog\n\n$TAGCONTENT$CHANGELOG" > CHANGELOG.md

- name: Commit Updated Changelog
- name: Create Pull Request
id: create_pr
if: steps.is_support_branch.outputs.filtered_branch_name == ''
uses: stefanzweifel/git-auto-commit-action@v4
uses: peter-evans/create-pull-request@v4
with:
title: Auto-Update CHANGELOG.md
commit-message: Updated CHANGELOG.md
labels: automerge

- name: Approve PR
if: steps.is_support_branch.outputs.filtered_branch_name == ''
uses: hmarr/auto-approve-action@v2
with:
review-message: Auto approved automated PR
pull-request-number: ${{ steps.create_pr.outputs.pull-request-number }}
github-token: ${{ secrets.SOME_USERS_PAT }}

- name: Auto merge
if: steps.is_support_branch.outputs.filtered_branch_name == ''
uses: pascalgn/automerge-action@v0.15.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST: ${{ steps.create_pr.outputs.pull-request-number }}
MERGE_DELETE_BRANCH: true
# END CHANGELOG PORTION


# Merge support changes into develop so they can be included in the next release
- name: Merge master/support -> develop
uses: devmasx/merge-branch@master
with:
commit_message: Updated CHANGELOG.md
branch: ${{ steps.payload_info.outputs.pull_request.base.ref }}
type: now
target_branch: develop
github_token: ${{ secrets.GITHUB_TOKEN }}
message: Merged master/support into develop

# Remove the release or hotfix branch after publishing
- name: Remove PR branch
uses: dawidd6/action-delete-branch@v3
with:
github_token: ${{github.token}}
github_token: ${{ secrets.GITHUB_TOKEN }}
branches: ${{ steps.payload_info.outputs.branch }}
52 changes: 0 additions & 52 deletions .github/workflows/sync_develop_with_master.yml

This file was deleted.

0 comments on commit 378970e

Please sign in to comment.