Skip to content

Commit 9c9e97a

Browse files
committed
ci: remake workflows from scratch
- Publishes release on dispatch - Publishes snapshot or jar files on push - Testing
1 parent e3dc75d commit 9c9e97a

3 files changed

Lines changed: 88 additions & 51 deletions

File tree

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,40 @@
11
name: Release
22

33
on:
4-
push:
5-
branches:
6-
- 'main'
7-
- 'master'
84
workflow_dispatch:
95

6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
1010
permissions:
1111
contents: write
1212
discussions: write
1313
pull-requests: write
1414

1515
jobs:
1616
tests:
17-
name: Run Tests
17+
name: Tests
1818
uses: ./.github/workflows/tests.yml
19-
secrets: inherit
20-
with:
21-
publish_snapshot: false
2219
release:
23-
name: Create Release
20+
name: Build
21+
needs: [tests]
2422
strategy:
2523
matrix:
2624
os: [ubuntu-latest]
2725
java: [8]
2826
runs-on: ${{ matrix.os }}
29-
concurrency:
30-
group: ${{ github.workflow }}-${{ github.ref }}
31-
cancel-in-progress: true
32-
needs: [tests]
3327
steps:
3428
# Checkout repository
3529
- name: Checkout Repository
3630
uses: actions/checkout@v4
37-
38-
# Setup JDK
31+
32+
# Build setup
3933
- name: Setup JDK
4034
uses: ./.github/actions/jdk
4135
with:
4236
java-version: ${{ matrix.java }}
4337

44-
# Setup Gradle & Verify wrapper
4538
- name: Setup Gradle
4639
uses: ./.github/actions/gradle
4740

@@ -51,14 +44,14 @@ jobs:
5144
with:
5245
github-token: ${{ secrets.GITHUB_TOKEN }}
5346
default-bump: patch
54-
55-
# Build with Gradle & Publish to Maven repository
56-
- name: Build with Gradle
57-
run: ./gradlew clean build publishAllPublicationsToReleasesRepository -PcustomVersion=${{ steps.version.outputs.version }}
47+
48+
# Build and upload to Maven
49+
- name: Build with Gradle & Publish to Maven
50+
run: ./gradlew clean build publishAllPublicationsToReleasesRepository -PcustomVersion=${{ steps.version.outputs.version }} --info
5851
env:
5952
MAVEN_USERNAME: ${{ secrets.MAVEN_NAME }}
6053
MAVEN_PASSWORD: ${{ secrets.MAVEN_SECRET }}
61-
54+
6255
# Generate changelog
6356
- name: Changelog
6457
uses: ardalanamini/auto-changelog@v4
@@ -91,11 +84,12 @@ jobs:
9184
- name: Create Release
9285
uses: softprops/action-gh-release@v2
9386
with:
87+
name: ${{ steps.version.outputs.version-with-prefix }}
88+
tag_name: ${{ steps.version.outputs.version }}
89+
generate_release_notes: false
90+
body: ${{ steps.changelog.outputs.changelog }}
9491
files: |
9592
${{ github.workspace }}/build/libs/*
9693
token: ${{ secrets.GITHUB_TOKEN }}
97-
tag_name: ${{ steps.version.outputs.version-with-prefix }}
9894
draft: false
99-
prerelease: ${{ contains(github.ref_name, '-RC-') }}
100-
generate_release_notes: false
101-
body: ${{ steps.changelog.outputs.changelog }}
95+
prerelease: ${{ contains(github.ref_name, '-RC-') }}

.github/workflows/snapshots.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Snapshot
2+
3+
on:
4+
push:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
permissions:
11+
contents: write
12+
discussions: write
13+
pull-requests: write
14+
15+
jobs:
16+
tests:
17+
name: Tests
18+
uses: ./.github/workflows/tests.yml
19+
snapshot:
20+
name: Build
21+
needs: [tests]
22+
strategy:
23+
matrix:
24+
os: [ubuntu-latest]
25+
java: [8]
26+
runs-on: ${{ matrix.os }}
27+
steps:
28+
# Checkout repository
29+
- name: Checkout Repository
30+
uses: actions/checkout@v4
31+
32+
# Build setup
33+
- name: Setup JDK
34+
uses: ./.github/actions/jdk
35+
with:
36+
java-version: ${{ matrix.java }}
37+
38+
- name: Setup Gradle
39+
uses: ./.github/actions/gradle
40+
41+
# Makes the next semantic tag variable available for use in workflow
42+
- uses: jveldboom/action-conventional-versioning@v1
43+
id: version
44+
with:
45+
github-token: ${{ secrets.GITHUB_TOKEN }}
46+
default-bump: patch
47+
48+
# If on main branch, upload snapshot to maven
49+
- name: Build with Gradle & Publish to Maven
50+
if: contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref)
51+
run: ./gradlew clean build publishAllPublicationsToSnapshotsRepository -PcustomVersion=${{ steps.version.outputs.version }}-SNAPSHOT-${{ github.run_number }} --info
52+
env:
53+
MAVEN_USERNAME: ${{ secrets.MAVEN_NAME }}
54+
MAVEN_PASSWORD: ${{ secrets.MAVEN_SECRET }}
55+
56+
# Else if, upload built jar from push
57+
- name: Build with Gradle
58+
if: contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref) == false
59+
run: ./gradlew clean build -PcustomVersion=${{ steps.version.outputs.version }}-SNAPSHOT-${{ github.run_number }} --info
60+
61+
- name: Upload build artifact
62+
uses: actions/upload-artifact@v4
63+
if: contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref) == false
64+
with:
65+
name: Build ${{ steps.version.outputs.version-with-prefix }}-SNAPSHOT-${{ github.run_number }}
66+
path: ${{ github.workspace }}/build/libs/
67+
retention-days: 3

.github/workflows/tests.yml

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
1-
name: Run Tests
1+
name: Tests
22

33
on:
4-
push:
5-
branches-ignore: # Tests are triggered from release workflow
6-
- 'main'
7-
- 'master'
84
workflow_dispatch:
95
workflow_call:
10-
secrets:
11-
MAVEN_NAME:
12-
required: false
13-
MAVEN_PASSWORD:
14-
required: false
15-
inputs:
16-
publish_snapshot:
17-
required: false
18-
default: true
19-
type: boolean
206

217
permissions:
228
contents: write
@@ -25,7 +11,7 @@ permissions:
2511

2612
jobs:
2713
test-build:
28-
name: Test Build
14+
name: Build
2915
strategy:
3016
matrix:
3117
os: [ubuntu-latest]
@@ -53,16 +39,6 @@ jobs:
5339
github-token: ${{ secrets.GITHUB_TOKEN }}
5440
default-bump: patch
5541

56-
5742
# Build with Gradle
5843
- name: Build with Gradle
59-
if: ${{ inputs.publish_snapshot == false }}
6044
run: ./gradlew clean build -PcustomVersion=${{ steps.version.outputs.version }}-SNAPSHOT-${{ github.run_number }} --info
61-
62-
# Build with Gradle
63-
- name: Build with Gradle
64-
if: ${{ inputs.publish_snapshot == true }}
65-
run: ./gradlew clean build publishAllPublicationsToSnapshotsRepository -PcustomVersion=${{ steps.version.outputs.version }}-SNAPSHOT-${{ github.run_number }} --info
66-
env:
67-
MAVEN_USERNAME: ${{ secrets.MAVEN_NAME }}
68-
MAVEN_PASSWORD: ${{ secrets.MAVEN_SECRET }}

0 commit comments

Comments
 (0)