-
Notifications
You must be signed in to change notification settings - Fork 3
210 lines (181 loc) · 6.52 KB
/
releases.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
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
---
name: Release
# Do this on every tagged commit
on:
push:
tags:
- "v*"
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
jobs:
build-release:
name: Build release for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-22.04
- macos-13
- macos-14
- ubuntu-22.04-arm
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: (macos) install dependencies
if: ${{ startsWith(matrix.os, 'macos') }}
run: |
brew install automake autoconf pkg-config hdf5@1.10
- name: (ubuntu) install dependencies
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt -y update
sudo apt -y install libhdf5-dev gcc pkg-config python3 curl wget git jq
- name: Install Rust, stable minimal toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- name: Add Python 3.8
if: ${{ matrix.os != 'macos-14' }}
uses: actions/setup-python@v5
continue-on-error: true
with:
python-version: "3.8"
- name: Add Python 3.9
if: ${{ matrix.os != 'macos-14' }}
uses: actions/setup-python@v5
continue-on-error: true
with:
python-version: "3.9"
- name: Add Python 3.10
uses: actions/setup-python@v5
continue-on-error: true
with:
python-version: "3.10"
- name: Add Python 3.11
uses: actions/setup-python@v5
continue-on-error: true
with:
python-version: "3.11"
- name: Add Python 3.12
uses: actions/setup-python@v5
continue-on-error: true
with:
python-version: "3.12"
- name: install maturin
run: |
python -m pip install --upgrade pip
python -m pip install maturin
- name: build mwa_hyperbeam
run: |
# Copy the release readme to the project root so it can neatly be put in the
# release tarballs.
cp .github/workflows/releases-readme.md README.md
# Because we've compiled HDF5 and ERFA into hyperbeam products, we
# legally must distribute their licenses with the products.
curl https://raw.githubusercontent.com/HDFGroup/hdf5/develop/COPYING -o COPYING-hdf5
curl https://raw.githubusercontent.com/liberfa/erfa/master/LICENSE -o LICENSE-erfa
export TAG="$(git describe --tags)"
export VER="v$(grep version Cargo.toml -m1 | cut -d' ' -f3 | tr -d '"')"
export REF="${{ github.ref_name }}"
echo "TAG=$TAG, VER=$VER, REF=$REF"
# determine which target cpus for rustc to build for from machine type
export ARCH="$(uname -m)"
case $ARCH in
x86_64)
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
export TARGETS="x86-64 x86-64-v2 x86-64-v3"
else
export TARGETS="x86-64"
fi
;;
arm64) export TARGETS="apple-m1" ;;
aarch64) export TARGETS="aarch64" ;;
*) echo "unknown arch (uname -m) $ARCH"; exit 1 ;;
esac
# determine which library file extensions to include in archive from kernel
export KERNEL="$(uname -s | tr '[:upper:]' '[:lower:]')"
case $KERNEL in
darwin*) export LIB_GLOB="{a,dylib}" ;;
linux*) export LIB_GLOB="{a,so}" ;;
*) echo "unknown kernel (uname -s) $KERNEL"; exit 1 ;;
esac
# determine which python versions are available
export PYTHONS=$(maturin list-python 2>&1 | grep CPython | cut -d' ' -f 4 | tr $'\n' ' ')
for TARGET in $TARGETS; do
echo "building target $TARGET"
export RUSTFLAGS="-C target-cpu=$TARGET"
# Build python first
maturin build --release --features python,all-static --strip -i $PYTHONS
# Build C objects
cargo build --release --features all-static
# Create new release asset tarballs
eval mv target/wheels/*.whl target/release/libmwa_hyperbeam.${LIB_GLOB} include/mwa_hyperbeam.h .
eval tar -acvf mwa_hyperbeam-${TAG}-${KERNEL}-${TARGET}.tar.gz \
LICENSE COPYING-hdf5 LICENSE-erfa README.md CHANGELOG.md \
libmwa_hyperbeam.${LIB_GLOB} mwa_hyperbeam.h
eval tar -acvf mwa_hyperbeam-${TAG}-${KERNEL}-${TARGET}-python.tar.gz \
LICENSE COPYING-hdf5 LICENSE-erfa README.md CHANGELOG.md \
./*.whl
done
- name: Upload tarball
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}.tar.gz
path: "*.tar.gz"
if-no-files-found: error
create-rust-release:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: [build-release]
environment: CI
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable, minimal toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- name: Build release on latest stable rust
run: |
sudo apt -y update
sudo apt -y install libhdf5-dev pkg-config
cargo build --release --features hdf5-static
- uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
args: --no-verify
create-github-and-pypi-release:
name: Create a new github and pypi release
runs-on: ubuntu-latest
needs: [create-rust-release]
environment: CI
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
shell: bash
run: |
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="${GITHUB_REPOSITORY#*/} ${tag#v}" \
--generate-notes *.tar.gz
- name: Place all python wheels into dir for publish to pypi
run: |
mkdir for_pypi
tar xvf *-darwin-apple-m1-python.tar.gz -C for_pypi/ --wildcards "*.whl"
tar xvf *-darwin-x86-64-python.tar.gz -C for_pypi/ --wildcards "*.whl"
tar xvf *-linux-x86-64-python.tar.gz -C for_pypi/ --wildcards "*.whl"
tar xvf *-linux-aarch64-python.tar.gz -C for_pypi/ --wildcards "*.whl"
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: for_pypi/
password: ${{ secrets.PYPI_API_TOKEN }}