Skip to content

Commit e2d03f5

Browse files
ci(aur): derive AUR pkgver from __version__, pin checkout to release commit
1 parent cfe7e6e commit e2d03f5

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

.github/workflows/aur-publish.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,25 @@ jobs:
2727
steps:
2828
- name: Check out repo
2929
uses: actions/checkout@v7
30+
with:
31+
# On workflow_run, checkout's default is the default branch — NOT
32+
# the commit the Publish run built. Pin to that commit so the
33+
# version read below is the same one publish.yml's tag guard
34+
# verified. Falls back to github.ref for workflow_dispatch.
35+
ref: ${{ github.event.workflow_run.head_sha || github.ref }}
3036

31-
- name: Read version from PKGBUILD
37+
# The version comes from __version__ — the same source of truth the
38+
# Publish workflow's tag guard checks. The pkgver= line in aur/PKGBUILD
39+
# is only a placeholder; it is overwritten below so a forgotten manual
40+
# bump can never push a stale version to AUR again (the v2.0.0 lesson).
41+
- name: Read version from package
3242
id: version
3343
run: |
34-
PKGVER=$(grep '^pkgver=' aur/PKGBUILD | head -1 | cut -d= -f2 | tr -d "'\"")
44+
PKGVER=$(grep -oP '^__version__\s*=\s*"\K[^"]+' src/ytm_player/__init__.py || true)
45+
if [ -z "$PKGVER" ]; then
46+
echo "::error::Could not read __version__ from src/ytm_player/__init__.py"
47+
exit 1
48+
fi
3549
echo "pkgver=$PKGVER" >> "$GITHUB_OUTPUT"
3650
echo "Detected version: $PKGVER"
3751
@@ -64,6 +78,10 @@ jobs:
6478
- name: Copy PKGBUILD and regenerate .SRCINFO
6579
run: |
6680
cp aur/PKGBUILD /tmp/aur-repo/PKGBUILD
81+
# Force the real version into the pushed PKGBUILD — the pkgver= in
82+
# aur/PKGBUILD is a placeholder and may be stale (the v2.0.0 lesson).
83+
# regenerate_srcinfo.py emits this literal line into .SRCINFO.
84+
sed -i "s/^pkgver=.*/pkgver=${{ steps.version.outputs.pkgver }}/" /tmp/aur-repo/PKGBUILD
6785
python3 scripts/regenerate_srcinfo.py /tmp/aur-repo/PKGBUILD /tmp/aur-repo/.SRCINFO
6886
echo "--- Diff vs previous AUR state ---"
6987
cd /tmp/aur-repo

0 commit comments

Comments
 (0)