-
-
Notifications
You must be signed in to change notification settings - Fork 185
110 lines (110 loc) · 4.01 KB
/
Copy pathpublish.yaml
File metadata and controls
110 lines (110 loc) · 4.01 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Publish
on:
push:
tags: ['*']
# When a new version of Python is released, the workflow can be run manually to
# publish new wheels for the existing tag.
workflow_dispatch:
inputs:
tag:
description: git tag to check out and upload to
required: true
python:
description: Python version, like "cp311"
required: true
jobs:
sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ inputs.tag }}
- uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0
with:
enable-cache: true
prune-cache: false
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version-file: pyproject.toml
- run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
- run: uv build --sdist
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: build-sdist
path: ./dist
# The sdist is not needed on new Python version builds. However, this job must
# be present in the run for the hash job, so only the upload is skipped.
if: github.event_name == 'push'
wheels:
name: wheels / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0
with:
enable-cache: true
prune-cache: false
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
with:
platforms: arm64,riscv64,ppc64le
- run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
- uses: pypa/cibuildwheel@7c619efba910c04005a835b110b057fc28fd6e93 # v3.2.0
env:
# For workflow_dispatch, only build the new Python version.
CIBW_BUILD: ${{ inputs.python && format('{0}-*', inputs.python) || null }}
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: build-wheels-${{ matrix.os }}
path: ./wheelhouse
create-release:
needs: [sdist, wheels]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
path: dist
pattern: build-*
merge-multiple: true
# When building a new tag, create a new draft release.
- if: github.event_name == 'push'
name: create release
run: >
gh release create --draft --repo ${{ github.repository }}
${{ inputs.tag || github.ref_name }} dist/*
env:
GH_TOKEN: ${{ github.token }}
# When running manually, update the existing release with more files.
- if: github.event_name == 'workflow_dispatch'
name: update release
run: >
gh release upload --repo ${{ github.repository }}
${{ inputs.tag || github.ref_name }} dist/*
env:
GH_TOKEN: ${{ github.token }}
publish-pypi:
needs: [sdist, wheels]
# Wait for approval before attempting to upload to PyPI. This allows reviewing the
# files in the draft release.
environment:
name: publish
url: https://pypi.org/project/MarkupSafe/${{ github.ref_name }}
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
path: dist
pattern: build-*
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
skip-existing: true