-
Notifications
You must be signed in to change notification settings - Fork 6
242 lines (208 loc) · 7.27 KB
/
Copy pathrelease-sdk-pypi.yml
File metadata and controls
242 lines (208 loc) · 7.27 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
name: SDK PyPI Release
# Publishes smbcloud-sdk-auth (sdk/python) to PyPI.
# Triggered by the crates release workflow when wrapped Rust crates change,
# or manually via workflow_dispatch.
#
# Windows arm64 wheels are intentionally not built here. GitHub's hosted
# Windows runners provide x64 Python, and maturin refuses to build an arm64
# wheel when the interpreter reports win-amd64.
on:
workflow_dispatch:
inputs:
tag:
description: "Release tag (e.g. v0.3.35)"
required: true
permissions:
id-token: write
contents: read
env:
CARGO_TERM_COLOR: always
CLI_CLIENT_SECRET: ${{ secrets.CLI_CLIENT_SECRET }}
jobs:
build-wheels:
name: Build PyPI wheels
runs-on: ${{ matrix.build.OS }}
strategy:
fail-fast: false
matrix:
build:
- {
NAME: linux-x64-glibc,
OS: ubuntu-latest,
TARGET: x86_64-unknown-linux-gnu,
MANYLINUX: "2014",
}
- {
NAME: linux-arm64-glibc,
OS: ubuntu-24.04-arm,
TARGET: aarch64-unknown-linux-gnu,
MANYLINUX: "2014",
}
- {
NAME: win32-x64-msvc,
OS: windows-2022,
TARGET: x86_64-pc-windows-msvc,
}
- {
NAME: darwin-x64,
OS: macos-15-intel,
TARGET: x86_64-apple-darwin,
}
- {
NAME: darwin-arm64,
OS: macos-latest,
TARGET: aarch64-apple-darwin,
}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Set the release version
shell: bash
run: |
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
release_version="${GITHUB_REF_NAME#v}"
else
release_version="${{ github.event.inputs.tag }}"
release_version="${release_version#v}"
fi
echo "RELEASE_VERSION=${release_version}" >> "$GITHUB_ENV"
- name: Read Rust toolchain
shell: bash
run: |
rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)"
if [ -z "$rust_toolchain" ]; then
echo "Failed to read Rust toolchain from rust-toolchain.toml" >&2
exit 1
fi
echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV"
- name: Install toolkit
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- name: Install Rust target
shell: bash
run: |
rustup target add ${{ matrix.build.TARGET }} --toolchain ${{ env.RUST_TOOLCHAIN }}
rustup target list --installed
- name: Verify Cargo.toml version matches tag
shell: bash
run: |
CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 \
| jq -r '.packages[] | select(.name == "smbcloud-auth-sdk-py") | .version')
echo "Cargo.toml version : ${CARGO_VERSION}"
echo "Release tag version: ${RELEASE_VERSION}"
if [[ "${CARGO_VERSION}" != "${RELEASE_VERSION}" ]]; then
echo "::error::Version mismatch — bump version in crates/smbcloud-auth-sdk-py/Cargo.toml before releasing."
exit 1
fi
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
key: sdk-pypi-${{ matrix.build.NAME }}
# manylinux containers are CentOS-based and use yum; perl-core is required
# by the openssl-sys vendored build to compile OpenSSL from source.
- name: Clean dist directory
shell: bash
run: rm -rf sdk/python/dist
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.build.TARGET }}
manylinux: ${{ matrix.build.MANYLINUX || 'off' }}
working-directory: sdk/python
args: --release --locked --compatibility pypi --out dist
before-script-linux: yum install -y perl-core
docker-options: -e CLI_CLIENT_SECRET
- name: Upload wheel artifact
uses: actions/upload-artifact@v7
with:
name: wheels-${{ matrix.build.NAME }}
path: sdk/python/dist/*
build-sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Set the release version
shell: bash
run: |
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
release_version="${GITHUB_REF_NAME#v}"
else
release_version="${{ github.event.inputs.tag }}"
release_version="${release_version#v}"
fi
echo "RELEASE_VERSION=${release_version}" >> "$GITHUB_ENV"
- name: Read Rust toolchain
shell: bash
run: |
rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)"
if [ -z "$rust_toolchain" ]; then
echo "Failed to read Rust toolchain from rust-toolchain.toml" >&2
exit 1
fi
echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV"
- name: Install toolkit
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- name: Clean dist directory
run: rm -rf sdk/python/dist
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
working-directory: sdk/python
args: --out dist
- name: Upload sdist artifact
uses: actions/upload-artifact@v7
with:
name: sdist
path: sdk/python/dist/*
publish-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs:
- build-wheels
- build-sdist
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Set the release version
shell: bash
run: |
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
release_version="${GITHUB_REF_NAME#v}"
else
release_version="${{ github.event.inputs.tag }}"
release_version="${release_version#v}"
fi
echo "RELEASE_VERSION=${release_version}" >> "$GITHUB_ENV"
- name: Download distribution artifacts
uses: actions/download-artifact@v7
with:
pattern: "*"
path: dist
merge-multiple: true
- name: Check whether release already exists on PyPI
id: pypi-check
shell: bash
run: |
if curl -fsS "https://pypi.org/pypi/smbcloud-sdk-auth/${RELEASE_VERSION}/json" >/dev/null 2>&1; then
echo "smbcloud-sdk-auth ${RELEASE_VERSION} already exists on PyPI, skipping publish"
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Publish distribution
if: steps.pypi-check.outputs.exists != 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true