-
-
Notifications
You must be signed in to change notification settings - Fork 25
177 lines (147 loc) · 4.63 KB
/
release.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
name: Release
on: workflow_dispatch
permissions:
contents: write
env:
toolchain: stable
jobs:
details:
name: Release details
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v4
# OS-specific
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('release/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: python -m pip install -r release/requirements.txt
shell: bash
- name: Version details
id: version
run: |
echo "::set-output name=version::`python -m release version`"
echo "::set-output name=tag::`python -m release version --tag`"
shell: bash
release:
name: GitHub release
needs: details
runs-on: ubuntu-latest
steps:
# Necessary to implicitly specify the repo to create the release for.
- uses: actions/checkout@v4
# OS-specific
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('release/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: python -m pip install -r release/requirements.txt
shell: bash
- name: Create release
run: gh release create ${{ needs.details.outputs.tag }} --draft --generate-notes
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
name: Build ${{ matrix.target }}
needs: [details, release]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# https://doc.rust-lang.org/stable/rustc/platform-support.html
# https://github.com/rust-embedded/cross#supported-targets
include:
- target: aarch64-apple-darwin
os: macos-11
use-cross: false
- target: x86_64-apple-darwin
os: macos-latest
use-cross: false
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
use-cross: false
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
use-cross: true
- target: riscv64gc-unknown-linux-gnu
os: ubuntu-latest
use-cross: true
- target: x86_64-unknown-netbsd
os: ubuntu-latest
use-cross: true
steps:
- uses: actions/checkout@v4
# OS-specific
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('release/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: python -m pip install -r release/requirements.txt
shell: bash
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.toolchain }}
target: ${{ matrix.target }}
override: true
profile: minimal
- name: Cargo build
uses: actions-rs/cargo@v1
with:
toolchain: ${{ env.toolchain }}
use-cross: ${{ matrix.use-cross }}
command: build
args: --release --target ${{ matrix.target }}
- name: Create tarball
run: |
TARBALL_PATH=`python -m release tarball --target ${{ matrix.target }}`
du -h $TARBALL_PATH
tar -tvf $TARBALL_PATH
echo "tarball_path=$TARBALL_PATH" >> $GITHUB_ENV
shell: bash
- name: Upload tarball
run: gh release upload ${{ needs.details.outputs.tag }} ${{ env.tarball_path }} --clobber
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
name: Publish to crates.io
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.toolchain }}
override: true
profile: minimal
- name: Publish
run: cargo publish --locked
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}