Skip to content

Commit 4b60e1e

Browse files
committed
build: Add GH workflows
1 parent 36203d4 commit 4b60e1e

File tree

2 files changed

+185
-0
lines changed

2 files changed

+185
-0
lines changed

.github/workflows/early-access.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Early Access
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
env:
8+
JAVA_VERSION: '11'
9+
JAVA_DISTRO: 'zulu'
10+
11+
jobs:
12+
precheck:
13+
if: github.repository == 'jreleaser/helloworld-java-jlink' && startsWith(github.event.head_commit.message, 'Releasing version') != true
14+
runs-on: ubuntu-latest
15+
outputs:
16+
VERSION: ${{ steps.vars.outputs.VERSION }}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
21+
- name: Cancel previous run
22+
uses: styfle/[email protected]
23+
with:
24+
access_token: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Setup Java
27+
uses: actions/setup-java@v3
28+
with:
29+
java-version: ${{ env.JAVA_VERSION }}
30+
distribution: ${{ env.JAVA_DISTRO }}
31+
32+
- name: Cache local Maven repository
33+
uses: actions/cache@v3
34+
with:
35+
path: ~/.m2/repository
36+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
37+
restore-keys: ${{ runner.os }}-maven-
38+
39+
- name: Version
40+
id: vars
41+
shell: bash
42+
run: |
43+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
44+
echo "VERSION=$(echo $VERSION)" >> $GITHUB_OUTPUT
45+
46+
release:
47+
needs: [ precheck ]
48+
if: endsWith(${{ needs.precheck.outputs.VERSION }}, '-SNAPSHOT')
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v3
53+
with:
54+
fetch-depth: 0
55+
56+
- name: Setup Java
57+
uses: actions/setup-java@v3
58+
with:
59+
java-version: ${{ env.JAVA_VERSION }}
60+
distribution: ${{ env.JAVA_DISTRO }}
61+
62+
- name: Cache Maven
63+
uses: actions/cache@v3
64+
with:
65+
path: ~/.m2/repository
66+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
67+
restore-keys: ${{ runner.os }}-m2
68+
69+
- name: Setup JDKs
70+
run: ./mvnw -ntp -B -q --file pom.xml -Pjdks
71+
72+
- name: Build
73+
run: ./mvnw -ntp -B --file pom.xml verify
74+
75+
- name: Assemble
76+
uses: jreleaser/release-action@v2
77+
with:
78+
arguments: assemble
79+
env:
80+
JRELEASER_PROJECT_VERSION: ${{ needs.precheck.outputs.VERSION }}
81+
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
83+
- name: Release
84+
uses: jreleaser/release-action@v2
85+
with:
86+
arguments: full-release
87+
env:
88+
JRELEASER_PROJECT_VERSION: ${{ needs.precheck.outputs.VERSION }}
89+
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- name: JReleaser output
92+
if: always()
93+
uses: actions/upload-artifact@v3
94+
with:
95+
name: jreleaser-release
96+
path: |
97+
out/jreleaser/trace.log
98+
out/jreleaser/output.properties

.github/workflows/release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version'
8+
required: true
9+
10+
env:
11+
JAVA_VERSION: '11'
12+
JAVA_DISTRO: 'zulu'
13+
14+
jobs:
15+
precheck:
16+
name: Precheck
17+
runs-on: ubuntu-latest
18+
outputs:
19+
VERSION: ${{ steps.vars.outputs.VERSION }}
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v3
23+
24+
- name: Version
25+
id: vars
26+
shell: bash
27+
run: |
28+
VERSION=${{ github.event.inputs.version }}
29+
./mvnw -B versions:set versions:commit -DnewVersion=$VERSION
30+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
31+
git config --global user.name "GitHub Action"
32+
git commit -a -m "Releasing version $VERSION"
33+
git push origin main
34+
35+
release:
36+
needs: [ precheck ]
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v3
41+
with:
42+
ref: main
43+
fetch-depth: 0
44+
45+
- name: Setup Java
46+
uses: actions/setup-java@v3
47+
with:
48+
java-version: ${{ env.JAVA_VERSION }}
49+
distribution: ${{ env.JAVA_DISTRO }}
50+
51+
- name: Cache Maven
52+
uses: actions/cache@v3
53+
with:
54+
path: ~/.m2/repository
55+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
56+
restore-keys: ${{ runner.os }}-m2
57+
58+
- name: Setup JDKs
59+
run: ./mvnw -ntp -B -q --file pom.xml -Pjdks
60+
61+
- name: Build
62+
run: ./mvnw -ntp -B --file pom.xml verify
63+
64+
- name: Assemble
65+
uses: jreleaser/release-action@v2
66+
with:
67+
arguments: assemble
68+
env:
69+
JRELEASER_PROJECT_VERSION: ${{ needs.precheck.outputs.VERSION }}
70+
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
72+
- name: Release
73+
uses: jreleaser/release-action@v2
74+
with:
75+
arguments: full-release
76+
env:
77+
JRELEASER_PROJECT_VERSION: ${{ needs.precheck.outputs.VERSION }}
78+
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
80+
- name: JReleaser output
81+
if: always()
82+
uses: actions/upload-artifact@v3
83+
with:
84+
name: jreleaser-release
85+
path: |
86+
out/jreleaser/trace.log
87+
out/jreleaser/output.properties

0 commit comments

Comments
 (0)