-
-
Notifications
You must be signed in to change notification settings - Fork 21
69 lines (57 loc) · 2.33 KB
/
Copy pathrelease.yml
File metadata and controls
69 lines (57 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: horde-engine build and publish
# Publish on a pushed version tag. The tag IS the version: hatch-vcs derives the
# package version from it (see [tool.hatch.version] in pyproject.toml), so a clean
# `vX.Y.Z` tag at HEAD produces a clean `X.Y.Z` release. To cut a release:
# git tag vX.Y.Z && git push origin vX.Y.Z
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
permissions:
id-token: write # IMPORTANT: mandatory for PyPI trusted publishing
contents: write # create the GitHub Release for the tag
jobs:
build-and-publish:
name: build and publish horde-engine
runs-on: ubuntu-latest
environment: # see https://github.com/pypa/gh-action-pypi-publish/tree/release/v1/
name: pypi
url: https://pypi.org/p/horde-engine/
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
steps:
# Full history + tags so hatch-vcs can resolve the version from the tag.
- name: "✔️ Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "📦 Set up uv"
uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"
# Builds an sdist, then a wheel from that sdist, into dist/.
- name: "🔧 Build sdist and wheel"
run: uv build
# Insurance against tag/HEAD drift: never publish a dev/local version.
- name: "🔎 Verify built version matches the tag"
run: |
tag="${GITHUB_REF_NAME#v}"
built="$(ls dist/*.whl | sed -E 's/.*horde_engine-([^-]+)-.*/\1/')"
echo "tag=$tag built=$built"
if [ "$tag" != "$built" ]; then
echo "::error::Built version ($built) does not match tag ($tag). Is HEAD exactly at the tag?"
exit 1
fi
- name: "📦 Publish distribution to PyPI"
uses: pypa/gh-action-pypi-publish@release/v1
- name: "📝 Create GitHub Release"
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: dist/*
- name: "📣 Announce on Discord"
if: ${{ success() && env.DISCORD_WEBHOOK_URL != '' }}
uses: tsickert/discord-webhook@v5.3.0
with:
webhook-url: ${{ env.DISCORD_WEBHOOK_URL }}
content: "New version of horde-engine published to PyPI: ${{ github.ref_name }} — https://pypi.org/project/horde-engine/"