diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml new file mode 100644 index 0000000..0e5d0c4 --- /dev/null +++ b/.forgejo/workflows/release.yml @@ -0,0 +1,57 @@ +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: 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 + skip-assets: true + tag: ${{ forgejo.ref_name }} + title: ${{ forgejo.ref_name }} + release-notes-file: dist/notes.md diff --git a/.forgejo/workflows/tests.yml b/.forgejo/workflows/tests.yml new file mode 100644 index 0000000..62e78b2 --- /dev/null +++ b/.forgejo/workflows/tests.yml @@ -0,0 +1,23 @@ +name: tests + +on: + push: + branches: + - '**' + workflow_call: + +jobs: + pytest: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + + - name: Setup uv + uses: astral-sh/setup-uv@v10.3.3 + + - name: Install dependencies + run: uv sync --frozen + + - name: Run the test suite + run: uv run --frozen pytest