Repository navigation
92 lines (86 loc) · 2.58 KB
/
Copy pathrelease.yml
File metadata and controls
92 lines (86 loc) · 2.58 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
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
tag:
required: true
type: string
permissions: {}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout tag
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ inputs.tag || github.ref_name }}
- name: Install uv
uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
- name: Verify tag matches project version
env:
EXPECTED_TAG: ${{ inputs.tag || github.ref_name }}
run: |
version=$(sed -n 's/^version = "\(.*\)"$/\1/p' pyproject.toml)
echo "tag: ${EXPECTED_TAG}, pyproject version: v${version}"
test "v${version}" = "${EXPECTED_TAG}"
- name: Build
run: uv build
- name: Upload dist
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dist
path: dist/
testpypi:
name: Publish to TestPyPI
needs: build
runs-on: ubuntu-latest
environment: testpypi
permissions:
id-token: write
steps:
- name: Download dist
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist/
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
repository-url: https://test.pypi.org/legacy/
github-release:
name: Create GitHub Release
needs: [build, testpypi]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download dist
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist/
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG: ${{ inputs.tag || github.ref_name }}
run: gh release create "$TAG" --verify-tag --generate-notes dist/*
pypi:
name: Publish to PyPI
needs: [build, testpypi]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- name: Download dist
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2