-
Notifications
You must be signed in to change notification settings - Fork 88
150 lines (132 loc) · 4.52 KB
/
build-publish-python-packages.yaml
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
# This is a GitHub workflow defining a set of jobs with a set of steps.
# ref: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
#
name: Build and publish Python packages
# Always test build of packages, but only publish to PyPI on pushed tag
on:
pull_request:
paths:
- "dask-gateway/**"
- "dask-gateway-server/**"
- ".github/workflows/build-publish-python-packages.yaml"
push:
paths:
- "dask-gateway/**"
- "dask-gateway-server/**"
- ".github/workflows/build-publish-python-packages.yaml"
branches: ["main"]
tags: ["**"]
workflow_dispatch:
jobs:
# Builds sdist (.tar.gz) and wheels (.whl) for the Python packages.
#
# - dask-gateway's wheel is platform and CPU architecture independent
# - dask-gateway-server's wheel is platform dependent (linux/mac) and CPU
# architecture dependent (amd64/arm64) because of the compiled Golang
# binary.
#
# Golang cross platform (GOOS env) and cross architecture (GOARCH env)
# compilation is used to produce different artifacts independent of the job's
# platform and CPU architecture.
#
build:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
# GOOS and GOARCH options available:
# https://go.dev/doc/install/source#environment
#
include:
- package: dask-gateway
upload_sdist: true
- package: dask-gateway-server
GOOS: linux
GOARCH: amd64
upload_sdist: true
- package: dask-gateway-server
GOOS: linux
GOARCH: arm64
upload_sdist: false
- package: dask-gateway-server
GOOS: darwin
GOARCH: amd64
upload_sdist: false
- package: dask-gateway-server
GOOS: darwin
GOARCH: arm64
upload_sdist: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build package
run: |
pip install build
pip list
- name: Build sdist and wheel
env:
GOOS: "${{ matrix.GOOS }}"
GOARCH: "${{ matrix.GOARCH }}"
working-directory: ${{ matrix.package }}
run: |
python -m build --sdist --wheel .
ls -alh ./dist
sha256sum ./dist/* | tee SHA256SUMS
- name: Upload sdist artifact
if: matrix.upload_sdist
uses: actions/upload-artifact@v4
with:
name: ${{ format('{0}_{1}', matrix.package, 'sdist') }}
path: ${{ matrix.package }}/dist/*.tar.gz
if-no-files-found: error
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: ${{ format('{0}_{1}-{2}-{3}', matrix.package, 'wheel', matrix.GOOS, matrix.GOARCH) }}
path: ${{ matrix.package }}/dist/*.whl
if-no-files-found: error
publish:
needs: build
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
package:
- dask-gateway
- dask-gateway-server
steps:
- name: Download built source distributions and wheels
uses: actions/download-artifact@v4
with:
pattern: ${{ matrix.package }}_*
path: ${{ matrix.package }}/dist
merge-multiple: true
- name: Inspect built source distributions and wheels
working-directory: ${{ matrix.package }}
run: |
ls -alh ./dist
sha256sum ./dist/* | tee SHA256SUMS
# Because we have two separate deploy tokens for the dask-gateway and
# dask-gateway-server packages, we define two separate steps to pick out
# the relevant secret depending on matrix.package.
- name: Publish to PyPI (dask-gateway)
uses: pypa/gh-action-pypi-publish@release/v1
if: >-
startsWith(github.ref, 'refs/tags/')
&& matrix.package == 'dask-gateway'
with:
user: __token__
password: "${{ secrets.pypi_token__dask_gateway }}"
packages_dir: ${{ matrix.package }}/dist
- name: Publish to PyPI (dask-gateway-server)
uses: pypa/gh-action-pypi-publish@release/v1
if: >-
startsWith(github.ref, 'refs/tags/')
&& matrix.package == 'dask-gateway-server'
with:
user: __token__
password: "${{ secrets.pypi_token__dask_gateway_server }}"
packages_dir: ${{ matrix.package }}/dist