Skip to content

Version Increment

Version Increment #31

Workflow file for this run

name: "Version Increment"
on:
push:
# run whenever pushes or merges are done to a non-default branch
branches:
- '*'
- '!main'
workflow_dispatch:
jobs:
version:
runs-on: ubuntu-latest
steps:
-
name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v7
-
uses: actions/checkout@v4
with:
ref: ${{ steps.branch-name.outputs.current_branch }}
fetch-depth: 0
-
run: |
echo "github ref = ${{ github.ref }}
and ${{ steps.branch-name.outputs.current_branch }}
and ${{ github.GITHUB_HEAD_REF }}"
-
run: git switch ${{ steps.branch-name.outputs.current_branch }}
-
name: Bump version
run: |
SEM_VER=$(cat VERSION | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}')
echo $SEM_VER
COMMIT_MSG=$(git log --format=%B -n 1 ${{ github.event.after }})
echo $COMMIT_MSG
# Write files
echo $SEM_VER > VERSION
# Add new git commit
git add VERSION
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "[Automated] Increment Version"
-
name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ steps.branch-name.outputs.current_branch }}