File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : AutoTag
2+ on :
3+ push :
4+ branches :
5+ - master
6+ paths :
7+ - ' Project.toml'
8+ jobs :
9+ tag :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - uses : actions/checkout@v4
13+ with :
14+ fetch-depth : 2
15+ - name : Check version change and tag
16+ run : |
17+ VERSION=$(grep '^version' Project.toml | sed 's/version = "\(.*\)"/\1/')
18+ TAG="v$VERSION"
19+
20+ if git ls-remote --tags origin | grep -q "refs/tags/$TAG$"; then
21+ echo "Tag $TAG already exists, skipping"
22+ exit 0
23+ fi
24+
25+ git show HEAD^:Project.toml > /tmp/old_project.toml 2>/dev/null || echo 'version = "0.0.0"' > /tmp/old_project.toml
26+ OLD_VERSION=$(grep '^version' /tmp/old_project.toml | sed 's/version = "\(.*\)"/\1/')
27+
28+ if [ "$VERSION" != "$OLD_VERSION" ]; then
29+ echo "Version changed from $OLD_VERSION to $VERSION, creating tag $TAG"
30+ git config user.name "github-actions[bot]"
31+ git config user.email "github-actions[bot]@users.noreply.github.com"
32+ git tag "$TAG"
33+ git push origin "$TAG"
34+ else
35+ echo "Version unchanged ($VERSION), skipping"
36+ fi
You can’t perform that action at this time.
0 commit comments