From c49a05651fd8b71a65940470d8045f7ef2e3b94a Mon Sep 17 00:00:00 2001 From: Florin Lungu Date: Mon, 8 Jan 2024 17:35:45 +0200 Subject: [PATCH] fix workflow for version bump --- .github/workflows/version_bump.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/version_bump.yaml b/.github/workflows/version_bump.yaml index 8ab0fa21..1ff4bffb 100644 --- a/.github/workflows/version_bump.yaml +++ b/.github/workflows/version_bump.yaml @@ -29,12 +29,12 @@ jobs: echo "Latest release tag of gohugoio/hugo is ${release_tag}" echo "hugo_latest_release_tag=${release_tag}" >> $GITHUB_ENV - - name: Identify latest release branch + - name: Identify latest release tag run: | - git fetch -a origin - latest_branch=$(git branch -r --sort=committerdate | grep -E "*/release/*" | tail -1 | awk -F'/' '{print $NF}') - echo "My latest release branch is ${latest_branch}" - echo "latest_branch=${latest_branch}" >> $GITHUB_ENV + releases=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/floryn90/docker-hugo/releases?per_page=1&page=1) + my_release_tag=$(echo $releases | jq '.[0].tag_name' | sed 's/v//' | sed 's/"//g') + echo "My latest release tag is ${my_release_tag}" + echo "my_release_tag=${my_release_tag}" >> $GITHUB_ENV - name: Configure Git User's information run: | @@ -42,7 +42,7 @@ jobs: git config --global user.name 'Florin Lungu' - name: Create new release branch and run version bump - if: env.latest_branch != env.hugo_latest_release_tag + if: env.my_release_tag != env.hugo_latest_release_tag run: | git checkout -b release/${{ env.hugo_latest_release_tag }} version=${{env.hugo_latest_release_tag}} make bump @@ -53,19 +53,19 @@ jobs: - name: Create new PR with latest release branch id: pr - if: env.latest_branch != env.hugo_latest_release_tag + if: env.my_release_tag != env.hugo_latest_release_tag run: | pr=$(gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/floryn90/docker-hugo/pulls -f title="Hugo version bump to ${{env.hugo_latest_release_tag}}" -f body="Hugo version bump to ${{env.hugo_latest_release_tag}}" -f head="release/${{env.hugo_latest_release_tag}}" -f base='master') pr_number=$(echo $pr | jq '.number') echo "pr_number=${pr_number}" >> $GITHUB_OUTPUT - name: Merge the PR - if: env.latest_branch != env.hugo_latest_release_tag + if: env.my_release_tag != env.hugo_latest_release_tag run: | gh api --method PUT -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/floryn90/docker-hugo/pulls/${{ steps.pr.outputs.pr_number }}/merge -f commit_title="Merge PR ${{ steps.pr.outputs.pr_number }}" -f commit_message='Merge pull request to upgrade hugo version' - name: Create new release tag - if: env.latest_branch != env.hugo_latest_release_tag + if: env.my_release_tag != env.hugo_latest_release_tag run: | gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/floryn90/docker-hugo/releases -f tag_name="v${{ env.hugo_latest_release_tag }}" -f target_commitish='master' -f name="Hugo version v${{env.hugo_latest_release_tag}}" -f body="Hugo release version bump to ${{env.hugo_latest_release_tag}}" -F draft=false -F prerelease=false -F generate_release_notes=false