Skip to content

Commit

Permalink
Add auto tag updating for major version (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
timja authored Oct 4, 2024
1 parent dfdc0c6 commit 5bdb012
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/self-update-major-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
required: false
description: The tag to move major version tag to
default: ""
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: version
id: version
env:
INPUT_TAG: ${{ inputs.tag }}
run: |
if [[ "${INPUT_TAG}" =~ ^v[0-9]+.[0-9]+.[0-9]+$ ]]; then
tag="${INPUT_TAG}"
fi
if [[ ! -z "${GITHUB_REF}" ]] && [[ "${GITHUB_REF}" =~ ^refs/tags/v[0-9]+.[0-9]+.[0-9]+$ ]]; then
tag=${GITHUB_REF/refs\/tags\//}
fi
if [[ -z "${tag}" ]]; then
echo "No tag found"
exit 1
fi
version=${tag#v}
major=${version%%.*}
echo "tag=${tag}" >> $GITHUB_OUTPUT
echo "version=${version}" >> $GITHUB_OUTPUT
echo "major=${major}" >> $GITHUB_OUTPUT
- name: force update major tag
run: |
git tag v${{ steps.version.outputs.major }} ${{ steps.version.outputs.tag }} -f
git push origin refs/tags/v${{ steps.version.outputs.major }} -f

0 comments on commit 5bdb012

Please sign in to comment.