From c5df72d4a40218dc12e410ba063274b09a9448a2 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Tue, 10 Jan 2023 18:46:36 +0100 Subject: [PATCH 1/6] Echo $GITHUB_SHA --- .github/workflows/auto-git-release-staging.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/auto-git-release-staging.yml b/.github/workflows/auto-git-release-staging.yml index f07f1d2..bcd6afe 100644 --- a/.github/workflows/auto-git-release-staging.yml +++ b/.github/workflows/auto-git-release-staging.yml @@ -19,6 +19,8 @@ jobs: with: fetch-depth: 0 # Force fetch all commits - See https://github.com/PaulHatch/semantic-version#important-note-regarding-the-checkout-action + - run: "echo \"$GITHUB_SHA: ${{ GITHUB_SHA }}\"" + # Outputs documentation: https://github.com/PaulHatch/semantic-version/blob/master/src/main.ts#L22-L33 - name: Resolving next Release Candidate version using semantic-version uses: paulhatch/semantic-version@v5.0.2 From d289f692b80dac55b61cf4c4df0d148701e45c6b Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Tue, 10 Jan 2023 18:59:36 +0100 Subject: [PATCH 2/6] Echo github.sha --- .github/workflows/auto-git-release-staging.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/auto-git-release-staging.yml b/.github/workflows/auto-git-release-staging.yml index bcd6afe..a2b9894 100644 --- a/.github/workflows/auto-git-release-staging.yml +++ b/.github/workflows/auto-git-release-staging.yml @@ -19,7 +19,10 @@ jobs: with: fetch-depth: 0 # Force fetch all commits - See https://github.com/PaulHatch/semantic-version#important-note-regarding-the-checkout-action - - run: "echo \"$GITHUB_SHA: ${{ GITHUB_SHA }}\"" + - run: "echo \"GITHUB_SHA: ${{ github.sha }}\"" + +# - name: Expose GitHub slug/short variables # See https://github.com/rlespinasse/github-slug-action#exposed-github-environment-variables +# uses: rlespinasse/github-slug-action@v4.4.0 # See https://github.com/rlespinasse/github-slug-action # Outputs documentation: https://github.com/PaulHatch/semantic-version/blob/master/src/main.ts#L22-L33 - name: Resolving next Release Candidate version using semantic-version @@ -67,7 +70,7 @@ jobs: --title "v${{steps.next_semantic_version.outputs.major}}-rc MAJOR release (auto-updated)" \ --generate-notes \ --prerelease \ - --target $GITHUB_SHA + --target "${{github.sha}}" env: GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" @@ -78,7 +81,7 @@ jobs: gh release edit v${{steps.next_semantic_version.outputs.major}}-rc \ --title "v${{steps.next_semantic_version.outputs.major}}-rc MAJOR release (auto-updated)" \ --prerelease \ - --target $GITHUB_SHA + --target "${{github.sha}}" env: GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" @@ -99,7 +102,7 @@ jobs: --title "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc MINOR release (auto-updated)" \ --generate-notes \ --prerelease \ - --target $GITHUB_SHA + --target "${{github.sha}}" env: GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" @@ -110,6 +113,6 @@ jobs: gh release edit v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc \ --title "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc MINOR release (auto-updated)" \ --prerelease \ - --target $GITHUB_SHA + --target "${{github.sha}}" env: GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" From c761a0eeae81bdbb331323eb5c9c6de7b6172579 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Tue, 10 Jan 2023 19:13:11 +0100 Subject: [PATCH 3/6] Update git tag in addition to gh release --- .github/workflows/auto-git-release-staging.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/auto-git-release-staging.yml b/.github/workflows/auto-git-release-staging.yml index a2b9894..7957f19 100644 --- a/.github/workflows/auto-git-release-staging.yml +++ b/.github/workflows/auto-git-release-staging.yml @@ -78,6 +78,11 @@ jobs: - name: Updating existing release for the major "v${{steps.next_semantic_version.outputs.major}}-rc" version if: ${{ steps.majorTagExists.outputs.exists == 'true' }} run: | + # Update Git tag first (changes the commit associated with the tag) + git tag -m "" -f -a v${{steps.next_semantic_version.outputs.major}}-rc ${{github.sha}} + git push -f origin refs/tags/v${{steps.next_semantic_version.outputs.major}}-rc + + # Update GitHub Release then (update the time of last update of the release) gh release edit v${{steps.next_semantic_version.outputs.major}}-rc \ --title "v${{steps.next_semantic_version.outputs.major}}-rc MAJOR release (auto-updated)" \ --prerelease \ @@ -110,6 +115,11 @@ jobs: - name: Updating existing release for the minor "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc" version if: ${{ steps.minorTagExists.outputs.exists == 'true' }} run: | + # Update Git tag first (changes the commit associated with the tag) + git tag -m "" -f -a v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc ${{github.sha}} + git push -f origin refs/tags/v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc + + # Update GitHub Release then (update the time of last update of the release) gh release edit v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc \ --title "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc MINOR release (auto-updated)" \ --prerelease \ From 80c65f32806a1fb7bae37cbae29e57ea3e1ecd07 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Tue, 10 Jan 2023 19:19:39 +0100 Subject: [PATCH 4/6] Add git committer identity --- .../workflows/auto-git-release-production.yml | 29 +++++++++++++++---- .../workflows/auto-git-release-staging.yml | 12 +++++--- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/.github/workflows/auto-git-release-production.yml b/.github/workflows/auto-git-release-production.yml index be79473..38ebd56 100644 --- a/.github/workflows/auto-git-release-production.yml +++ b/.github/workflows/auto-git-release-production.yml @@ -4,7 +4,6 @@ # # See https://github.com/PaulHatch/semantic-version https://github.com/PaulHatch/semantic-version/tree/v5.0.2 # See https://github.com/softprops/action-gh-release https://github.com/softprops/action-gh-release/tree/v1 -# See https://github.com/Actions-R-Us/actions-tagger https://github.com/Actions-R-Us/actions-tagger/releases/tag/v2.0.3 name: 'Auto release' on: @@ -21,6 +20,8 @@ jobs: with: fetch-depth: 0 # Force fetch all commits - See https://github.com/PaulHatch/semantic-version#important-note-regarding-the-checkout-action + - run: "echo \"GITHUB_SHA: ${{ github.sha }}\"" + # Outputs documentation: https://github.com/PaulHatch/semantic-version/blob/master/src/main.ts#L22-L33 - name: Resolving next Release Candidate version using semantic-version uses: paulhatch/semantic-version@v5.0.2 @@ -56,7 +57,7 @@ jobs: --title "${{steps.next_semantic_version.outputs.version_tag}}" \ --latest \ --generate-notes \ - --target $GITHUB_SHA + --target "${{github.sha}}" env: GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" @@ -76,7 +77,7 @@ jobs: gh release create v${{steps.next_semantic_version.outputs.major}} \ --title "v${{steps.next_semantic_version.outputs.major}} MAJOR release (auto-updated)" \ --generate-notes \ - --target $GITHUB_SHA + --target "${{github.sha}}" env: GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" @@ -84,9 +85,17 @@ jobs: - name: Updating existing release for the major "v${{steps.next_semantic_version.outputs.major}}" version if: ${{ steps.majorTagExists.outputs.exists == 'true' }} run: | + git config --global user.name "GitHub Action Releaser" + git config --global user.email "auto-releaser@github.unly.org" + + # Update Git tag first (changes the commit associated with the tag) + git tag -m "" -f -a v${{steps.next_semantic_version.outputs.major}} ${{github.sha}} + git push -f origin refs/tags/v${{steps.next_semantic_version.outputs.major}} + + # Update GitHub Release then (update the time of last update of the release) gh release edit v${{steps.next_semantic_version.outputs.major}} \ --title "v${{steps.next_semantic_version.outputs.major}} MAJOR release (auto-updated)" \ - --target $GITHUB_SHA + --target "${{github.sha}}" env: GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" @@ -106,7 +115,7 @@ jobs: gh release create v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} \ --title "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} MINOR release (auto-updated)" \ --generate-notes \ - --target $GITHUB_SHA + --target "${{github.sha}}" env: GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" @@ -114,8 +123,16 @@ jobs: - name: Updating existing release for the minor "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}" version if: ${{ steps.minorTagExists.outputs.exists == 'true' }} run: | + git config --global user.name "GitHub Action Releaser" + git config --global user.email "auto-releaser@github.unly.org" + + # Update Git tag first (changes the commit associated with the tag) + git tag -m "" -f -a v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} ${{github.sha}} + git push -f origin refs/tags/v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} + + # Update GitHub Release then (update the time of last update of the release) gh release edit v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} \ --title "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} MINOR release (auto-updated)" \ - --target $GITHUB_SHA + --target "${{github.sha}}" env: GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/auto-git-release-staging.yml b/.github/workflows/auto-git-release-staging.yml index 7957f19..427eef2 100644 --- a/.github/workflows/auto-git-release-staging.yml +++ b/.github/workflows/auto-git-release-staging.yml @@ -15,15 +15,13 @@ jobs: tag-and-release: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - name: Fetching all commits for the current branch + uses: actions/checkout@v3 with: fetch-depth: 0 # Force fetch all commits - See https://github.com/PaulHatch/semantic-version#important-note-regarding-the-checkout-action - run: "echo \"GITHUB_SHA: ${{ github.sha }}\"" -# - name: Expose GitHub slug/short variables # See https://github.com/rlespinasse/github-slug-action#exposed-github-environment-variables -# uses: rlespinasse/github-slug-action@v4.4.0 # See https://github.com/rlespinasse/github-slug-action - # Outputs documentation: https://github.com/PaulHatch/semantic-version/blob/master/src/main.ts#L22-L33 - name: Resolving next Release Candidate version using semantic-version uses: paulhatch/semantic-version@v5.0.2 @@ -78,6 +76,9 @@ jobs: - name: Updating existing release for the major "v${{steps.next_semantic_version.outputs.major}}-rc" version if: ${{ steps.majorTagExists.outputs.exists == 'true' }} run: | + git config --global user.name "GitHub Action Releaser" + git config --global user.email "auto-releaser@github.unly.org" + # Update Git tag first (changes the commit associated with the tag) git tag -m "" -f -a v${{steps.next_semantic_version.outputs.major}}-rc ${{github.sha}} git push -f origin refs/tags/v${{steps.next_semantic_version.outputs.major}}-rc @@ -115,6 +116,9 @@ jobs: - name: Updating existing release for the minor "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc" version if: ${{ steps.minorTagExists.outputs.exists == 'true' }} run: | + git config --global user.name "GitHub Action Releaser" + git config --global user.email "auto-releaser@github.unly.org" + # Update Git tag first (changes the commit associated with the tag) git tag -m "" -f -a v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc ${{github.sha}} git push -f origin refs/tags/v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc From 80c332b2e7b6a79d268dc61a2b9c00145d4f4a94 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Tue, 10 Jan 2023 19:25:43 +0100 Subject: [PATCH 5/6] Explore alternative (delete + create again) instead --- .../workflows/auto-git-release-production.yml | 20 +++++---------- .../workflows/auto-git-release-staging.yml | 25 ++++++------------- 2 files changed, 14 insertions(+), 31 deletions(-) diff --git a/.github/workflows/auto-git-release-production.yml b/.github/workflows/auto-git-release-production.yml index 38ebd56..cc420d6 100644 --- a/.github/workflows/auto-git-release-production.yml +++ b/.github/workflows/auto-git-release-production.yml @@ -82,15 +82,11 @@ jobs: GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" # See https://cli.github.com/manual/gh_release_edit - - name: Updating existing release for the major "v${{steps.next_semantic_version.outputs.major}}" version + - name: Recreating existing release for the major "v${{steps.next_semantic_version.outputs.major}}" version if: ${{ steps.majorTagExists.outputs.exists == 'true' }} run: | - git config --global user.name "GitHub Action Releaser" - git config --global user.email "auto-releaser@github.unly.org" - - # Update Git tag first (changes the commit associated with the tag) - git tag -m "" -f -a v${{steps.next_semantic_version.outputs.major}} ${{github.sha}} - git push -f origin refs/tags/v${{steps.next_semantic_version.outputs.major}} + # Delete and create the release again + gh release delete v${{steps.next_semantic_version.outputs.major}} --cleanup-tag --yes # Update GitHub Release then (update the time of last update of the release) gh release edit v${{steps.next_semantic_version.outputs.major}} \ @@ -120,15 +116,11 @@ jobs: GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" # See https://cli.github.com/manual/gh_release_edit - - name: Updating existing release for the minor "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}" version + - name: Recreating existing release for the minor "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}" version if: ${{ steps.minorTagExists.outputs.exists == 'true' }} run: | - git config --global user.name "GitHub Action Releaser" - git config --global user.email "auto-releaser@github.unly.org" - - # Update Git tag first (changes the commit associated with the tag) - git tag -m "" -f -a v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} ${{github.sha}} - git push -f origin refs/tags/v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} + # Delete and create the release again + gh release delete v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} --cleanup-tag --yes # Update GitHub Release then (update the time of last update of the release) gh release edit v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} \ diff --git a/.github/workflows/auto-git-release-staging.yml b/.github/workflows/auto-git-release-staging.yml index 427eef2..13e2e44 100644 --- a/.github/workflows/auto-git-release-staging.yml +++ b/.github/workflows/auto-git-release-staging.yml @@ -73,17 +73,12 @@ jobs: GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" # See https://cli.github.com/manual/gh_release_edit - - name: Updating existing release for the major "v${{steps.next_semantic_version.outputs.major}}-rc" version + - name: Recreating existing release for the major "v${{steps.next_semantic_version.outputs.major}}-rc" version if: ${{ steps.majorTagExists.outputs.exists == 'true' }} run: | - git config --global user.name "GitHub Action Releaser" - git config --global user.email "auto-releaser@github.unly.org" + # Delete and create the release again + gh release delete v${{steps.next_semantic_version.outputs.major}}-rc --cleanup-tag --yes - # Update Git tag first (changes the commit associated with the tag) - git tag -m "" -f -a v${{steps.next_semantic_version.outputs.major}}-rc ${{github.sha}} - git push -f origin refs/tags/v${{steps.next_semantic_version.outputs.major}}-rc - - # Update GitHub Release then (update the time of last update of the release) gh release edit v${{steps.next_semantic_version.outputs.major}}-rc \ --title "v${{steps.next_semantic_version.outputs.major}}-rc MAJOR release (auto-updated)" \ --prerelease \ @@ -113,19 +108,15 @@ jobs: GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" # See https://cli.github.com/manual/gh_release_edit - - name: Updating existing release for the minor "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc" version + - name: Recreating existing release for the minor "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc" version if: ${{ steps.minorTagExists.outputs.exists == 'true' }} run: | - git config --global user.name "GitHub Action Releaser" - git config --global user.email "auto-releaser@github.unly.org" - - # Update Git tag first (changes the commit associated with the tag) - git tag -m "" -f -a v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc ${{github.sha}} - git push -f origin refs/tags/v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc + # Delete and create the release again + gh release delete v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc --cleanup-tag --yes - # Update GitHub Release then (update the time of last update of the release) - gh release edit v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc \ + gh release create v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc \ --title "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}-rc MINOR release (auto-updated)" \ + --generate-notes \ --prerelease \ --target "${{github.sha}}" env: From 5339bde98c588ecaa76b48e9589b3c2f642af8f8 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Tue, 10 Jan 2023 19:26:46 +0100 Subject: [PATCH 6/6] Oops --- .github/workflows/auto-git-release-production.yml | 8 ++++---- .github/workflows/auto-git-release-staging.yml | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/auto-git-release-production.yml b/.github/workflows/auto-git-release-production.yml index cc420d6..35c1047 100644 --- a/.github/workflows/auto-git-release-production.yml +++ b/.github/workflows/auto-git-release-production.yml @@ -88,9 +88,9 @@ jobs: # Delete and create the release again gh release delete v${{steps.next_semantic_version.outputs.major}} --cleanup-tag --yes - # Update GitHub Release then (update the time of last update of the release) - gh release edit v${{steps.next_semantic_version.outputs.major}} \ + gh release create v${{steps.next_semantic_version.outputs.major}} \ --title "v${{steps.next_semantic_version.outputs.major}} MAJOR release (auto-updated)" \ + --generate-notes \ --target "${{github.sha}}" env: GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" @@ -122,9 +122,9 @@ jobs: # Delete and create the release again gh release delete v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} --cleanup-tag --yes - # Update GitHub Release then (update the time of last update of the release) - gh release edit v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} \ + gh release create v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} \ --title "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} MINOR release (auto-updated)" \ + --generate-notes \ --target "${{github.sha}}" env: GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/auto-git-release-staging.yml b/.github/workflows/auto-git-release-staging.yml index 13e2e44..2d2b5e9 100644 --- a/.github/workflows/auto-git-release-staging.yml +++ b/.github/workflows/auto-git-release-staging.yml @@ -79,8 +79,9 @@ jobs: # Delete and create the release again gh release delete v${{steps.next_semantic_version.outputs.major}}-rc --cleanup-tag --yes - gh release edit v${{steps.next_semantic_version.outputs.major}}-rc \ + gh release create v${{steps.next_semantic_version.outputs.major}}-rc \ --title "v${{steps.next_semantic_version.outputs.major}}-rc MAJOR release (auto-updated)" \ + --generate-notes \ --prerelease \ --target "${{github.sha}}" env: