-
Notifications
You must be signed in to change notification settings - Fork 30
126 lines (105 loc) · 3.72 KB
/
release-pypi.yml
File metadata and controls
126 lines (105 loc) · 3.72 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Build wheels and publish to PyPI
#
# See these docs for more about trusted publishing
# https://docs.pypi.org/trusted-publishers/
name: Release PyPI
on:
workflow_dispatch:
inputs:
version:
description: Binary version. No leading `v`.
required: true
type: string
dry_run:
description: Build wheels, but skip publishing.
required: true
default: false
type: boolean
jobs:
build:
name: "Build Wheels (${{ matrix.this.target }})"
runs-on: ${{ matrix.this.runner }}
timeout-minutes: 30
defaults:
run:
shell: bash
strategy:
matrix:
this:
# Platform tags are based on https://pypi.org/project/ruff/#files
# - macosx_10_12 matches Rust's default support
# - macosx_11_0 is the minimum for ARM Mac
# - manylinux_2_28 is what we build the binaries in for Linux
- target: x86_64-apple-darwin
platform_tag: macosx_10_12_x86_64
runner: macos-15-intel
- target: aarch64-apple-darwin
platform_tag: macosx_11_0_arm64
runner: macos-14
- target: x86_64-unknown-linux-gnu
platform_tag: manylinux_2_28_x86_64
runner: ubuntu-24.04
- target: aarch64-unknown-linux-gnu
platform_tag: manylinux_2_28_aarch64
runner: ubuntu-24.04-arm
- target: x86_64-pc-windows-msvc
platform_tag: win_amd64
runner: windows-2022
- target: aarch64-pc-windows-msvc
platform_tag: win_arm64
runner: windows-11-arm
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
- name: "Download binary"
run: |
TARGET=${{ matrix.this.target }}
# uv knows to copy `scripts/` to `.data/scripts/` in the wheel
mkdir -p python/scripts
if [[ "$TARGET" == *windows* ]]; then
ARCHIVE_NAME=air-$TARGET
ARCHIVE_FILE=$ARCHIVE_NAME.zip
curl -LsSfO https://github.com/posit-dev/air/releases/download/${{ inputs.version }}/$ARCHIVE_FILE
unzip $ARCHIVE_FILE
mv air.exe python/scripts/air.exe
else
ARCHIVE_NAME=air-$TARGET
ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz
curl -LsSfO https://github.com/posit-dev/air/releases/download/${{ inputs.version }}/$ARCHIVE_FILE
tar -xvzf $ARCHIVE_FILE
mv $ARCHIVE_NAME/air python/scripts/air
chmod +x python/scripts/air
fi
- name: "Build wheel"
# Builds the wheel as generic `air_formatter-{air-version}-py3-none-any.whl`
run: uv build --wheel --out-dir wheel/ python/
- name: "Retag wheel"
# Retag the wheel with known platform-tag, becoming `air_formatter-{air-version}-py3-none-{platform-tag}.whl`
run: uvx wheel tags --platform-tag ${{ matrix.this.platform_tag }} --remove wheel/*.whl
- name: "Test wheel"
run: uv tool run --from wheel/*.whl air --help
- name: "Upload wheel"
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.this.target }}
path: wheel/*.whl
publish:
name: "Publish to PyPI"
runs-on: ubuntu-latest
needs: build
# For the restricted GitHub Environment
environment: pypi
permissions:
# For PyPI's trusted publishing
id-token: write
steps:
- uses: astral-sh/setup-uv@v7
- name: "Download wheels"
uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: wheels
merge-multiple: true
- name: "Publish"
if: ${{ inputs.dry_run == false }}
run: uv publish wheels/*