-
Notifications
You must be signed in to change notification settings - Fork 29
174 lines (156 loc) · 5.97 KB
/
Copy pathbuild.yml
File metadata and controls
174 lines (156 loc) · 5.97 KB
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
name: CI (build & test)
on:
push:
branches: [ master ]
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Gradle build on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
permissions:
contents: read
env:
GRADLE_OPTS: -Dorg.gradle.daemon=false
defaults:
run:
working-directory: de.peeeq.wurstscript
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Temurin JDK 25
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '25'
cache: 'gradle'
# Linux only: use a portable, pristine Temurin 25 for jlink
- name: (Linux) Install portable Temurin 25
if: runner.os == 'Linux'
shell: bash
run: |
set -euo pipefail
URL="https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25%2B36/OpenJDK25U-jdk_x64_linux_hotspot_25_36.tar.gz"
mkdir -p "$RUNNER_TEMP/temurin25"
curl -fsSL "$URL" -o "$RUNNER_TEMP/temurin25/jdk.tar.gz"
tar -xzf "$RUNNER_TEMP/temurin25/jdk.tar.gz" -C "$RUNNER_TEMP/temurin25"
PORTABLE_JAVA_HOME="$(find "$RUNNER_TEMP/temurin25" -maxdepth 1 -type d -name 'jdk-25*' | head -n1)"
echo "PORTABLE_JAVA_HOME=$PORTABLE_JAVA_HOME" >> "$GITHUB_ENV"
echo "$PORTABLE_JAVA_HOME/bin" >> "$GITHUB_PATH"
# Pin Gradle toolchain to the active JDK (portable on Linux, setup-java on Windows)
- name: Pin Gradle toolchain
shell: bash
run: |
ACTIVE_JAVA_HOME="${PORTABLE_JAVA_HOME:-$JAVA_HOME}"
echo "JAVA_HOME=${ACTIVE_JAVA_HOME}" >> "$GITHUB_ENV"
echo "${ACTIVE_JAVA_HOME}/bin" >> "$GITHUB_PATH"
echo "org.gradle.java.installations.paths=${ACTIVE_JAVA_HOME}" >> gradle.properties
echo "org.gradle.java.installations.auto-detect=false" >> gradle.properties
- name: Show Java & jlink
shell: bash
run: |
echo "JAVA_HOME=$JAVA_HOME"
"$JAVA_HOME/bin/java" -version
"$JAVA_HOME/bin/jlink" --version
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Setup Gradle (cache)
uses: gradle/actions/setup-gradle@v4
# ---- FAIL FAST: package first (so jlink issues show immediately) ----
- name: Package slim runtime (fail fast)
shell: bash
run: ./gradlew checksumSlimCompilerDist --no-daemon --stacktrace
- name: Run tests
shell: bash
run: ./gradlew test --no-daemon --stacktrace
- name: Upload packaged artifact (per-OS)
uses: actions/upload-artifact@v4
with:
name: wurst-compiler-${{ matrix.os }}
path: |
de.peeeq.wurstscript/build/releases/*.zip
de.peeeq.wurstscript/build/releases/*.tar.gz
de.peeeq.wurstscript/build/releases/*.sha256
if-no-files-found: error
retention-days: 7
nightly_release:
name: Nightly prerelease (master)
needs: build
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all packaged artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
# Copy only archives (skip .sha256 for nightly)
- name: Gather files (zip + tar.gz, no checksums)
shell: bash
run: |
set -euo pipefail
mkdir -p upload
find artifacts -type f \( -name '*.zip' -o -name '*.tar.gz' \) -print0 | xargs -0 -I{} cp "{}" upload/
# Ensure both Windows (.zip) and Linux (.tar.gz) exist
- name: Verify we have both archive types
shell: bash
run: |
shopt -s nullglob
zips=(upload/*.zip)
tars=(upload/*.tar.gz)
echo "Found ${#zips[@]} zip(s) and ${#tars[@]} tar.gz file(s)."
if (( ${#zips[@]} == 0 || ${#tars[@]} == 0 )); then
echo "ERROR: Expected both .zip (Windows) and .tar.gz (Linux) artifacts."
ls -alR upload || true
exit 1
fi
# Rename artifacts: replace ONLY the version token between hyphens with 'nightly', keep platform + extension
- name: Normalize nightly filenames (preserve platform + extension)
shell: bash
run: |
set -euo pipefail
shopt -s nullglob
for f in upload/*; do
base="$(basename "$f")"
ext=""; stem="$base"
if [[ "$base" == *.* ]]; then
ext=".${base##*.}" # extension incl. dot
stem="${base%.*}" # name without extension
fi
# Replace the first hyphen-delimited numeric version token with 'nightly'
# Example: wurst-compiler-1.8.1.0-linux-x64 -> wurst-compiler-nightly-linux-x64
new_stem="$(echo "$stem" | sed -E 's/-[0-9]+(\.[0-9]+)*-/-nightly-/' )"
new="${new_stem}${ext}"
if [[ "$base" != "$new" ]]; then
mv -f "upload/$base" "upload/$new"
fi
done
echo "After rename:"
ls -alh upload
- name: Publish Nightly Release (rolling 'nightly' tag)
uses: softprops/action-gh-release@v2
with:
tag_name: nightly
name: Nightly Build (master)
prerelease: true
draft: false
make_latest: false
generate_release_notes: false
body: |
Nightly build for the latest commit on `master`.
This release is automatically updated in-place (same tag).
files: |
upload/**
fail_on_unmatched_files: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}