-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (79 loc) · 2.54 KB
/
Copy pathrelease.yml
File metadata and controls
92 lines (79 loc) · 2.54 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: release
# Triggered by pushing a tag matching v*. Builds the Python wheel + sdist
# and publishes to PyPI, and builds the Docker image and pushes to GHCR
# under the same version tag.
#
# Required repository secrets (configure in Settings → Secrets):
# PYPI_API_TOKEN — PyPI project-scoped token (https://pypi.org/manage/account/token/)
# Required permissions:
# contents: read
# packages: write (for ghcr.io)
# (The GITHUB_TOKEN is auto-provided.)
on:
push:
tags:
- 'v*'
jobs:
pypi:
name: build + publish to PyPI
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install build deps
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build wheel + sdist
run: python -m build
- name: Twine check
run: twine check dist/*
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
if [ -z "$TWINE_PASSWORD" ]; then
echo "PYPI_API_TOKEN not set — skipping publish (artifact built only)."
exit 0
fi
twine upload dist/*
docker:
name: build + push docker image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Extract version from tag + lowercase owner
id: ver
run: |
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
# GHCR requires lowercase repo paths; the github actor / owner
# may contain capitals.
echo "owner_lc=${GITHUB_REPOSITORY_OWNER,,}" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build + push (multi-arch)
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ steps.ver.outputs.owner_lc }}/zhub:latest
ghcr.io/${{ steps.ver.outputs.owner_lc }}/zhub:${{ steps.ver.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max