From 409147fab7f8676676fc6694ad3f669db2b06373 Mon Sep 17 00:00:00 2001 From: Eddie Jaoude Date: Sun, 30 Jun 2024 19:05:14 +0100 Subject: [PATCH] feat: release action --- .github/workflows/release.yml | 60 +++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c2915eb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +name: Release +on: + push: + branches: + - main + +jobs: + changelog: + if: github.repository == 'EddieHubCommunity/EddieHubCommunity.github.io' + runs-on: ubuntu-latest + + steps: + # check out the repository with all releases + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Create a temporary, uniquely named branch to push release info to + - name: create temporary branch + run: git branch "release-from-${{ github.sha }}" "${{ github.sha }}" + + # switch to the temporary branch + - name: switch to new branch + run: git checkout release-from-${{ github.sha }} + + # create release info and push it upstream + - name: conventional Changelog Action + id: changelog + uses: TriPSs/conventional-changelog-action@v3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + version-file: "./package.json,./package-lock.json,./src/config/app.json" + git-branch: "release-from-${{ github.sha }}" + skip-git-pull: true + + # create PR using GitHub CLI + - name: create PR with release info + if: steps.changelog.outputs.skipped == 'false' + id: create-pr + run: gh pr create --base main --head release-from-${{ github.sha }} --title 'Merge new release into main' --body 'Created by Github action' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # merge PR using GitHub CLI + - name: merge PR with release info + if: steps.changelog.outputs.skipped == 'false' + id: merge-pr + run: gh pr merge --admin --merge --subject 'Merge release info' --delete-branch + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # release info is now in main so we can continue as before + - name: create release with last commit + if: steps.changelog.outputs.skipped == 'false' + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.CHANGELOG_RELEASE }} + tag: ${{ steps.changelog.outputs.tag }} + name: ${{ steps.changelog.outputs.tag }} + body: ${{ steps.changelog.outputs.clean_changelog }}