-
Notifications
You must be signed in to change notification settings - Fork 38
155 lines (138 loc) · 5.26 KB
/
package-server.yml
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
name: package-server
on:
workflow_call:
inputs:
version:
description: The version to use
type: string
required: true
# PS: If you trigger manually the packaging, take into account that it will use the workflow as defined in the main branch not in the target branch.
workflow_dispatch:
inputs:
version:
description: The version to use (if not provided will generated one from the code space version)
type: string
required: false
pull_request:
paths:
- .github/workflows/package-server.yml
- server/packaging
- server/build.py
- server/pyproject.toml
# We set `concurrency` to prevent having this workflow being run on code that is not up-to-date on a PR (a user make multiple push in a quick manner).
# But on the main branch, we don't want that behavior.
# Having the workflow run on each merge commit is something we would like, that could help us where a regression was made and missed by previous checks.
#
# For that we use `head_ref` that is only defined on `pull-request` and fallback to `run_id` (this is a counter, so it's value is unique between workflow call).
concurrency:
group: package-server-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
node-version: 18.12.0
poetry-version: 1.5.1
permissions:
contents: read
jobs:
package-wheel:
strategy:
fail-fast: false
matrix:
include:
- name: 🐧 Linux
platform: linux
os: ubuntu-22.04
- name: 🍎 macOS
platform: macos
os: macos-12
- name: 🏁 Windows
platform: windows
os: windows-2022
name: "${{ matrix.name }}: 📦 Packaging (build Wheel)"
runs-on: ${{ matrix.os }}
outputs:
wheel-version: ${{ steps.version.outputs.full }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin v4.1.1
timeout-minutes: 5
- uses: ./.github/actions/setup-python-poetry
with:
poetry-version: ${{ env.poetry-version }}
project-path: ./server
timeout-minutes: 10
- name: Get wheel version
id: version
shell: bash
run: |
set -eux
function parse_version {
PYTHONPATH=. python3 misc/releaser.py version "$@"
}
if [ -n "${{ inputs.version }}" ]; then
parse_version "${{ inputs.version }}" | tee -a $GITHUB_OUTPUT
else
case "${{ github.event_name }}" in
workflow_call)
echo "The top workflow should have provided the version to use"
exit 2
;;
workflow_dispatch)
# No version provided, fallback to the version in the repository
parse_version --uniq-dev | tee -a $GITHUB_OUTPUT
;;
pull_request)
parse_version --uniq-dev | tee -a $GITHUB_OUTPUT
;;
*)
echo 'Unsupported event type ${{ github.event_name }}' >&2
exit 1
;;
esac
fi
- name: Set parsec version ${{ steps.version.outputs.full }}
run: python3 misc/version_updater.py --tool parsec --version ${{ steps.version.outputs.full }}
- name: Build wheel
uses: pypa/cibuildwheel@fff9ec32ed25a9c576750c91e06b410ed0c15db7 # pin v2.16.2
with:
package-dir: server
output-dir: dist
timeout-minutes: 50
- name: Set file for wheel version
run: echo ${{ steps.version.outputs.full }} > dist/version
- name: Hack the wheel macos version
if: startsWith(matrix.os, 'macos-')
shell: bash
run: |
set -eux
# Old wheel name
OLD_WHEEL_NAME=$(basename dist/parsec_cloud-*.whl)
# Unzip the wheel
mkdir temp
cd temp
unzip ../dist/$OLD_WHEEL_NAME
# Get platform new wheel name
python -m pip install wheel
PLATFORM=$(python -c "from wheel.bdist_wheel import get_platform; print(get_platform('.'))")
NEW_WHEEL_NAME=$(basename ../dist/parsec_cloud-*.whl | sed "s/macosx_.*_x86_64/$PLATFORM/")
# Update archive and zip back
sed -i "" "s/macosx_.*_x86_64/$PLATFORM/" parsec_cloud-*.dist-info/WHEEL
zip -r $NEW_WHEEL_NAME *
cd ..
# Replace old wheel with the new one
mv temp/$NEW_WHEEL_NAME dist/
rm dist/$OLD_WHEEL_NAME
rm -rf temp
- name: Generate requirements & constraints infos
run: python server/packaging/wheel/wheel_it.py ./server --output dist --skip-wheel
# Install syft
- uses: taiki-e/install-action@285bd10d1ce81bd96d8e0c372615e57cf204e95a # pin v2.21.3
with:
tool: [email protected]
- name: Generate SBOM
run: syft packages --config=.syft.yaml --output=spdx-json=dist/Parsec-SBOM-Wheel-${{ matrix.platform }}.spdx.json .
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # pin v3.1.3
with:
name: ${{ runner.os }}-${{ runner.arch }}-wheel
path: |
dist/
if-no-files-found: error
timeout-minutes: 5