-
Notifications
You must be signed in to change notification settings - Fork 6
95 lines (80 loc) · 2.35 KB
/
Copy pathrelease.yml
File metadata and controls
95 lines (80 loc) · 2.35 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
93
94
95
name: Release Workflow
on:
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup uv
uses: astral-sh/setup-uv@v10.0.1
with:
version: "~=0.9.16"
- name: Check tag
# For test releases, we allow any version
if: github.event_name == 'release'
shell: bash
run: |
PACKAGE_VERSION=$(uv version --short)
RELEASE_VERSION=${GITHUB_REF#refs/*/}
if [ "$RELEASE_VERSION" != "v$PACKAGE_VERSION" ];
then
echo "Tag '${RELEASE_VERSION}' does not match the package version '${PACKAGE_VERSION}'!";
exit 1;
fi
- name: Build Wheel
run: uv build --out-dir ./dist .
- uses: actions/upload-artifact@v7
with:
name: 'pypi-dist'
path: './dist'
if-no-files-found: 'error'
publish-pypi:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: ["build"]
environment: pypi
permissions:
# This permission is mandatory for Trusted Publishing
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
id-token: write
steps:
- name: Download dist
uses: actions/download-artifact@v8
with:
name: 'pypi-dist'
path: './dist'
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
skip-existing: true
print-hash: true
publish-testpypi:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
needs: ["build"]
environment: testpypi
permissions:
# This permission is mandatory for Trusted Publishing
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
id-token: write
steps:
- name: Download dist
uses: actions/download-artifact@v8
with:
name: 'pypi-dist'
path: './dist'
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
# Test release platform for now
repository-url: https://test.pypi.org/legacy/
skip-existing: false
print-hash: true