Gitea refuses secret names starting with GITEA_, so GITEA_TOKEN could never be set and every release failed; it is RELEASE_TOKEN now. git over HTTP is disabled on this Gitea, so the tap formula is updated through the contents API instead of a clone and push. Claude-Session: https://claude.ai/code/session_012LCTmU2ewo8tnM1dByYAoG
87 lines
3.3 KiB
YAML
87 lines
3.3 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
# Built on Arch: the locker needs gtk-session-lock (not packaged by Ubuntu).
|
|
container:
|
|
image: archlinux:base-devel
|
|
steps:
|
|
- name: Install system dependencies
|
|
run: pacman -Syu --noconfirm --needed base-devel git openssh nodejs rust meson ninja gtk3 gtk-session-lock gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad-libs pam curl python
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Compute source tarball SHA256
|
|
run: |
|
|
SHA256=$(curl -fsSL \
|
|
"https://gitea.weircon.dk/agw/gtk-ahfail/archive/${{ github.ref_name }}.tar.gz" \
|
|
| sha256sum | cut -d' ' -f1)
|
|
echo "SOURCE_SHA256=${SHA256}" >> $GITHUB_ENV
|
|
|
|
- name: Build release
|
|
run: |
|
|
meson setup builddir --buildtype=release
|
|
meson compile -C builddir
|
|
|
|
- name: Bundle artifacts
|
|
run: |
|
|
mkdir -p dist
|
|
cp builddir/ahfail-module.so dist/
|
|
cp builddir/libahfail_pam.so dist/
|
|
cp builddir/ahfail-display dist/
|
|
cp builddir/ahfail dist/
|
|
cp data/pam.d/ahfail dist/ahfail.pam
|
|
tar czf ahfail-linux-x86_64.tar.gz -C dist .
|
|
|
|
- name: Upload release asset
|
|
# RELEASE_TOKEN: an agw token with write:repository scope. Gitea refuses
|
|
# secret names that start with GITEA_ or GITHUB_, so it cannot be called
|
|
# GITEA_TOKEN.
|
|
uses: https://gitea.com/actions/gitea-release-action@v1
|
|
with:
|
|
token: ${{ secrets.RELEASE_TOKEN }}
|
|
server_url: ${{ github.server_url }}
|
|
tag_name: ${{ github.ref_name }}
|
|
name: ${{ github.ref_name }}
|
|
files: ahfail-linux-x86_64.tar.gz
|
|
|
|
- name: Update Homebrew tap
|
|
# git over HTTP is disabled on this Gitea on purpose, so the formula is
|
|
# updated through the contents API instead of a clone and push.
|
|
env:
|
|
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
TAG: ${{ github.ref_name }}
|
|
API: ${{ github.server_url }}/api/v1/repos/agw/homebrew-ahfail/contents/Formula/ahfail.rb
|
|
run: |
|
|
python3 - <<'PY'
|
|
import base64, json, os, re, urllib.request
|
|
|
|
api, token, tag = os.environ["API"], os.environ["RELEASE_TOKEN"], os.environ["TAG"]
|
|
sha256 = os.environ["SOURCE_SHA256"]
|
|
headers = {"Authorization": f"token {token}", "Content-Type": "application/json"}
|
|
|
|
with urllib.request.urlopen(urllib.request.Request(api, headers=headers)) as r:
|
|
current = json.load(r)
|
|
formula = base64.b64decode(current["content"]).decode()
|
|
new = re.sub(r'url ".*?"', f'url "https://gitea.weircon.dk/agw/gtk-ahfail/archive/{tag}.tar.gz"', formula, count=1)
|
|
new = re.sub(r'sha256 ".*?"', f'sha256 "{sha256}"', new, count=1)
|
|
if new == formula:
|
|
print("formula already up to date")
|
|
raise SystemExit(0)
|
|
|
|
body = json.dumps({
|
|
"content": base64.b64encode(new.encode()).decode(),
|
|
"sha": current["sha"],
|
|
"message": f"chore: update ahfail to {tag}",
|
|
}).encode()
|
|
req = urllib.request.Request(api, data=body, headers=headers, method="PUT")
|
|
with urllib.request.urlopen(req) as r:
|
|
print("formula updated:", r.status)
|
|
PY
|