Files
beefy-player/.forgejo/workflows/release.yml
T

100 lines
3.5 KiB
YAML

name: release
on:
push:
tags:
- 'v*'
jobs:
tests:
uses: ./.forgejo/workflows/tests.yml
release:
needs: tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Check the tag matches the package version
run: |
python3 - <<'PY'
import os, tomllib
from pathlib import Path
pyproject = tomllib.loads(Path("pyproject.toml").read_text())["project"]["version"]
namespace = {}
exec(Path("beefy_player/__init__.py").read_text(), namespace)
tag = os.environ["FORGEJO_REF_NAME"].removeprefix("v")
assert pyproject == namespace["__version__"] == tag, (
pyproject, namespace["__version__"], tag
)
PY
- name: Setup uv
uses: astral-sh/[email protected]
# No `submodules:` on the checkout above, so the tap is empty here and the
# sdist below differs from a local `uv build` with the submodule populated.
# The published asset is therefore the authority: bump_packaging.py
# hashes the download, never a rebuild.
- name: Build the sdist and wheel
run: |
uv build --out-dir dist/release
# PKGBUILD and the tap formula name this exact file.
test -f "dist/release/beefy_player-${FORGEJO_REF_NAME#v}.tar.gz"
- name: Generate release notes
run: |
previous="$(git describe --tags --abbrev=0 "${FORGEJO_REF_NAME}^" 2>/dev/null || true)"
{
echo "beefy-player ${FORGEJO_REF_NAME#v}"
echo
if [ -n "$previous" ]; then
echo "Changes since $previous:"
git log --pretty='- %s (%h)' "$previous..$FORGEJO_REF_NAME"
else
echo "First tagged release."
fi
} > dist/notes.md
- name: Publish the release
uses: actions/forgejo-release@v2
with:
direction: upload
# A re-run finds the release it made last time and would otherwise die
# on `curl: (22) ... 409` when it tries to create it again. Override
# deletes and recreates the release (the tag survives, since it still
# matches the triggered SHA), so re-running this workflow is safe.
override: true
tag: ${{ forgejo.ref_name }}
title: ${{ forgejo.ref_name }}
release-notes-file: dist/notes.md
# Every packaging channel (AUR, the Homebrew tap and the flake) downloads
# its source from tildeforge, so the release is published there as well.
# That repository is not a mirror of this one: nothing reaches it unless
# it is pushed, hence the tag push before the upload. Pushing a tag that
# is already there and identical is a no-op, so this stays re-runnable.
- name: Push the tag to tildeforge
env:
TILDEFORGE_TOKEN: ${{ secrets.TILDEFORGE_TOKEN }}
run: |
git push \
"https://beefcarver:${TILDEFORGE_TOKEN}@tildeforge.dev/beefcarver/beefy-player.git" \
"refs/tags/${FORGEJO_REF_NAME}"
- name: Publish the release to tildeforge
uses: actions/forgejo-release@v2
with:
direction: upload
url: https://tildeforge.dev
repo: beefcarver/beefy-player
token: ${{ secrets.TILDEFORGE_TOKEN }}
override: true
tag: ${{ forgejo.ref_name }}
title: ${{ forgejo.ref_name }}
release-notes-file: dist/notes.md