Skip to content

Commit

Permalink
Fix version replacement for alpha to stable bump (#311)
Browse files Browse the repository at this point in the history
Version replacement would fail when replacing an alpha version for its
next stable version, because Git `v:refname` tag sorting puts qualified
versions (e.g. `1.0-alpha01`) after non-qualified ones (`1.0`).

Tested manually with
[dispatch](https://github.com/gabrielfeo/develocity-api-kotlin/actions/runs/10814010943/job/29999397756),
which resulted in #314.
  • Loading branch information
gabrielfeo authored Sep 11, 2024
1 parent dec8207 commit fd8544c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/update-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
push:
tags: [ '*' ]
workflow_dispatch:
inputs:
ref:
description: 'Branch or tag'
required: true

defaults:
run:
Expand All @@ -21,16 +25,21 @@ jobs:
- run: pip install -r .github/scripts/requirements.txt
- name: 'Get versions'
run: |
old_version="$(git tag --sort=-v:refname | head -n 2 | tail -n 1)"
echo "OLD_VERSION=$old_version" >> $GITHUB_ENV
echo "NEW_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
new="${{ inputs.ref || github.ref_name }}"
echo "Deleting '$new' in case it's alpha to stable bump." \
"Git v:refname doesn't handle Maven version qualifiers correctly."
git tag -d "$new"
old="$(git tag --sort=-v:refname | head -n 1)"
echo "OLD_VERSION=$old" | tee -a $GITHUB_ENV
echo "NEW_VERSION=$new" | tee -a $GITHUB_ENV
- name: 'Update version in all files'
run: ./.github/scripts/replace_string.py ./ "$OLD_VERSION" "$NEW_VERSION"
- name: 'Create PR'
uses: peter-evans/create-pull-request@v7
with:
base: 'main'
branch: "replace-${{ env.OLD_VERSION }}-${{ env.NEW_VERSION }}"
title: "Bump library version in examples to ${{ env.NEW_VERSION }}"
title: "Bump examples and badges to ${{ env.NEW_VERSION }}"
author: "github-actions <github-actions@github.com>"
committer: "github-actions <github-actions@github.com>"
body: "Bump the version in examples and badges from ${{ env.OLD_VERSION }} to ${{ env.NEW_VERSION }}."

0 comments on commit fd8544c

Please sign in to comment.