-
-
Notifications
You must be signed in to change notification settings - Fork 8
233 lines (205 loc) · 7.7 KB
/
update.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: Update
on:
workflow_dispatch:
inputs:
sdk:
description: "Version of Playdate SDK"
default: latest
type: string
required: true
source:
description: "Source ref used to build bindings. Uses `github.ref`` by default."
required: false
sha:
description: "Source SHA used to build bindings. Uses `github.sha`` by default."
required: false
push:
branches: [main, master]
schedule:
- cron: "0 0 * * 1"
env:
CARGO_INCREMENTAL: 1
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
CARGO_TERM_COLOR: always
CARGO_TERM_PROGRESS_WHEN: never
# logging:
CARGO_PLAYDATE_LOG: trace
# allow modify source for bindings generator:
PD_BUILD_PREBUILT: 1
permissions:
contents: write
jobs:
new-branch:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Input
run: |
echo "ref: ${{ github.ref }}, ${{ github.ref_name }}"
echo "inputs: ${{ github.event.inputs.source }}, ${{ github.event.inputs.sha }}"
echo "default branch: ${{ github.event.repository.default_branch }}"
echo "Will checkout ${{ github.event.inputs.source || github.ref }}"
- name: Checkout Master
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.source || github.ref || github.event.repository.default_branch }}
- name: Base branch name
id: base
if: ${{ github.ref_type == 'branch' }}
run: echo "value=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
- name: Work branch name
id: work_branch
run: |
NAME_SUFFIX="${{ (github.ref_type == 'branch' && github.ref_name) || (github.event.inputs.sha || github.sha) }}"
echo "value=api/sys/pre-build/$NAME_SUFFIX" >> "$GITHUB_OUTPUT"
echo "suffix: '$NAME_SUFFIX'"
- name: Create Branch
id: branch
uses: peterjgrainger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: refs/heads/${{ steps.work_branch.outputs.value }}
sha: ${{ github.event.inputs.sha || github.sha }}
- name: Created
run: 'echo "Created: ${{ steps.branch.outputs.created }}"'
# if not created => rebase to master
- name: ReSync Branch
if: ${{ steps.branch.outputs.created == 'false' }}
uses: Joao208/[email protected]
with:
PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: ${{ steps.work_branch.outputs.value }}
DEFAULT_BRANCH: ${{ github.event.inputs.source || steps.base.outputs.value || github.event.repository.default_branch }}
outputs:
working: ${{ steps.work_branch.outputs.value }}
base: ${{ github.event.inputs.source || steps.base.outputs.value || github.event.repository.default_branch }}
pre-gen:
name: Gen (${{ matrix.os }}, ${{ matrix.features.name }})
defaults:
run:
shell: bash
needs: new-branch
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os:
- macos-latest
- ubuntu-latest
# - windows-latest
sdk:
- ${{ github.event.inputs.sdk || 'latest' }}
features:
- v: >-
bindings-documentation
bindings-derive-debug
name: default
- v: >-
bindings-documentation
bindings-derive-default
bindings-derive-eq
bindings-derive-copy
bindings-derive-debug
bindings-derive-hash
bindings-derive-ord
bindings-derive-partialeq
bindings-derive-partialord
name: full
steps:
- name: Inputs
run: |
echo "I: SDK version: ${{ github.event.inputs.sdk }}"
echo "M: SDK version: ${{ matrix.sdk }}"
echo "Base branch: ${{ needs.new-branch.outputs.base }}"
echo "Working branch: ${{ needs.new-branch.outputs.working }}"
- uses: actions/checkout@v4
with:
ref: ${{ needs.new-branch.outputs.working }}
- name: Cache
uses: Swatinem/[email protected]
- name: Install Playdate SDK ${{ matrix.sdk }}
id: sdk
uses: pd-rs/get-playdate-sdk@main
with:
version: ${{ matrix.sdk }}
- name: SDK ${{ steps.sdk.outputs.version }} installed
run: which pdc && pdc --version
# TODO: check & stop if there's no changes or mb. save SDK version cached
- name: Host
run: |
cargo build -p=playdate-sys --features="${{ matrix.features.v }}" -vv
cargo build -p=playdate-sys --features="${{ matrix.features.v }}" --release
- name: Device
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cargo build -p=playdate-sys --features="${{ matrix.features.v }}" --target=thumbv7em-none-eabihf
cargo build -p=playdate-sys --features="${{ matrix.features.v }}" --target=thumbv7em-none-eabihf --release
- name: Format
run: rustfmt api/sys/gen/*.rs
- name: Test (host)
# env: # uncomment when all bindings for min-supported-SDK will be there
# IGNORE_EXISTING_PLAYDATE_SDK: 1
# PLAYDATE_USE_PREBUILT_VERSION: ${{ steps.sdk.outputs.version }}
run: |
cargo test -p=playdate-sys --features="${{ matrix.features.v }}"
cargo test -p=playdate-sys --features="${{ matrix.features.v }}" --release
- name: Test (device)
if: ${{ matrix.os == 'ubuntu-latest' }}
# env: # uncomment when all bindings for min-supported-SDK will be there
# IGNORE_EXISTING_PLAYDATE_SDK: 1
# PLAYDATE_USE_PREBUILT_VERSION: ${{ steps.sdk.outputs.version }}
run: |
cargo build -p=playdate-sys --features="${{ matrix.features.v }}" --target=thumbv7em-none-eabihf -Zbuild-std=core,alloc
cargo build -p=playdate-sys --features="${{ matrix.features.v }}" --target=thumbv7em-none-eabihf -Zbuild-std=core,alloc --release
- name: Commit
id: commit
uses: EndBug/add-and-commit@v9
with:
add: ./api/sys/gen/*.rs
author_name: Alex Koz
author_email: [email protected]
committer_name: Update Workflow
message: Automated build pre-built bindings
pull: "--rebase --autostash"
push: true
- name: Committed
run: |
echo "Committed: ${{ steps.commit.outputs.committed }}"
echo "Pushed: ${{ steps.commit.outputs.pushed }}"
echo "SHA: ${{ steps.commit.outputs.commit_sha }}"
pr:
name: Make PR
needs: [pre-gen, new-branch]
runs-on: ubuntu-latest
defaults:
run:
shell: bash
permissions:
pull-requests: write
contents: write
steps:
- name: Inputs
run: |
echo "Base branch: ${{ needs.new-branch.outputs.base }}"
echo "Working branch: ${{ needs.new-branch.outputs.working }}"
- uses: actions/checkout@v4
with:
ref: ${{ needs.new-branch.outputs.working }}
- name: Create PR
uses: TreTuna/[email protected]
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
FROM_BRANCH: refs/heads/${{ needs.new-branch.outputs.working }}
TO_BRANCH: ${{ needs.new-branch.outputs.base || github.event.repository.default_branch }}
PULL_REQUEST_TITLE: Update pre-built bindings
PULL_REQUEST_BODY: |
Pre-built bindings just updated.
Don't forget to bump version and make release.
PULL_REQUEST_IS_DRAFT: false
CONTENT_COMPARISON: true
REVIEWERS: '["boozook"]'
LABELS: '["pre-built bindings"]'