diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml deleted file mode 100644 index 08e57f8..0000000 --- a/.github/workflows/changelog.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Generate Changelog - -on: - release: - types: [published] - -permissions: - contents: write - -jobs: - update_changelog: - runs-on: ubuntu-latest - outputs: - output: ${{ steps.changelog.outputs.changelog }} - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - ref: master - - - name: Generate Changelog - id: changelog - uses: loopwerk/tag-changelog@v1.0.4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - exclude_types: other,doc,chore - config_file: .github/tag-changelog-config.js - - - name: Output Changelog - id: output_changelog - 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 - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: Updated CHANGELOG.md diff --git a/.github/workflows/draftrelease.yml b/.github/workflows/draftrelease.yml index f85c172..f63a9ed 100644 --- a/.github/workflows/draftrelease.yml +++ b/.github/workflows/draftrelease.yml @@ -27,7 +27,7 @@ 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 @@ -35,7 +35,7 @@ jobs: 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 @@ -56,7 +56,7 @@ 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 @@ -64,33 +64,23 @@ jobs: 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 }} diff --git a/.github/workflows/publish_release_draft.yml b/.github/workflows/publish_release_draft.yml index 5d89f92..d9cbf26 100644 --- a/.github/workflows/publish_release_draft.yml +++ b/.github/workflows/publish_release_draft.yml @@ -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 == '' @@ -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 }} diff --git a/.github/workflows/sync_develop_with_master.yml b/.github/workflows/sync_develop_with_master.yml deleted file mode 100644 index f945ab9..0000000 --- a/.github/workflows/sync_develop_with_master.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Sync develop branch with master - -on: - push: - branches: - - master - - support/* - -permissions: - contents: write - -jobs: - sync_develop: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@master - - # Check if this is a support branch - - name: Check For support branch - id: is_support_branch - continue-on-error: true - run: | - FILTEREDBRANCHNAME=$(git branch | grep "\* support") - echo "::set-output name=filtered_branch_name::$FILTEREDBRANCHNAME" - - # Get the support branch - - name: Get support branch - id: get_support_branch - if: steps.is_support_branch.outputs.filtered_branch_name != '' - run: | - SUPPORTBRANCH=$(git branch | grep \* | sed -re "s/[\*|\ ]//g") - echo "::set-output name=support_branch::$SUPPORTBRANCH" - - - name: Merge support -> master - uses: devmasx/merge-branch@master - if: steps.is_support_branch.outputs.filtered_branch_name != '' - with: - type: now - from_branch: ${{ steps.get_support_branch.outputs.support_branch }} - target_branch: master - github_token: ${{ secrets.GITHUB_TOKEN }} - message: Merged ${{ steps.get_support_branch.outputs.support_branch }} into master - - - name: Merge master -> develop - uses: devmasx/merge-branch@master - with: - type: now - from_branch: master - target_branch: develop - github_token: ${{ secrets.GITHUB_TOKEN }} - message: Merged master into develop