Skip to content

Commit dfe04e8

Browse files
committed
Add github actions to build, test, and add the jar to releases
1 parent 21e5533 commit dfe04e8

3 files changed

Lines changed: 97 additions & 3 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
2+
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
3+
4+
name: Publish Release Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
env:
16+
PLUGIN_NAME: dicom-edit-routing
17+
PLUGIN_DIR: ${{ github.workspace }}
18+
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
19+
GRADLE_USER_HOME: ${{ github.workspace }}/.gradle
20+
steps:
21+
- uses: actions/checkout@v5
22+
23+
- name: Set up JDK 11
24+
uses: actions/setup-java@v4
25+
with:
26+
java-version: '11'
27+
distribution: 'temurin'
28+
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
29+
settings-path: ${{ github.workspace }} # location for the settings.xml file
30+
cache: gradle
31+
32+
- name: Print Gradle version
33+
run: ./gradlew --version
34+
35+
- name: Build plugin
36+
run: |
37+
echo "Building plugin ${{ env.PLUGIN_NAME }}, located at ${{ env.PLUGIN_DIR }}. Using Gradle user home at ${{ env.GRADLE_USER_HOME }}"
38+
./gradlew -p ${{ env.PLUGIN_DIR }} clean build
39+
40+
- name: Upload JAR to GitHub Release
41+
uses: softprops/action-gh-release@v2
42+
with:
43+
files: build/libs/dicom-edit-routing-*.jar

.github/workflows/gradle.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
3+
4+
name: Java CI with Gradle
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
env:
18+
PLUGIN_NAME: dicom-edit-routing
19+
PLUGIN_DIR: ${{ github.workspace }}
20+
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
21+
GRADLE_USER_HOME: ${{ github.workspace }}/.gradle
22+
steps:
23+
- uses: actions/checkout@v5
24+
25+
- name: Set up JDK 11
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: '11'
29+
distribution: 'temurin'
30+
cache: gradle
31+
32+
- name: Print Gradle version
33+
run: ./gradlew --version
34+
35+
- name: Build plugin
36+
run: |
37+
echo "Building plugin ${{ env.PLUGIN_NAME }}, located at ${{ env.PLUGIN_DIR }}. Using Gradle user home at ${{ env.GRADLE_USER_HOME }}"
38+
./gradlew -p ${{ env.PLUGIN_DIR }} clean build
39+
40+
- name: Extract version
41+
id: get_version
42+
run: |
43+
VERSION=$(./gradlew -p ${{ env.PLUGIN_DIR }} :version -q | tail -n 1)
44+
echo "VERSION=$VERSION" >> $GITHUB_ENV
45+
echo "Built version $VERSION of plugin ${{ env.PLUGIN_NAME }}"
46+
47+
- name: Upload JAR artifact
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: ${{ env.PLUGIN_NAME }}-jar
51+
path: ${{ env.PLUGIN_DIR }}/build/libs/*.jar

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ gitVersioning.apply {
4141
branch('.+') {
4242
version = '${ref}-SNAPSHOT'
4343
}
44-
tag('v(?<version>.*)') {
44+
tag('^v?(?<version>\\d+\\.\\d+\\.\\d+)$') {
4545
version = '${ref.version}'
4646
}
4747
}
@@ -94,7 +94,7 @@ dependencyManagement {
9494

9595
// This is a pretty minimal set of dependencies, so don't worry if you need to add more.
9696
dependencies {
97-
implementation enforcedPlatform("org.nrg:parent:${vXnat}")
97+
compileOnly enforcedPlatform("org.nrg:parent:${vXnat}")
9898
implementation("org.nrg.xnat:web") { transitive = false }
9999
implementation("org.nrg:dicom-xnat-mx") { transitive = false }
100100
implementation("org.nrg.xnat:xnat-data-models") { transitive = false }
@@ -172,4 +172,4 @@ jacocoTestReport {
172172
}
173173
}
174174

175-
compileJava.dependsOn project.tasks["xnatDataBuilder"]
175+
compileJava.dependsOn project.tasks["xnatDataBuilder"]

0 commit comments

Comments
 (0)