Add workflow to bump build.func revision
This commit is contained in:
parent
7101291349
commit
e6305be04f
44
.github/workflows/revision-bump.yml
vendored
Normal file
44
.github/workflows/revision-bump.yml
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
name: Bump build.func Revision
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
paths:
|
||||||
|
- 'misc/*.func'
|
||||||
|
- 'misc/*.sh'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
bump-revision:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event.head_commit.author.name != 'github-actions[bot]'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Detect misc changes
|
||||||
|
id: changes
|
||||||
|
run: |
|
||||||
|
git diff --name-only HEAD^ HEAD > changed_files.txt
|
||||||
|
echo "changed=$(cat changed_files.txt)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Bump Revision if needed
|
||||||
|
if: contains(steps.changes.outputs.changed, 'misc/') && !contains(steps.changes.outputs.changed, 'misc/build.func')
|
||||||
|
run: |
|
||||||
|
REV_FILE=".build-revision"
|
||||||
|
if [ ! -f "$REV_FILE" ]; then echo 0 > "$REV_FILE"; fi
|
||||||
|
REV_NUM=$(($(cat $REV_FILE) + 1))
|
||||||
|
echo $REV_NUM > $REV_FILE
|
||||||
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
||||||
|
REV_STR="Revision: r${REV_NUM} (git-${SHORT_SHA})"
|
||||||
|
sed -i "s/^# Revision:.*/# $REV_STR/" misc/build.func
|
||||||
|
echo "REV_STR=$REV_STR" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Commit & push revision
|
||||||
|
if: contains(steps.changes.outputs.changed, 'misc/') && !contains(steps.changes.outputs.changed, 'misc/build.func')
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git add misc/build.func .build-revision
|
||||||
|
git commit -m "chore: bump build.func to $REV_STR"
|
||||||
|
git push
|
Loading…
x
Reference in New Issue
Block a user