Skip to content

Commit 932e867

Browse files
committed
Chore: Update CI workflow to include build artifacts
The GitHub workflow will now use the upload-artifact action to include a Maven repository overlay if the build is successful. Parent and module versions are managed via snapshot.properties.
1 parent 7714fe1 commit 932e867

File tree

5 files changed

+63
-11
lines changed

5 files changed

+63
-11
lines changed

.github/workflows/ci.yml

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,29 @@ on:
1616
- '**.md'
1717

1818
jobs:
19-
build:
19+
artifact:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@master
23+
- name: Set up JDK 8
24+
uses: actions/setup-java@master
25+
with:
26+
java-version: 8
27+
- name: Set artifact version
28+
run: script/version_snapshot.sh
29+
shell: bash
30+
- name: Stage artifacts
31+
run: mvn -B -DaltDeploymentRepository=ossrh::default::file:snapshot/ deploy
32+
- name: Package artifacts
33+
uses: actions/upload-artifact@master
34+
if: success()
35+
with:
36+
name: jsonurl-maven-repository
37+
path: snapshot/*
38+
39+
matrix-build:
40+
needs: artifact
41+
if: needs.artifact.result == 'success'
2042
runs-on: ${{ matrix.os }}
2143
strategy:
2244
matrix:
@@ -29,34 +51,45 @@ jobs:
2951
with:
3052
java-version: ${{ matrix.jdk }}
3153
- name: Cache Maven dependencies
32-
uses: actions/cache@master
54+
timeout-minutes: 10
55+
uses: actions/cache@v1
3356
with:
3457
path: ~/.m2
3558
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
3659
restore-keys: ${{ runner.os }}-m2
60+
- name: Set artifact version
61+
run: script/version_snapshot.sh
62+
shell: bash
3763
- name: Build with Maven
38-
run: mvn -P jacoco -B clean package --file pom.xml
64+
run: mvn -P jacoco -B clean package verify --file pom.xml
3965

4066
snyk:
41-
needs: build
67+
needs: artifact
4268
if: |
4369
github.event_name == 'push'
4470
&& endsWith( github.ref, '/master' )
45-
&& needs.build.result == 'success'
71+
&& needs.artifact.result == 'success'
4672
runs-on: ubuntu-latest
4773
steps:
4874
- uses: actions/checkout@master
75+
- name: Set up JDK 11
76+
uses: actions/setup-java@master
77+
with:
78+
java-version: 11
79+
- name: Set artifact version
80+
run: script/version_snapshot.sh
81+
shell: bash
4982
- name: Run Snyk to check for vulnerabilities
5083
uses: snyk/actions/maven-3-jdk-11@master
5184
env:
5285
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
5386

5487
sonarcloud:
55-
needs: build
88+
needs: artifact
5689
if: |
5790
github.event_name == 'push'
5891
&& endsWith( github.ref, '/master' )
59-
&& needs.build.result == 'success'
92+
&& needs.artifact.result == 'success'
6093
runs-on: ubuntu-latest
6194
steps:
6295
- uses: actions/checkout@master
@@ -66,8 +99,12 @@ jobs:
6699
java-version: 11
67100
server-id: sonar
68101
server-sonar.login: ${{ secrets.SONAR_TOKEN }}
102+
- name: Set artifact version
103+
run: script/version_snapshot.sh
104+
shell: bash
69105
- name: SonarCloud Scan
70106
run: mvn -P jacoco -B -Dsonar.projectKey=jsonurl_jsonurl-java -Dsonar.organization=jsonurl -Dsonar.host.url=https://sonarcloud.io package sonar:sonar
71107
env:
72108
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73109
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
110+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
**/.mvn/timing.properties
1313
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
1414
**/.mvn/wrapper/maven-wrapper.jar
15+
snapshot/
1516

1617
#
1718
# Eclipse

module/pom.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<maven.doxia.plugin>[1.9,)</maven.doxia.plugin>
5656
<maven.project.info.reports.plugin>2.9</maven.project.info.reports.plugin>
5757
<nexus.staging.pluggin>1.6.8</nexus.staging.pluggin>
58+
<codehaus.versions.pluggin>2.7</codehaus.versions.pluggin>
5859
<nexus.url>https://oss.sonatype.org</nexus.url>
5960

6061
<junit.version>[5.4,)</junit.version>
@@ -115,7 +116,6 @@
115116
<url>${nexus.url}/content/repositories/snapshots</url>
116117
</snapshotRepository>
117118
</distributionManagement>
118-
119119

120120
<dependencies>
121121
<dependency>
@@ -133,9 +133,6 @@
133133
</dependencies>
134134

135135
<build>
136-
<!--
137-
<finalName>jsonurl-${project.artifactId}-${project.version}</finalName>
138-
-->
139136
<pluginManagement>
140137
<plugins>
141138
<plugin>
@@ -290,6 +287,11 @@
290287
<autoReleaseAfterClose>false</autoReleaseAfterClose>
291288
</configuration>
292289
</plugin>
290+
<plugin>
291+
<groupId>org.codehaus.mojo</groupId>
292+
<artifactId>versions-maven-plugin</artifactId>
293+
<version>${codehaus.versions.pluggin}</version>
294+
</plugin>
293295
</plugins>
294296
</pluginManagement>
295297
</build>

script/version_snapshot.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
mvn -B versions:set -DnewVersion=`sed -n 's/^parent.version=//p' snapshot.properties` -DartifactId=parent
4+
5+
mvn -B versions:set -DnewVersion=`sed -n 's/^module.version=//p' snapshot.properties` -DartifactId='*' -DprocessParent=false
6+

snapshot.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#
2+
# version information used for building snapshots
3+
#
4+
parent.version=3-SNAPSHOT
5+
module.version=1.2.0-SNAPSHOT
6+

0 commit comments

Comments
 (0)