Skip to content

Commit 1c4a76c

Browse files
committed
fix build workflow and add release workflow
1 parent 5f9d817 commit 1c4a76c

File tree

4 files changed

+105
-39
lines changed

4 files changed

+105
-39
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: SonarCloud
1+
name: Build Pipeline
22
on:
33
push:
44
branches:
@@ -18,21 +18,15 @@ jobs:
1818
with:
1919
java-version: 17
2020
distribution: 'zulu' # Alternative distribution options are available
21-
- name: Cache SonarCloud packages
22-
uses: actions/cache@v3
23-
with:
24-
path: ~/.sonar/cache
25-
key: ${{ runner.os }}-sonar
26-
restore-keys: ${{ runner.os }}-sonar
2721
- name: Cache Gradle packages
2822
uses: actions/cache@v3
2923
with:
3024
path: ~/.gradle/caches
3125
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
3226
restore-keys: ${{ runner.os }}-gradle
33-
- name: Build and analyze
27+
- name: Build & Run Tests
3428
working-directory: ./de.peeeq.wurstscript
3529
env:
3630
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
3731
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
38-
run: ./gradlew build sonar --info
32+
run: ./gradlew test --info

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Deploy Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
jobs:
10+
deploy:
11+
name: Build WurstScript and Upload to GitHub Release
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up JDK 17
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: 17
22+
distribution: temurin
23+
24+
- name: Grant Gradle permissions
25+
working-directory: ./de.peeeq.wurstscript
26+
run: chmod +x ./gradlew
27+
28+
- name: Build WurstScript zips
29+
working-directory: ./de.peeeq.wurstscript
30+
run: ./gradlew create_zips
31+
32+
- name: Create or update nightly-master tag
33+
run: |
34+
git config user.name "github-actions[bot]"
35+
git config user.email "github-actions[bot]@users.noreply.github.com"
36+
git tag -f nightly-master
37+
git push -f origin nightly-master
38+
39+
- name: Create or update GitHub Release
40+
id: create_release
41+
uses: softprops/action-gh-release@v1
42+
with:
43+
tag_name: nightly-master
44+
name: Nightly Build (master)
45+
body: "This release is automatically updated from the latest push to `master`."
46+
draft: false
47+
prerelease: true
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: Upload wurstpack_complete.zip
52+
uses: softprops/action-gh-release@v1
53+
with:
54+
files: de.peeeq.wurstscript/../downloads/wurstpack_complete.zip
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
58+
- name: Upload wurstpack_compiler.zip
59+
uses: softprops/action-gh-release@v1
60+
with:
61+
files: de.peeeq.wurstscript/../downloads/wurstpack_compiler.zip
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

de.peeeq.wurstscript/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ plugins {
1717
id 'idea'
1818
id 'application'
1919
id "org.sonarqube" version "4.4.1.3373"
20+
id 'com.github.johnrengelman.shadow' version '8.1.1'
2021
}
2122

2223
import de.undercouch.gradle.tasks.download.Download

de.peeeq.wurstscript/deploy.gradle

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,98 @@
1-
// To publish first run ./gradlew installDist
2-
// then copy to wurstpack folder
1+
// Apply shadow plugin (assumes this is applied from main build.gradle with buildscript setup)
2+
apply plugin: 'com.github.johnrengelman.shadow'
33

4-
jar {
5-
version = null
4+
// Shadow JAR config using externally defined mainClassName
5+
shadowJar {
6+
archiveBaseName.set('wurstscript')
7+
archiveClassifier.set('')
8+
archiveVersion.set('')
69
manifest {
7-
attributes(
8-
'Class-Path': configurations.runtimeClasspath.collect { it.getName() }.join(' '),
9-
'Main-Class': mainClassName
10-
)
10+
attributes 'Main-Class': mainClassName
1111
}
1212
}
1313

14+
// Get reference to fat JAR for reuse
15+
def fatJar = shadowJar.archiveFile.map { it.asFile }
16+
17+
// Install fat jar into ~/.wurst
1418
task make_for_userdir(type: Copy) {
15-
from 'build/install/wurstscript/lib'
19+
from fatJar
1620
into "${System.properties['user.home']}/.wurst/"
1721
}
22+
make_for_userdir.dependsOn(shadowJar)
1823

19-
make_for_userdir.dependsOn(installDist)
20-
24+
// Copy fat jar into Wurstpack bundle dir
2125
task make_for_wurstpack(type: Copy) {
22-
from 'build/install/wurstscript/lib'
26+
from fatJar
2327
into '../Wurstpack/wurstscript/'
2428
}
25-
make_for_wurstpack.dependsOn(installDist)
26-
29+
make_for_wurstpack.dependsOn(shadowJar)
2730

31+
// Full zip of Wurstpack (includes wrappers, .exe, etc.)
2832
task create_zip_wurstpack_complete(type: Zip) {
2933
from '../Wurstpack'
3034
archiveFileName.set('wurstpack_complete.zip')
3135
}
3236
create_zip_wurstpack_complete.dependsOn(make_for_wurstpack)
3337

38+
// Compiler-only zip (just the fat jar and related files)
3439
task create_zip_wurstpack_compiler(type: Zip) {
3540
from '../Wurstpack/wurstscript/'
3641
archiveFileName.set('wurstpack_compiler.zip')
3742
}
3843
create_zip_wurstpack_compiler.dependsOn(make_for_wurstpack)
3944

40-
41-
45+
// Bundle downloads for GitHub release
4246
task create_zips {
4347
doLast {
4448
mkdir("../downloads/")
49+
4550
copy {
46-
from 'build/distributions/'
47-
into '../downloads/'
48-
}
49-
copy {
50-
from 'build/install/wurstscript/lib/wurstscript.jar'
51+
from fatJar
5152
into '../downloads/'
5253
}
54+
5355
copy {
5456
from '../Wurstpack'
5557
into '../downloads/Wurstpack/'
5658
}
59+
5760
copy {
5861
from '../WurstSetup/build/libs/WurstSetup.jar'
5962
into '../downloads/'
6063
}
61-
// create checksums
62-
mkdir("../Checksums/bin")
6364

65+
// Generate checksums
66+
mkdir("../Checksums/bin")
6467
javaexec {
6568
classpath = sourceSets.main.runtimeClasspath
6669
main = "de.peeeq.wurstio.Checksums"
67-
args = ["../downloads/Wurstpack/",
68-
"../downloads/wurstpack.md5"]
70+
args = [
71+
"../downloads/Wurstpack/",
72+
"../downloads/wurstpack.md5"
73+
]
6974
}
7075
}
7176
}
72-
create_zips.dependsOn(installDist)
77+
create_zips.dependsOn(shadowJar)
7378
create_zips.dependsOn(create_zip_wurstpack_complete)
7479
create_zips.dependsOn(create_zip_wurstpack_compiler)
7580

81+
// Hotdoc generation
7682
task generate_hotdoc {
7783
doLast {
7884
copy {
79-
from("/src/main/resources/")
80-
into("/build/classes/main/")
85+
from("src/main/resources/")
86+
into("build/classes/main/")
8187
}
8288
javaexec {
8389
classpath = sourceSets.main.runtimeClasspath
8490
main = "de.peeeq.wurstio.Main"
85-
args = ["--hotdoc",
91+
args = [
92+
"--hotdoc",
8693
"./build/deps/",
87-
"../downloads/hotdoc"]
94+
"../downloads/hotdoc"
95+
]
8896
}
8997
}
9098
}

0 commit comments

Comments
 (0)