Skip to content

Updated version def as a base and updated build and release process a… #2

Updated version def as a base and updated build and release process a…

Updated version def as a base and updated build and release process a… #2

Workflow file for this run

name: Version Bump
on:
push:
branches:
- master
jobs:
version-bump:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get base version from VERSION.md
id: get_base_version
run: echo "BASE_VERSION=$(cat VERSION.md)" >> $GITHUB_OUTPUT
- name: Get latest tag
id: get_latest_tag
run: echo "LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo v0.0.0)" >> $GITHUB_OUTPUT
- name: Determine new version
id: determine_version
run: |
base_version="${{ steps.get_base_version.outputs.BASE_VERSION }}"
latest_tag="${{ steps.get_latest_tag.outputs.LATEST_TAG }}"
if [ "$(printf '%s\n' "$base_version" "$latest_tag" | sort -V | tail -n1)" = "$base_version" ]; then
# Use base version if it's greater
new_version="$base_version"
else
# Increment patch version of latest tag
version=$(echo $latest_tag | sed 's/v//')
IFS='.' read -ra ADDR <<< "$version"
new_patch=$((ADDR[2] + 1))
new_version="v${ADDR[0]}.${ADDR[1]}.$new_patch"
fi
echo "NEW_VERSION=$new_version" >> $GITHUB_OUTPUT
- name: Create and push new tag
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git tag ${{ steps.determine_version.outputs.NEW_VERSION }}
git push origin ${{ steps.determine_version.outputs.NEW_VERSION }}
- name: Trigger build and release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh workflow run build-and-release.yml --ref ${{ steps.determine_version.outputs.NEW_VERSION }}
outputs:
new_version: ${{ steps.determine_version.outputs.NEW_VERSION }}