7d361549e1
Nightly update.yml rewrote PKGBUILD then failed with pre-receive hook declined on protected master and tags. Push chore/bump-$pkgver and open (or reuse) a PR instead. After merge, tag-release.yml creates v$pkgver so build.yml still attaches the package.
59 lines
2.0 KiB
YAML
59 lines
2.0 KiB
YAML
name: Tag release after merge
|
|
on:
|
|
push:
|
|
branches: ['master']
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
tag:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GITEA_TOKEN }}
|
|
- name: Create v$pkgver tag if missing
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
set -euo pipefail
|
|
if [[ "${GITHUB_REF:-}" != "refs/heads/master" ]]; then
|
|
echo "error: refusing to tag from ${GITHUB_REF:-unset}; only master" >&2
|
|
exit 1
|
|
fi
|
|
pkgver=$(sed -n 's/^pkgver=//p' PKGBUILD | head -1)
|
|
if [[ -z "$pkgver" ]]; then
|
|
echo "error: could not read pkgver from PKGBUILD" >&2
|
|
exit 1
|
|
fi
|
|
if [[ ! "$pkgver" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z]+)*$ ]]; then
|
|
echo "error: PKGBUILD pkgver looks wrong: $pkgver" >&2
|
|
exit 1
|
|
fi
|
|
if [[ -z "${GITHUB_SHA:-}" ]]; then
|
|
echo "error: GITHUB_SHA is empty; cannot tag v${pkgver}" >&2
|
|
exit 1
|
|
fi
|
|
tag="v${pkgver}"
|
|
existing=$(git ls-remote --tags origin "refs/tags/${tag}")
|
|
if [[ -n "$existing" ]]; then
|
|
echo "Tag ${tag} already exists; nothing to do"
|
|
exit 0
|
|
fi
|
|
if [[ -z "${GITEA_TOKEN:-}" ]]; then
|
|
echo "error: GITEA_TOKEN is empty; cannot push tag ${tag}" >&2
|
|
exit 1
|
|
fi
|
|
git tag "${tag}" "${GITHUB_SHA}"
|
|
if git push origin "refs/tags/${tag}"; then
|
|
echo "Pushed tag ${tag} -> ${GITHUB_SHA}"
|
|
exit 0
|
|
fi
|
|
existing=$(git ls-remote --tags origin "refs/tags/${tag}")
|
|
if [[ -n "$existing" ]]; then
|
|
echo "Tag ${tag} appeared concurrently; nothing to do"
|
|
exit 0
|
|
fi
|
|
echo "error: could not push tag ${tag} for ${GITHUB_SHA}." >&2
|
|
echo "error: Manual path: git tag ${tag} && git push origin ${tag} so build.yml can attach the release asset." >&2
|
|
exit 1
|