-
Notifications
You must be signed in to change notification settings - Fork 1
303 lines (255 loc) · 11.2 KB
/
build.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
291
292
293
294
295
296
297
298
299
300
301
302
303
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: Build
on:
push:
branches-ignore: # build all branches except:
- 'dependabot/**' # prevent GHA triggered twice (once for commit to the branch and once for opening/syncing the PR)
tags-ignore: # don't build tags
- '**'
paths-ignore:
- '**/*.adoc'
- '**/*.md'
- '.editorconfig'
- '.git*'
- '.github/*.yml'
- '.github/workflows/stale.yml'
pull_request:
paths-ignore:
- '**/*.adoc'
- '**/*.md'
- '.editorconfig'
- '.git*'
- '.github/*.yml'
repository_dispatch:
types: [new-dart4e-release]
workflow_dispatch:
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
inputs:
additional_maven_args:
description: 'Additional Maven Args'
required: false
default: ''
defaults:
run:
shell: bash
env:
JAVA_VERSION: 17
jobs:
###########################################################
maven-build:
###########################################################
runs-on: windows-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'repository_dispatch' }}
steps:
- name: "Show: GitHub context"
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo $GITHUB_CONTEXT
- name: "Show: environment variables"
run: env | sort
- name: Git Checkout
uses: actions/checkout@v4 # https://github.com/actions/checkout
- name: "Install: JDK ${{ env.JAVA_VERSION }} ☕"
uses: actions/setup-java@v4 # https://github.com/actions/setup-java
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
- name: "Cache: Local Maven Repository"
uses: actions/cache@v4
with:
# Excluded sub directory not working https://github.com/actions/toolkit/issues/713
path: |
~/.m2/repository/*
!~/.m2/repository/com/vegardit/no-npe
!~/.m2/repository/.cache/tycho
!~/.m2/repository/.meta/p2-artifacts.properties
!~/.m2/repository/p2
!~/.m2/repository/*SNAPSHOT*
key: ${{ runner.os }}-repo-mvn-${{ hashFiles('**/pom.xml') }}
- name: "Cache: Local Tycho Repository"
uses: actions/cache@v4
with:
path: |
~/.m2/repository/.cache/tycho
~/.m2/repository/.meta/p2-artifacts.properties
~/.m2/repository/p2
key: ${{ runner.os }}-repo-tycho-${{ hashFiles('build.target') }}
- name: "Build with Maven 🔨"
id: maven-build
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_API_KEY: ${{ github.token }}
run: |
set -eu
#
# ensure mnvw is executable
#
chmod u+x ./mvnw
# https://gh.neting.ccmunity/t/github-actions-bot-email-address/17204
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
MAVEN_OPTS="${MAVEN_OPTS:-}"
MAVEN_OPTS+=" -Djava.security.egd=file:/dev/./urandom" # https://stackoverflow.com/questions/58991966/what-java-security-egd-option-is-for/59097932#59097932
MAVEN_OPTS+=" -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS" # https://stackoverflow.com/questions/5120470/how-to-time-the-different-stages-of-maven-execution/49494561#49494561
MAVEN_OPTS+=" -Xmx1024m -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dhttps.protocols=TLSv1.3,TLSv1.2"
export MAVEN_OPTS
echo "MAVEN_OPTS: $MAVEN_OPTS"
./mvnw \
--errors \
--update-snapshots \
--batch-mode \
--show-version \
--no-transfer-progress \
-s .ci/maven-settings.xml \
-t .ci/maven-toolchains.xml \
-Dtycho.disableP2Mirrors=true \
${{ github.event.inputs.additional_maven_args }} \
clean verify
cd product/target/products
# remove unused dynamic libs
rm -rf \
org.dart4e.studio/linux/gtk/x86_64/plugins/com.sun.jna_*/com/sun/jna/{aix,darwin,freebsd,linux-a,linux-l,linux-m,linux-p,linux-r,linux-s,openbsd,sunos,win32}* \
org.dart4e.studio/macosx/cocoa/x86_64/Eclipse.app/Contents/Eclipse/plugins/com.sun.jna_*/com/sun/jna/{aix,freebsd,linux,openbsd,sunos,win32}* \
org.dart4e.studio/win32/win32/x86_64/plugins/com.sun.jna_*/com/sun/jna/{aix,darwin,freebsd,linux,openbsd,sunos}* \
# generate linux archive
(
cd org.dart4e.studio/linux/gtk/x86_64;
tar -cf ../../../../org.dart4e.studio-linux.gtk.x86_64.tar --exclude='Dart4EStudio' --exclude='plugins/org.eclipse.justj.*/jre/bin' *;
tar --mode='+x' --append -f ../../../../org.dart4e.studio-linux.gtk.x86_64.tar Dart4EStudio plugins/org.eclipse.justj.*/jre/bin/*
)
gzip -9 org.dart4e.studio-linux.gtk.x86_64.tar
# generate macos archive
(
cd org.dart4e.studio/macosx/cocoa/aarch64;
tar -cf ../../../../org.dart4e.studio-macosx.cocoa.aarch64.tar --exclude='Eclipse.app/Contents/MacOS/Dart4EStudio' --exclude='Eclipse.app/Contents/Eclipse/plugins/org.eclipse.justj.*/jre/bin' *;
tar --mode='+x' --append -f ../../../../org.dart4e.studio-macosx.cocoa.aarch64.tar Eclipse.app/Contents/MacOS/Dart4EStudio Eclipse.app/Contents/Eclipse/plugins/org.eclipse.justj.*/jre/bin/*
)
gzip -9 org.dart4e.studio-macosx.cocoa.aarch64.tar
(
cd org.dart4e.studio/macosx/cocoa/x86_64;
tar -cf ../../../../org.dart4e.studio-macosx.cocoa.x86_64.tar --exclude='Eclipse.app/Contents/MacOS/Dart4EStudio' --exclude='Eclipse.app/Contents/Eclipse/plugins/org.eclipse.justj.*/jre/bin' *;
tar --mode='+x' --append -f ../../../../org.dart4e.studio-macosx.cocoa.x86_64.tar Eclipse.app/Contents/MacOS/Dart4EStudio Eclipse.app/Contents/Eclipse/plugins/org.eclipse.justj.*/jre/bin/*
)
gzip -9 org.dart4e.studio-macosx.cocoa.x86_64.tar
# generate windows archive
7z a -mx9 -tzip org.dart4e.studio-win.x86_64.zip ./org.dart4e.studio/win32/win32/x86_64/*
- name: Generate PortableApps archive
run: |
bash product/build-paf.sh
- name: "Determine release name"
id: release
if: ${{ !env.ACT }}
run: |
case "$GITHUB_REF_NAME" in
main)
echo "name=preview" >>"$GITHUB_OUTPUT"
echo "updatesite_branch=updatesite-preview" >>"$GITHUB_OUTPUT"
;;
release)
echo "name=stable" >>"$GITHUB_OUTPUT"
echo "updatesite_branch=updatesite" >>"$GITHUB_OUTPUT"
;;
esac
- name: "Delete previous '${{ steps.release.outputs.name }}' release"
if: ${{ steps.release.outputs.name != '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NAME: ${{ steps.release.outputs.name }}
# https://cli.github.com/manual/gh_release_delete
run: |
GH_DEBUG=1 gh release delete "$RELEASE_NAME" --yes --cleanup-tag || true
- name: "Create '${{ steps.release.outputs.name }}' release"
if: ${{ steps.release.outputs.name != '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NAME: ${{ steps.release.outputs.name }}
COMMIT_MSG: ${{ github.event.head_commit.message }} # https://stackoverflow.com/a/78420438/5116073
# https://cli.github.com/manual/gh_release_create
run: |
GH_DEBUG=1 gh release create "$RELEASE_NAME" \
--title "$RELEASE_NAME" \
${{ steps.release.outputs.name == 'stable' && '--latest' || '' }} \
${{ steps.release.outputs.name == 'preview' && '--prerelease' || '' }} \
--notes "$COMMIT_MSG" \
--target "${{ github.sha }}" \
product/target/products/org.dart4e.studio-linux.gtk.x86_64.tar.gz \
product/target/products/org.dart4e.studio-macosx.cocoa.aarch64.tar.gz \
product/target/products/org.dart4e.studio-macosx.cocoa.x86_64.tar.gz \
product/target/products/org.dart4e.studio-win.x86_64.zip \
product/target/Dart4EStudioPortable.paf.exe
- name: Deploy p2 update site
if: ${{ steps.release.outputs.name != '' }}
env:
BRANCH_NAME: ${{ steps.release.outputs.updatesite_branch }}
run: |
set -eux
last_commit_message=$(git log --pretty=format:"%s (%h)" -1)
cd /tmp
github_repo_url="https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}"
if curl --output /dev/null --silent --head --fail "$github_repo_url/tree/$BRANCH_NAME"; then
git clone $github_repo_url --single-branch --branch "$BRANCH_NAME" updatesite
cd updatesite
# https://gh.neting.ccmunity/t/github-actions-bot-email-address/17204
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git reset --hard HEAD^
else
git clone $github_repo_url updatesite
cd updatesite
git checkout --orphan "$BRANCH_NAME"
git rm -rf .
cat <<EOF > index.html
<!DOCTYPE html>
<html>
<head>
<title>${{ github.repository }} - Update Site</title>
</head>
<body>
<h1>${{ github.repository }} - Update Site</h1>
</body>
</html>
EOF
git add index.html
# https://gh.neting.ccmunity/t/github-actions-bot-email-address/17204
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -am "Initialize Update Site"
fi
mv $(cygpath $GITHUB_WORKSPACE)/product/target/repository/* .
git add --all
git commit -am "$last_commit_message"
git push origin "$BRANCH_NAME" --force
###########################################################
dependabot-pr-auto-merge:
###########################################################
needs: maven-build
if: ${{ github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest
concurrency: dependabot-pr-auto-merge
permissions:
contents: write
pull-requests: write
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2 # https://github.com/dependabot/fetch-metadata/
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
if: |
${{
(
steps.dependabot-metadata.outputs.package-ecosystem == 'github-actions' &&
steps.metadata.outputs.update-type == 'version-update:semver-major'
) || (
steps.dependabot-metadata.outputs.package-ecosystem == 'maven' &&
steps.metadata.outputs.update-type == 'version-update:semver-minor'
)
}}
run: |
gh pr merge --auto --rebase "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}