-
Notifications
You must be signed in to change notification settings - Fork 590
290 lines (241 loc) · 10.7 KB
/
nightly.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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#
# Logisim-evolution nightly builder
# https://github.com/logisim-evolution/logisim-evolution
#
# Cron driven Github Action builder, intended to create nightly builds
# from Logisim-evolution's "develop" branch. It assumes to be invoked
# daily (once per 24 hrs) and skips building if there was no repo activity
# during last 24 hours.
#
# Marcin Orlowski
#
name: "Nightly"
on:
# The "pull_request" trigger is here for debugging purposes and
# as work-around for having this worker not yet in main branch.
# Keep it disabled once it's merged into main branch as we only
# want "schedule" to be the trigger.
# NOTE: remove `if` condition marked with `HACK` once merged.
# pull_request:
# # Nightly must be run against "develop" branch only.
# branches: [ develop ]
# types: [ closed ]
# schedule:
# # every day at midnight
# - cron: "0 0 * * *"
env:
JDK_VERSION: 16
JDK_DISTRO: 'temurin'
jobs:
git_check:
name: "Any changes since last run?"
runs-on: ubuntu-latest
# HACK: Temporary workaround for `schedule` not working outside main
# branch and lack of `type: merged` for `pull_request` trigger.
# if: github.event.pull_request.merged == true
# Export build vars so other steps can use it.
outputs:
# Shall we build anything?
run_build: ${{ steps.filter.outputs.run_build }}
# Base application name and version (read from gradle.properties).
lse_name: ${{ steps.filter.outputs.lse_name }}
lse_version: ${{ steps.filter.outputs.lse_version }}
# Same as lse_version but with with no "unstable suffix (i.e. no "-dev" etc)
lse_version_short: ${{ steps.filter.outputs.lse_version_short }}
# Base name for final daily build files.
base_name: ${{ steps.filter.outputs.base_name }}
steps:
# https://github.com/marketplace/actions/checkout
- name: 'Checkout sources'
uses: actions/checkout@v2
# Check if latest commit is less than a day.
- name: "ANY CHANGES SINCE LAST BUILD?"
id: filter
continue-on-error: true
# if: ${{ github.event_name == 'schedule' }}
run: |
# Have no mercy.
set -euo pipefail
# Short name for branch in which action was triggered.
declare -r branch_name="${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}"
echo "Triggered for branch: ${branch_name}"
# Get SHA of last commit in that branch.
declare -r last_commit_sha="$(git rev-parse HEAD)"
# Let's see if we have any commits in last 24 hours.
if [[ -n "$(git rev-list --after="24 hours" ${last_commit_sha})" ]]; then
echo "::set-output name=run_build::true"
else
echo "*** No code changes since yesterday. Skipping."
fi
# I need to export current version, even if is incorrect for develop branch as it
# is part of produced artifacts. We will strip it prior uploading anyway.
# LSe version string can have additional "unstable" indicator (i.e. "-dev") but
# we are forced to drop the "-" as some packages do not allow it. So in fact
# Gradle artifact for "1.2.3-dev" uses "1.2.3dev" in file names, so we need to
# consider that whlie looking for artifacts (i.e. for upload).
declare -r version_prop=$(grep '^version\s*=.*' gradle.properties | awk '{print $3}')
# Remove "-" (if present) from version string.
declare -r lse_version=$(echo "${version_prop}" | awk '{gsub("-","", $0); print}')
echo "::set-output name=lse_version::${lse_version}"
# Version string with suffix stripped. Required for some packages/platforms.
declare -r lse_version_short=$(echo "${version_prop}" | awk '{ split($0, v, "-")} {print v[1]}')
echo "::set-output name=lse_version_short::${lse_version_short}"
declare -r lse_name="$(fgrep name gradle.properties | awk '{print $3}')"
echo "::set-output name=lse_name::${lse_name}"
# Base name for uploaded artifacts.
echo "::set-output name=base_name::${lse_name}_${branch_name}_$(date +%Y%m%d)"
# ###############################################################################################
# Building for Linux.
build_linux:
name: 'Linux build'
runs-on: ubuntu-latest
# Will run only if git_check determined it is needed.
needs: git_check
if: needs.git_check.outputs.run_build == 'true'
steps:
# https://github.com/z0al/dependent-issues
- name: 'Checkout branch: ${{ env.GITHUB_REF }}'
uses: actions/checkout@v2
with:
ref: 'develop'
- name: 'Build Snap package'
# https://github.com/snapcore/action-build
uses: snapcore/action-build@v1
id: snapcraft
- name: 'Upload *.snap artifact.'
uses: actions/upload-artifact@v3
if: success()
with:
path: ${{ steps.snapcraft.outputs.snap }}
name: ${{ needs.git_check.outputs.base_name }}_amd64.snap
# - name: 'Pushing *.snap to snapcraft.io'
# # https://github.com/snapcore/action-publish
# uses: snapcore/action-publish@v1
# if: success()
# env:
# # Obtain Snapcraft.io store token:
# # $ snapcraft export-login --snaps=logisim-evolution --acls package_access,package_push,package_update,package_release token.txt
# # then open Github repository settings and add new secred named SNAPCRAFT_STORE_TOKEN with the value of token.txt
# SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_TOKEN }}
# with:
# snap: ${{ steps.snapcraft.outputs.snap }}
# release: edge
# ###########################################################################################
- name: Set up JDK ${{ env.JDK_VERSION }} ${{ env.JDK_DISTRO }}
uses: actions/setup-java@v2
with:
java-version: ${{ env.JDK_VERSION }}
distribution: ${{ env.JDK_DISTRO }}
# ###########################################################################################
- name: 'Build binary JAR'
run: |
# Have no mercy.
set -euo pipefail
chmod +x gradlew
./gradlew shadowJar
# https://github.com/marketplace/actions/upload-a-build-artifact
- name: 'Upload binary JAR'
uses: actions/upload-artifact@v3
if: success()
with:
path: build/libs/${{ needs.git_check.outputs.lse_name }}-${{ needs.git_check.outputs.lse_version }}-all.jar
name: ${{ needs.git_check.outputs.base_name }}-all-jdk${{ env.JDK_VERSION }}.jar
# ###########################################################################################
- name: 'Build DEB'
run: |
# Have no mercy.
set -euo pipefail
chmod +x gradlew
./gradlew createDeb -x checkstyleMain -x checkstyleTest
- name: 'Upload *.deb'
uses: actions/upload-artifact@v3
if: success()
with:
path: build/dist/${{ needs.git_check.outputs.lse_name }}_${{ needs.git_check.outputs.lse_version }}-1_amd64.deb
name: ${{ needs.git_check.outputs.base_name }}_amd64.deb
# ###########################################################################################
- name: 'Build RPM'
run: |
# Have no mercy.
set -euo pipefail
chmod +x gradlew
# Needs rpm package, but it should be installed already.
./gradlew createRpm -x checkstyleMain -x checkstyleTest
- name: 'Upload *.rpm'
uses: actions/upload-artifact@v3
if: success()
with:
path: build/dist/${{ needs.git_check.outputs.lse_name }}-${{ needs.git_check.outputs.lse_version }}-1.x86_64.rpm
name: ${{ needs.git_check.outputs.base_name }}.x86_64.rpm
# ###########################################################################################
- name: 'Build sources JAR'
run: |
# Have no mercy.
set -euo pipefail
chmod +x gradlew
# Need to clean to have just one JAR or createDistDir task would fail.
./gradlew clean
./gradlew sourcesJar
- name: 'Upload sources JAR'
uses: actions/upload-artifact@v3
if: success()
with:
path: build/libs/${{ needs.git_check.outputs.lse_name }}-${{ needs.git_check.outputs.lse_version }}-src.jar
name: ${{ needs.git_check.outputs.base_name }}-src.jar
# ###############################################################################################
# Building for macOS.
build_macos:
name: 'macOS build'
runs-on: macos-latest
# Will run only if git_check determined it is needed.
needs: git_check
if: needs.git_check.outputs.run_build == 'true'
steps:
# https://github.com/marketplace/actions/checkout
- name: "Checkout sources"
uses: actions/checkout@v2
with:
ref: ${{ github.ref_name }}
- name: Set up JDK ${{ env.JDK_VERSION }} ${{ env.JDK_DISTRO }}
uses: actions/setup-java@v2
with:
java-version: ${{ env.JDK_VERSION }}
distribution: ${{ env.JDK_DISTRO }}
- name: "Build DMG"
run: |
# Have no mercy.
set -euo pipefail
chmod +x gradlew
./gradlew createDmg -x checkstyleMain -x checkstyleTest
- name: 'Upload DMG'
uses: actions/upload-artifact@v3
if: success()
with:
path: build/dist/${{ needs.git_check.outputs.lse_name }}-${{ needs.git_check.outputs.lse_version }}.dmg
name: ${{ needs.git_check.outputs.base_name }}.dmg
# ###############################################################################################
# Building for Windows.
build_windows:
name: 'Windows build'
runs-on: windows-latest
# Will run only if git_check determined it is needed.
needs: git_check
if: needs.git_check.outputs.run_build == 'true'
steps:
# https://github.com/marketplace/actions/checkout
- name: "Checkout sources"
uses: actions/checkout@v2
- name: Set up JDK ${{ env.JDK_VERSION }} ${{ env.JDK_DISTRO }}
uses: actions/setup-java@v2
with:
java-version: ${{ env.JDK_VERSION }}
distribution: ${{ env.JDK_DISTRO }}
- name: "Build MSI"
run: .\gradlew.bat createMsi -x checkstyleMain -x checkstyleTest
- name: 'Upload MSI'
uses: actions/upload-artifact@v3
if: success()
with:
# NOTE: Gradle builder creates MSI file that always uses short version format in file name.
path: build\dist\${{ needs.git_check.outputs.lse_name }}-${{ needs.git_check.outputs.lse_version_short }}.msi
name: ${{ needs.git_check.outputs.base_name }}.msi