Skip to content

Hugo release version bump #207

Hugo release version bump

Hugo release version bump #207

Workflow file for this run

name: Hugo release version bump
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: master
- name: Login to GitHub API
run: |
echo ${{secrets.TOKEN_GITHUB}} > github_token.txt
gh auth login --with-token < github_token.txt
- name: Check latest release tag
id: hugo_tag
run: |
releases=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/gohugoio/hugo/releases?per_page=1&page=1)
release_tag=$(echo $releases | jq '.[0].tag_name' | sed 's/v//' | sed 's/"//g')
echo "Latest release tag of gohugoio/hugo is ${release_tag}"
echo "hugo_latest_release_tag=${release_tag}" >> $GITHUB_ENV
- name: Identify latest release branch
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
- name: Configure Git User's information
run: |
git config --global user.email '[email protected]'
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
run: |
git checkout -b release/${{ env.hugo_latest_release_tag }}
version=${{env.hugo_latest_release_tag}} make bump
git add -A
git reset -- github_token.txt
git commit -m "hugo version bump to ${{env.hugo_latest_release_tag}}"
git push origin release/${{env.hugo_latest_release_tag}}:release/${{env.hugo_latest_release_tag}}
- name: Create new PR with latest release branch
id: pr
if: env.latest_branch != 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
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
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