Skip to content

Commit 18fc30a

Browse files
committed
Add CI files
1 parent c026f39 commit 18fc30a

File tree

2 files changed

+201
-0
lines changed

2 files changed

+201
-0
lines changed

.github/workflows/build.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
workflow_dispatch:
11+
inputs:
12+
is-a-release:
13+
description: Publish release? (Only works on master, and for untagged versions)
14+
type: boolean
15+
16+
permissions:
17+
contents: write
18+
19+
jobs:
20+
test:
21+
name: Run test suite
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
os: [ ubuntu-latest ]
26+
java-version: [ 21 ]
27+
runs-on: ubuntu-latest
28+
timeout-minutes: 10
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v3
32+
- name: Setup JDK
33+
uses: actions/setup-java@v3
34+
with:
35+
distribution: temurin
36+
java-version: 21
37+
check-latest: true
38+
# The project version extract NEEDS to have the maven wrapper already downloaded.
39+
# So we have a dummy step here just to initialize it.
40+
- name: Download Maven wrapper
41+
run: ./mvnw --version
42+
- name: Run tests
43+
run: ./mvnw test
44+
- name: Upload test results
45+
if: always()
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: Test artifacts
49+
retention-days: 21
50+
path: |
51+
**/TEST-*
52+
**/hs_err_pid*
53+
54+
# Publishes the test results of 'test'
55+
publish-test-results:
56+
name: Publish tests results
57+
needs: test
58+
if: always()
59+
runs-on: ubuntu-latest
60+
permissions:
61+
checks: write
62+
pull-requests: write
63+
steps:
64+
- name: Download artifacts
65+
uses: actions/download-artifact@v4
66+
with:
67+
path: artifacts
68+
- name: Publish test results
69+
uses: EnricoMi/publish-unit-test-result-action@v2
70+
with:
71+
check_name: Unit Test results
72+
files: |
73+
**/TEST-*
74+
75+
# Builds the projects and attempts to publish a release if the current project version
76+
# does not match any existing tags in the repository.
77+
build-and-release:
78+
name: Publish release
79+
needs: test
80+
if: inputs.is-a-release && github.repository == 'Col-E/BentoFX' && github.ref == 'refs/heads/master'
81+
strategy:
82+
fail-fast: false
83+
runs-on: ubuntu-latest
84+
timeout-minutes: 10
85+
steps:
86+
- name: Checkout
87+
uses: actions/checkout@v3
88+
with:
89+
fetch-depth: 0 # Required depth for JReleaser
90+
- name: Setup Java JDK
91+
uses: actions/setup-java@v3
92+
with:
93+
distribution: temurin
94+
java-version: 21
95+
# The project version extract NEEDS to have the maven wrapper already downloaded.
96+
# So we have a dummy step here just to initialize it.
97+
- name: Download Maven wrapper
98+
run: ./mvnw --version
99+
# Set environment variable for the project version: "var_to_set=$(command_to_run)" >> sink
100+
# - For maven: echo "PROJECT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
101+
# - For gradle: echo "PROJECT_VERSION=$(./gradlew properties | grep -Po '(?<=version: ).*')" >> $GITHUB_ENV
102+
- name: Extract project version to environment variable
103+
run: echo "PROJECT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
104+
# Check if a tag exists that matches the current project version.
105+
# Write the existence state to the step output 'tagExists'.
106+
- name: Check the package version has corresponding Git tag
107+
id: tagged
108+
shell: bash
109+
run: |
110+
git show-ref --tags --verify --quiet -- "refs/tags/${{ env.PROJECT_VERSION }}" && echo "tagExists=1" >> $GITHUB_OUTPUT || echo "tagExists=0" >> $GITHUB_OUTPUT
111+
git show-ref --tags --verify --quiet -- "refs/tags/${{ env.PROJECT_VERSION }}" && echo "Tag for current version exists" || echo "Tag for current version does not exist"
112+
# If the tag could not be fetched, show a message and abort the job.
113+
# The wonky if logic is a workaround for: https://github.com/actions/runner/issues/1173
114+
- name: Abort if tag exists, or existence check fails
115+
if: ${{ false && steps.tagged.outputs.tagExists }}
116+
run: |
117+
echo "Output of 'tagged' step: ${{ steps.tagged.outputs.tagExists }}"
118+
echo "Failed to check if tag exists."
119+
echo "PROJECT_VERSION: ${{ env.PROJECT_VERSION }}"
120+
echo "Tags $(git tag | wc -l):"
121+
git tag
122+
git show-ref --tags --verify -- "refs/tags/${{ env.PROJECT_VERSION }}"
123+
exit 1
124+
# Run build to generate the release artifacts.
125+
# Tag does not exist AND trigger was manual. Deploy release artifacts!
126+
- name: Build release artifacts
127+
run: ./mvnw -Dmaven.test.skip=true deploy -Prelease -DaltDeploymentRepository=local::default::file:./target/staging-deploy
128+
# Make release with JReleaser, only running when the project version does not exist as a tag on the repository.
129+
- name: Publish release
130+
uses: jreleaser/release-action@v2
131+
with:
132+
arguments: full-release
133+
env:
134+
JRELEASER_PROJECT_VERSION: ${{ env.PROJECT_VERSION }}
135+
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
136+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
137+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
138+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
139+
JRELEASER_NEXUS2_USERNAME: ${{ secrets.JRELEASER_DEPLOY_MAVEN_NEXUS2_USERNAME }}
140+
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.JRELEASER_DEPLOY_MAVEN_NEXUS2_PASSWORD }}
141+
# Upload JRelease debug log
142+
- name: JReleaser output
143+
uses: actions/upload-artifact@v4
144+
if: always()
145+
with:
146+
name: jreleaser-release
147+
path: |
148+
out/jreleaser/trace.log
149+
out/jreleaser/output.properties

jreleaser.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
project:
2+
name: bento-fx
3+
description: A docking system for JavaFX
4+
longDescription: A docking system for JavaFX
5+
links:
6+
homepage: https://github.com/Col-E/BentoFX
7+
authors:
8+
- Matt Coley
9+
license: MIT
10+
inceptionYear: 2025
11+
stereotype: none
12+
java:
13+
version: 21
14+
groupId: software.coley
15+
artifactId: bento-fx
16+
17+
release:
18+
github:
19+
overwrite: true
20+
tagName: '{{projectVersion}}'
21+
changelog:
22+
formatted: ALWAYS
23+
preset: conventional-commits
24+
contributors:
25+
format: '- {{contributorName}}{{#contributorUsernameAsLink}} ({{.}}){{/contributorUsernameAsLink}}'
26+
27+
distributions:
28+
dist:
29+
type: SINGLE_JAR
30+
artifacts:
31+
- path: target/{{projectName}}-{{projectVersion}}.jar
32+
33+
signing:
34+
active: RELEASE
35+
mode: MEMORY
36+
armored: true
37+
verify: true
38+
artifacts: true
39+
checksums: true
40+
files: false
41+
42+
deploy:
43+
maven:
44+
nexus2:
45+
maven-central:
46+
active: RELEASE
47+
url: https://s01.oss.sonatype.org/service/local
48+
applyMavenCentralRules: true
49+
stagingRepositories:
50+
- target/staging-deploy
51+
closeRepository: true
52+
releaseRepository: true

0 commit comments

Comments
 (0)