Repository navigation
57 lines (50 loc) · 1.97 KB
/
Copy pathauto-version-increment.yaml
File metadata and controls
57 lines (50 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# MANAGED by EpiAwarePackageTools.scaffold — do not edit by hand.
name: Auto Version Increment
on:
push:
branches: [main]
# Batched merges to main fire this workflow several times within minutes;
# without a group, each run reads the same Project.toml, computes the same
# next version, and races to push the same branch. Not
# cancel-in-progress: true like most managed workflows (see
# `benchmark-history.yaml`): cancelling a queued run here would make it skip
# observing the version the previous run just landed, so runs queue instead.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
check-version:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 2
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check if version changed
id: version-check
run: |
CURRENT_VERSION=$(grep '^version = ' Project.toml | sed 's/version = "\(.*\)"/\1/')
echo "Current version: $CURRENT_VERSION"
git show HEAD~1:Project.toml > Project.toml.prev
PREV_VERSION=$(grep '^version = ' Project.toml.prev | sed 's/version = "\(.*\)"/\1/')
echo "Previous version: $PREV_VERSION"
if [ "$CURRENT_VERSION" = "$PREV_VERSION" ]; then
echo "Version unchanged, need to increment"
echo "needs_increment=true" >> $GITHUB_OUTPUT
else
echo "Version already changed, no action needed"
echo "needs_increment=false" >> $GITHUB_OUTPUT
fi
- name: Increment version automatically
if: steps.version-check.outputs.needs_increment == 'true'
uses: ./.github/actions/increment-version
with:
increment-type: patch
pr-title-prefix: "chore: auto-increment version"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}