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+ # Git does not create tags when a PR merges. This workflow tags main when
2+ # extension.yml's version changes so archive URLs like .../refs/tags/vX.Y.Z.zip work.
3+ name : Tag version on main
4+
5+ on :
6+ push :
7+ branches : [main]
8+ paths :
9+ - " extension.yml"
10+
11+ jobs :
12+ tag-if-needed :
13+ runs-on : ubuntu-latest
14+ permissions :
15+ contents : write
16+ steps :
17+ - uses : actions/checkout@v4
18+ with :
19+ fetch-depth : 0
20+
21+ - name : Parse version from extension.yml
22+ id : meta
23+ run : |
24+ VERSION=$(python3 <<'PY'
25+ import re
26+ from pathlib import Path
27+ text = Path("extension.yml").read_text()
28+ m = re.search(r'^\s+version:\s*"(?P<v>[0-9]+\.[0-9]+\.[0-9]+)"', text, re.M)
29+ if not m:
30+ raise SystemExit("Could not parse extension.version in extension.yml")
31+ print(m.group("v"))
32+ PY
33+ )
34+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
35+ echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
36+
37+ - name : Create annotated tag if missing
38+ env :
39+ TAG : ${{ steps.meta.outputs.tag }}
40+ run : |
41+ git fetch origin --tags
42+ if git rev-parse "$TAG" >/dev/null 2>&1; then
43+ echo "Tag $TAG already exists — nothing to do."
44+ exit 0
45+ fi
46+ git config user.name "github-actions[bot]"
47+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
48+ git tag -a "$TAG" -m "Release $TAG"
49+ git push origin "$TAG"
50+ echo "Pushed $TAG"
You can’t perform that action at this time.
0 commit comments