-
Notifications
You must be signed in to change notification settings - Fork 1.6k
220 lines (196 loc) · 7.52 KB
/
cron-unstable-build.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
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
---
name: Unstable build
on:
workflow_dispatch:
inputs:
branch:
description: The branch to create an unstable release for/from.
type: string
default: master
required: true
# Run nightly build at this time, bit of trial and error but this seems good.
schedule:
- cron: "0 6 * * *" # master build
- cron: "0 12 * * *" # 2.2 build
- cron: "0 18 * * *" # 2.1 build
# We do not want a new unstable build to run whilst we are releasing the current unstable build.
concurrency: unstable-build-release
jobs:
# This job provides this metadata for the other jobs to use.
unstable-build-get-meta:
name: Get metadata to add to build
runs-on: ubuntu-latest
environment: unstable
outputs:
date: ${{ steps.date.outputs.date }}
branch: ${{ steps.branch.outputs.branch }}
permissions:
contents: none
steps:
# For cron builds, i.e. nightly, we provide date and time as extra parameter to distinguish them.
- name: Get current date
id: date
run: echo "date=$(date '+%Y-%m-%d-%H_%M_%S')" >> $GITHUB_OUTPUT
- name: Debug event output
uses: hmarr/debug-action@v2
# Now we need to determine which branch to build
- name: Manual run - get branch
if: github.event_name == 'workflow_dispatch'
run: |
echo "cron_branch=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
shell: bash
- name: master run
if: github.event_name == 'schedule' && github.event.schedule=='0 6 * * *'
run: |
echo "cron_branch=master" >> $GITHUB_ENV
shell: bash
- name: 2.2 run
if: github.event_name == 'schedule' && github.event.schedule=='0 12 * * *'
run: |
echo "cron_branch=2.2" >> $GITHUB_ENV
shell: bash
- name: 2.1 run
if: github.event_name == 'schedule' && github.event.schedule=='0 18 * * *'
run: |
echo "cron_branch=2.1" >> $GITHUB_ENV
shell: bash
- name: Output the branch to use
id: branch
run: |
echo "$cron_branch"
if [[ -z "$cron_branch" ]]; then
echo "Unable to determine branch to use"
exit 1
fi
echo "branch=$cron_branch" >> $GITHUB_OUTPUT
shell: bash
unstable-build-images:
needs: unstable-build-get-meta
uses: ./.github/workflows/call-build-images.yaml
with:
version: ${{ needs.unstable-build-get-meta.outputs.branch }}
ref: ${{ needs.unstable-build-get-meta.outputs.branch }}
registry: ghcr.io
username: ${{ github.actor }}
image: ${{ github.repository }}/unstable
environment: unstable
unstable: ${{ needs.unstable-build-get-meta.outputs.date }}
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
unstable-build-generate-matrix:
name: unstable build matrix
needs:
- unstable-build-get-meta
runs-on: ubuntu-latest
outputs:
build-matrix: ${{ steps.set-matrix.outputs.build-matrix }}
environment: unstable
permissions:
contents: read
steps:
- name: Checkout repository, always latest for action
uses: actions/checkout@v4
# Set up the list of target to build so we can pass the JSON to the reusable job
- uses: ./.github/actions/generate-package-build-matrix
id: set-matrix
with:
ref: ${{ needs.unstable-build-get-meta.outputs.branch }}
unstable-build-packages:
needs:
- unstable-build-get-meta
- unstable-build-generate-matrix
uses: ./.github/workflows/call-build-linux-packages.yaml
with:
version: ${{ needs.unstable-build-get-meta.outputs.branch }}
ref: ${{ needs.unstable-build-get-meta.outputs.branch }}
build_matrix: ${{ needs.unstable-build-generate-matrix.outputs.build-matrix }}
environment: unstable
unstable: ${{ needs.unstable-build-get-meta.outputs.date }}
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
unstable-build-windows-package:
needs:
- unstable-build-get-meta
uses: ./.github/workflows/call-build-windows.yaml
with:
version: ${{ needs.unstable-build-get-meta.outputs.branch }}
ref: ${{ needs.unstable-build-get-meta.outputs.branch }}
environment: unstable
unstable: ${{ needs.unstable-build-get-meta.outputs.date }}
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
unstable-build-macos-package:
needs:
- unstable-build-get-meta
uses: ./.github/workflows/call-build-macos.yaml
with:
version: ${{ needs.unstable-build-get-meta.outputs.branch }}
ref: ${{ needs.unstable-build-get-meta.outputs.branch }}
environment: unstable
unstable: ${{ needs.unstable-build-get-meta.outputs.date }}
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
# We already detain all artefacts as build output so just capture for an unstable release.
# We make all of these on a separate repo to prevent notification spam.
unstable-release:
runs-on: ubuntu-latest
needs:
- unstable-build-get-meta
- unstable-build-images
- unstable-build-packages
- unstable-build-windows-package
- unstable-build-macos-package
environment: unstable
permissions:
contents: read
steps:
# Required to make a release later
- name: Checkout repository
uses: actions/checkout@v4
- name: Download all artefacts
continue-on-error: true
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Single packages tar
run: |
mkdir -p release-upload
# Optional JSON schema so ignore failure
mv -f artifacts/*.json release-upload/ || true
tar -czvf release-upload/packages-unstable-${{ needs.unstable-build-get-meta.outputs.branch }}.tar.gz -C artifacts/ .
shell: bash
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull containers as well (single arch only)
# May not be any/valid so ignore errors
continue-on-error: true
run: |
docker pull $IMAGE
docker save --output container-${{ needs.unstable-build-get-meta.outputs.branch }}.tar $IMAGE
docker pull $IMAGE-debug
docker save --output container-${{ needs.unstable-build-get-meta.outputs.branch }}-debug.tar $IMAGE-debug
shell: bash
working-directory: release-upload
env:
IMAGE: ghcr.io/${{ github.repository }}/unstable:${{ needs.unstable-build-get-meta.outputs.branch }}
- name: Display structure of files to upload
run: ls -R
working-directory: release-upload
shell: bash
- name: Remove any existing release
continue-on-error: true
run: gh release delete unstable-${{ needs.unstable-build-get-meta.outputs.branch }} --yes --repo ${{ secrets.RELEASE_REPO }}
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
shell: bash
- name: Create Release
# Do not fail the job here
continue-on-error: true
run: gh release create unstable-${{ needs.unstable-build-get-meta.outputs.branch }} release-upload/*.* --repo ${{ secrets.RELEASE_REPO }} --generate-notes --prerelease --target ${{ needs.unstable-build-get-meta.outputs.branch }} --title "Nightly unstable ${{ needs.unstable-build-get-meta.outputs.branch }} build"
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
shell: bash