-
Notifications
You must be signed in to change notification settings - Fork 8
193 lines (176 loc) · 5.73 KB
/
dist.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
name: Dist build
on:
push:
paths:
- pyproject.toml
- poetry.lock
- '**.py'
- 'scripts/**'
tags:
- '*'
pull_request:
paths:
- pyproject.toml
- poetry.lock
- '**.py'
- 'scripts/**'
merge_group:
types: [checks_requested]
jobs:
# https://stackoverflow.com/questions/65384420/how-do-i-make-a-github-action-matrix-element-conditional
prepare_matrix_linux:
name: "Prepare the job's matrix (Linux)"
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.gen_matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- name: Generate the matrix
id: gen_matrix
run: scripts/gen_matrix.py linux
env:
RUYI_PR_TITLE: ${{ github.event.pull_request.title }}
prepare_matrix_windows:
name: "Prepare the job's matrix (Windows)"
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.gen_matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- name: Generate the matrix
id: gen_matrix
run: scripts/gen_matrix.py windows
env:
RUYI_PR_TITLE: ${{ github.event.pull_request.title }}
dist:
needs:
- prepare_matrix_linux
strategy:
# arch: str
# build_output_name: str
# is_windows: bool
# job_name: str
# runs_on: RunsOn
# skip: bool
# upload_artifact_name: str
matrix: ${{ fromJson(needs.prepare_matrix_linux.outputs.matrix) }}
name: ${{ matrix.job_name }}
runs-on: ${{ matrix.runs_on }}
outputs:
run_id: ${{ github.run_id }}
release_mirror_url: ${{ steps.run_dist.outputs.release_mirror_url }}
container:
image: ghcr.io/ruyisdk/ruyi-python-dist:20240827
options: --user root # https://github.com/actions/checkout/issues/1014
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
volumes:
- ${{ github.workspace }}:/home/b/ruyi
- tmp-build:/build
- tmp-poetry-cache:/poetry-cache
- tmp-ccache:/ccache
- tmp-ruyi-dist-cache:/ruyi-dist-cache
env:
# this has to mirror the setup in scripts/dist.sh
CCACHE_DIR: /ccache
POETRY_CACHE_DIR: /poetry-cache
RUYI_DIST_BUILD_DIR: /build
RUYI_DIST_CACHE_DIR: /ruyi-dist-cache
RUYI_DIST_INNER_CONTAINERIZED: x
steps:
- uses: actions/checkout@v4
- name: Cache deps and Nuitka output
if: success() && !matrix.skip
uses: actions/cache@v4
with:
key: ${{ runner.os }}-tgt-${{ matrix.arch }}-r4
path: |
/ccache
/poetry-cache
/ruyi-dist-cache
- name: Run dist
if: success() && !matrix.skip
id: run_dist
run: RUYI_DIST_INNER=x /home/b/ruyi/scripts/dist.sh ${{ matrix.arch }}
- name: Upload artifact
if: success() && !matrix.skip
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.upload_artifact_name }}
path: /build/${{ matrix.build_output_name }}
compression-level: 0 # the Nuitka onefile payload is already compressed
dist-windows:
needs:
- prepare_matrix_windows
strategy:
# arch: str
# build_output_name: str
# is_windows: bool
# job_name: str
# runs_on: RunsOn
# skip: bool
# upload_artifact_name: str
matrix: ${{ fromJson(needs.prepare_matrix_windows.outputs.matrix) }}
name: ${{ matrix.job_name }}
runs-on: ${{ matrix.runs_on }}
steps:
- uses: actions/checkout@v4
- name: Install Poetry
if: success() && !matrix.skip
run: pipx install poetry
- uses: actions/setup-python@v5
if: success() && !matrix.skip
with:
# don't let the ">=" directive bump the Python version without letting
# us know
# python-version-file: pyproject.toml
python-version: '3.12'
cache: poetry
- name: Cache/restore Nuitka clcache contents
if: success() && !matrix.skip
uses: actions/cache@v4
with:
key: ${{ runner.os }}-tgt-${{ matrix.arch }}
path: |
/clcache
- name: Install deps
if: success() && !matrix.skip
run: poetry install && mkdir /build
- name: Run dist
if: success() && !matrix.skip
run: "scripts\\dist.ps1"
- name: Upload artifact
if: success() && !matrix.skip
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.upload_artifact_name }}
path: /build/${{ matrix.build_output_name }}
compression-level: 0 # the Nuitka onefile payload is already compressed
release:
name: Make a GitHub Release
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') }}
needs:
- dist
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version-file: 'pyproject.toml'
- name: Download artifacts for release
uses: actions/download-artifact@v4
with:
run-id: ${{ needs.dist.outputs.run_id }}
path: tmp/release
- name: Organize release artifacts
run: scripts/organize-release-artifacts.py tmp/release
- name: Render the release notes header
run: sed "s!@RELEASE_MIRROR_URL@!${{ needs.dist.outputs.release_mirror_url }}!g" < resources/release-notes-header-template.md > tmp/release-notes-header.md
- name: Make the release
uses: softprops/action-gh-release@v2
with:
body_path: tmp/release-notes-header.md
files: tmp/release/ruyi-*
generate_release_notes: true
prerelease: ${{ contains(needs.dist.outputs.release_mirror_url, 'testing') }}