Skip to content

Commit 319d7f7

Browse files
committed
Added Github actions to build on PR, main commit & release.
1 parent 7ad4dcd commit 319d7f7

10 files changed

Lines changed: 188 additions & 20 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: 'Build XNAT Plugin Jar'
2+
description: 'Builds the XNAT plugin JAR file with Gradle'
3+
inputs:
4+
java-version:
5+
description: 'The version of Java to set up'
6+
required: true
7+
default: '8'
8+
gradle-version:
9+
description: 'The version of Gradle to set up'
10+
required: true
11+
default: '7.0'
12+
outputs:
13+
jar-path:
14+
description: 'The path to the built JAR file'
15+
runs:
16+
using: 'composite'
17+
steps:
18+
- name: Set up JDK
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: ${{ inputs.java-version }}
22+
distribution: 'zulu'
23+
java-package: 'jdk'
24+
25+
- name: Setup Gradle
26+
uses: gradle/actions/setup-gradle@v3
27+
with:
28+
gradle-version: ${{ inputs.gradle-version }}
29+
30+
- name: Build with Gradle
31+
shell: bash
32+
run: ./gradlew clean build --stacktrace
33+
34+
- name: Test Summary
35+
if: always()
36+
uses: test-summary/action@v2
37+
with:
38+
paths: '**/build/test-results/test/*.xml'
39+
40+
- name: Upload Test Results
41+
if: always()
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: test-results
45+
path: '**/build/test-results/test/*.xml'
46+
retention-days: 30
47+
48+
- name: Set output
49+
id: set-output
50+
shell: bash
51+
run: echo "jar-path=build/libs/*.jar" >> "$GITHUB_ENV"

.github/workflows/develop.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Develop
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Build Plugin JAR
20+
uses: ./.github/actions/build-plugin-jar
21+
with:
22+
java-version: '8'
23+
gradle-version: '7.0'
24+
25+
- name: Upload JAR
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: plugin-jar
29+
path: ${{ env.jar-path }}
30+
retention-days: 90

.github/workflows/main.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Build Plugin JAR
20+
uses: ./.github/actions/build-plugin-jar
21+
with:
22+
java-version: '8'
23+
gradle-version: '7.0'
24+
25+
- name: Upload JAR
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: plugin-jar
29+
path: ${{ env.jar-path }}
30+
retention-days: 90
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Pull Request
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Build Plugin JAR
20+
uses: ./.github/actions/build-plugin-jar
21+
with:
22+
java-version: '8'
23+
gradle-version: '7.0'

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
10+
release:
11+
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
contents: write
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Build JAR
21+
uses: ./.github/actions/build-plugin-jar
22+
with:
23+
java-version: '8'
24+
gradle-version: '7.0'
25+
26+
- name: Publish Release
27+
uses: softprops/action-gh-release@v1
28+
with:
29+
files: ${{ env.jar-path }}
30+
prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-beta') || contains(github.ref, '-alpha') }}
31+
body: The plugin JAR is attached to this release.

build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.gradle.api.attributes.java.TargetJvmEnvironment
2+
13
buildscript {
24
ext {
35
vXnat = "1.9.3.3"
@@ -40,8 +42,8 @@ configurations.all {
4042
}
4143
attributes {
4244
attribute(
43-
Attribute.of("org.gradle.jvm.environment", String),
44-
"standard-jvm"
45+
TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE,
46+
objects.named(TargetJvmEnvironment, TargetJvmEnvironment.STANDARD_JVM)
4547
)
4648
}
4749
}

gradle/wrapper/gradle-wrapper.jar

3.22 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

Lines changed: 14 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)