-
Notifications
You must be signed in to change notification settings - Fork 83
148 lines (131 loc) · 4.7 KB
/
pypi.yml
File metadata and controls
148 lines (131 loc) · 4.7 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
name: pypi-wheels
on:
workflow_call:
inputs:
tag:
description: "Release tag to package (e.g., v1.2.3)"
required: true
type: string
workflow_dispatch:
inputs:
tag:
description: "Release tag to package (e.g., v1.2.3). Leave blank to use the latest release."
required: false
type: string
permissions: {}
jobs:
build-wheels:
name: Build PyPI wheels
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Determine version/tag
id: version
shell: bash
env:
INPUT_TAG: ${{ inputs.tag || github.event.inputs.tag || '' }}
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
if [[ -z "${INPUT_TAG}" ]]; then
set +e
TAG="$(gh release view --repo "${GITHUB_REPOSITORY}" --json tagName -q .tagName)"
gh_status=$?
set -e
if [[ ${gh_status} -ne 0 || -z "${TAG}" ]]; then
echo "No tag provided and failed to determine latest release tag (gh release view exit status: ${gh_status})" >&2
exit 1
fi
else
TAG="${INPUT_TAG}"
fi
if [[ ! "${TAG}" =~ ^v[0-9A-Za-z._+-]+$ ]]; then
echo "Invalid tag format: ${TAG}" >&2
exit 1
fi
VERSION="${TAG#v}"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
ref: ${{ steps.version.outputs.tag }}
- name: Download release assets
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p release-assets
gh release download "${{ steps.version.outputs.tag }}" \
-p "kingfisher-*.tgz" \
-p "kingfisher-*.zip" \
-D release-assets
- name: Extract binaries
shell: bash
run: |
set -euo pipefail
mkdir -p extracted
for archive in release-assets/*; do
name=$(basename "$archive")
dir="extracted/${name%.*}"
mkdir -p "$dir"
case "$archive" in
*.tgz)
tar -xzf "$archive" -C "$dir"
;;
*.zip)
unzip -q "$archive" -d "$dir"
;;
*)
echo "Unknown archive: $archive" >&2
exit 1
;;
esac
done
mkdir -p extracted/bin
for bin in $(find extracted -type f \( -name "kingfisher" -o -name "kingfisher.exe" \)); do
chmod +x "$bin" || true
done
- name: Install build tooling
run: "python -m pip install --upgrade --only-binary :all: --require-hashes -r .github/requirements/pypi-build.txt"
- name: Build wheels
shell: bash
run: |
set -euo pipefail
version="${{ steps.version.outputs.version }}"
linux_x64=$(find extracted -type f -name "kingfisher" | grep -m1 "linux-x64")
linux_arm64=$(find extracted -type f -name "kingfisher" | grep -m1 "linux-arm64")
mac_x64=$(find extracted -type f -name "kingfisher" | grep -m1 "darwin-x64")
mac_arm64=$(find extracted -type f -name "kingfisher" | grep -m1 "darwin-arm64")
win_x64=$(find extracted -type f -name "kingfisher.exe" | grep -m1 "windows-x64")
win_arm64=$(find extracted -type f -name "kingfisher.exe" | grep -m1 "windows-arm64")
scripts/build-pypi-wheel.sh \
--binary "$linux_x64" \
--version "$version" \
--plat-name musllinux_1_2_x86_64
scripts/build-pypi-wheel.sh \
--binary "$linux_arm64" \
--version "$version" \
--plat-name musllinux_1_2_aarch64
scripts/build-pypi-wheel.sh \
--binary "$mac_x64" \
--version "$version" \
--plat-name macosx_10_9_x86_64
scripts/build-pypi-wheel.sh \
--binary "$mac_arm64" \
--version "$version" \
--plat-name macosx_11_0_arm64
scripts/build-pypi-wheel.sh \
--binary "$win_x64" \
--version "$version" \
--plat-name win_amd64
scripts/build-pypi-wheel.sh \
--binary "$win_arm64" \
--version "$version" \
--plat-name win_arm64
- name: Publish to PyPI (Trusted Publishing)
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
with:
packages-dir: dist-pypi
verbose: true
attestations: false