From 562c22af8299575ac73017a5a71fc06c64a78ebf Mon Sep 17 00:00:00 2001 From: "Eryk K." Date: Mon, 8 Jan 2024 01:39:36 +0100 Subject: [PATCH] feat(releases): Refactor Github Actions for releases. Add CHANGELOG generation. --- .github/workflows/pages.yml | 4 +-- .github/workflows/pre-release.yml | 42 ++++++++++++++++++++++++++++--- publish.sh | 6 ++--- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index f66c678..915750b 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -1,4 +1,4 @@ -name: Deploy Docusaurus site to Pages +name: Deploy docs Pages on: push: @@ -40,7 +40,7 @@ jobs: path: docs-web/build # Deployment job - deploy: + deploy-docs: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 6ba092d..82c6dd1 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -27,9 +27,43 @@ jobs: working-directory: ./ansible run: ansible-playbook -i inventory.yml setup-ubuntu.yml - - uses: "marvinpinto/action-automatic-releases@latest" + - name: Get previous tag + id: previousTag + run: | + name=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | tail -2 | head -1) + echo "previousTag: $name" + echo "previousTag=$name" >> $GITHUB_ENV + + - name: Update CHANGELOG + id: changelog + uses: requarks/changelog-action@v1 + with: + token: ${{ github.token }} + fromTag: latest + toTag: ${{ env.previousTag }} + + - name: Create Pre-Release + uses: ncipollo/release-action@v1.12.0 with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "latest" + allowUpdates: true + draft: false + makeLatest: true + tag: latest prerelease: true - title: "Pre-release Build" + name: ${{ github.ref_name }} + body: ${{ steps.changelog.outputs.changes }} + token: ${{ github.token }} + + - name: Commit CHANGELOG.md + uses: stefanzweifel/git-auto-commit-action@v4 + with: + branch: main + commit_message: 'docs: update CHANGELOG.md for ${{ github.ref_name }}' + file_pattern: CHANGELOG.md + + # - uses: "marvinpinto/action-automatic-releases@latest" + # with: + # repo_token: "${{ secrets.GITHUB_TOKEN }}" + # automatic_release_tag: "latest" + # prerelease: true + # title: "Pre-release Build" diff --git a/publish.sh b/publish.sh index 079922b..f8d9c49 100755 --- a/publish.sh +++ b/publish.sh @@ -17,13 +17,13 @@ echo 'git add' git add . echo 'git commit updated versions' -git commit -a -m 'release: Update versions' +git commit -a -m 'build: Release updated versions' echo 'Update docs' rsync -avrE ${SCRIPT_DIR}/docs-web/docs/ ${SCRIPT_DIR}/docs-web/versioned_docs/version-stable/ echo 'git commit updated docs' -git commit -a -m 'release: Update docs' +git commit -a -m 'build: Release updated docs' echo 'git push' git push @@ -50,7 +50,7 @@ echo 'git add' git add . echo 'git commit' -git commit -a -m 'release: Set latest versions for development' +git commit -a -m 'build: Set latest versions for development' echo 'git push' git push