Skip to content

fix: add permissions to auto versioner (#5) #3

fix: add permissions to auto versioner (#5)

fix: add permissions to auto versioner (#5) #3

Workflow file for this run

name: Automatically update major tags
on:
push:
tags:
- "v*.*.*"
jobs:
update-major-tag:
name: Update major tag
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
persist-credentials: true
- name: Configure git
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Update tags
run: |
set -eu
NEW_TAG="${GITHUB_REF#refs/tags/}"
[ -z "$NEW_TAG" ] && exit 10
MAJOR=$(expr "$NEW_TAG" : '\(v[0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*$')
[ -z "$MAJOR" ] && exit 20
echo "Creating tag $MAJOR pointing to $NEW_TAG ..."
git fetch --tags
git tag -f "$MAJOR" "$NEW_TAG"
git push origin "$MAJOR" --force