Skip to content

Commit cc0a25a

Browse files
author
Julien Ruaux
committed
feat: added maven and docker workflows
1 parent 9b0735c commit cc0a25a

File tree

3 files changed

+225
-0
lines changed

3 files changed

+225
-0
lines changed

.github/workflows/build-maven.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
java-version:
7+
default: '11'
8+
required: false
9+
type: string
10+
11+
jobs:
12+
build:
13+
name: Build
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Set up Java
20+
uses: actions/setup-java@v3
21+
with:
22+
java-version: ${{ inputs.java-version }}
23+
distribution: 'zulu'
24+
25+
- name: Cache Maven
26+
uses: actions/cache@v3
27+
with:
28+
path: ~/.m2/repository
29+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
30+
restore-keys: |
31+
${{ runner.os }}-maven-
32+
33+
- name: Build
34+
run: ./mvnw -B package --file pom.xml
35+
36+
- name: Upload test reports
37+
if: failure()
38+
uses: actions/upload-artifact@v3
39+
with:
40+
name: test-reports
41+
path: target/

.github/workflows/docker.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: 'Early Access'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
tags:
7+
required: true
8+
type: string
9+
platforms:
10+
default: 'linux/amd64,linux/arm64'
11+
required: false
12+
type: string
13+
secrets:
14+
github-token:
15+
required: true
16+
docker-username:
17+
required: true
18+
docker-password:
19+
required: true
20+
21+
jobs:
22+
docker:
23+
name: 'Docker'
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Cancel previous run
27+
uses: styfle/cancel-workflow-action@0.11.0
28+
with:
29+
access_token: ${{ secrets.github-token }}
30+
31+
- name: Checkout
32+
uses: actions/checkout@v3
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Set up QEMU
37+
uses: docker/setup-qemu-action@v2
38+
39+
- name: Set up Docker Buildx
40+
uses: docker/setup-buildx-action@v2
41+
42+
- name: Login to DockerHub
43+
uses: docker/login-action@v2
44+
with:
45+
username: ${{ secrets.docker-username }}
46+
password: ${{ secrets.docker-password }}
47+
48+
- name: Build and push
49+
uses: docker/build-push-action@v3
50+
with:
51+
push: ${{ github.event_name != 'pull_request' }}
52+
tags: ${{ inputs.tags }}
53+
platforms: ${{ inputs.platforms }}
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Release
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
branch:
7+
default: 'master'
8+
required: false
9+
type: string
10+
version:
11+
required: true
12+
type: string
13+
jreleaser-version:
14+
default: 'early-access'
15+
required: false
16+
type: string
17+
java-version:
18+
default: '11'
19+
required: false
20+
type: string
21+
secrets:
22+
github-token:
23+
required: true
24+
gpg-passphrase:
25+
required: true
26+
gpg-public-key:
27+
required: true
28+
gpg-secret-key:
29+
required: true
30+
docker-username:
31+
required: false
32+
docker-password:
33+
required: false
34+
sonatype-username:
35+
required: false
36+
sonatype-password:
37+
required: false
38+
slack-webhook:
39+
required: false
40+
41+
jobs:
42+
release:
43+
name: Release
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Cancel previous run
47+
uses: styfle/cancel-workflow-action@0.11.0
48+
with:
49+
access_token: ${{ secrets.github-token }}
50+
51+
- name: Checkout
52+
uses: actions/checkout@v3
53+
with:
54+
ref: ${{ inputs.branch }}
55+
fetch-depth: 0
56+
57+
- name: Set up Java
58+
uses: actions/setup-java@v3
59+
with:
60+
java-version: ${{ inputs.java-version }}
61+
distribution: 'zulu'
62+
63+
- name: Cache Maven
64+
uses: actions/cache@v3
65+
with:
66+
path: ~/.m2/repository
67+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
68+
restore-keys: |
69+
${{ runner.os }}-maven-
70+
71+
- name: Set release version
72+
run: |
73+
VERSION=${{ github.event.inputs.version }}
74+
./mvnw versions:set -DnewVersion=$VERSION
75+
76+
- name: Build
77+
run: |
78+
./mvnw --no-transfer-progress -B --file pom.xml verify
79+
80+
- name: Upload test reports
81+
if: failure()
82+
uses: actions/upload-artifact@v3
83+
with:
84+
name: test-reports
85+
path: target/
86+
87+
- name: Assemble
88+
uses: jreleaser/release-action@v2
89+
with:
90+
arguments: assemble
91+
version: ${{ inputs.jreleaser-version }}
92+
env:
93+
JRELEASER_PROJECT_VERSION: ${{ inputs.version }}
94+
95+
- name: Release
96+
uses: jreleaser/release-action@v2
97+
with:
98+
arguments: full-release
99+
version: ${{ inputs.jreleaser-version }}
100+
env:
101+
JRELEASER_PROJECT_VERSION: ${{ inputs.version }}
102+
JRELEASER_GITHUB_TOKEN: ${{ secrets.github-token }}
103+
JRELEASER_BRANCH: ${{ inputs.branch }}
104+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.gpg-passphrase }}
105+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.gpg-public-key }}
106+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.gpg-secret-key }}
107+
JRELEASER_DOCKER_DEFAULT_USERNAME: ${{ secrets.docker-username }}
108+
JRELEASER_DOCKER_DEFAULT_PASSWORD: ${{ secrets.docker-password }}
109+
JRELEASER_NEXUS2_USERNAME: ${{ secrets.sonatype-username }}
110+
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.sonatype-password }}
111+
JRELEASER_SLACK_WEBHOOK: ${{ secrets.slack-webhook }}
112+
113+
- name: JReleaser output
114+
if: always()
115+
uses: actions/upload-artifact@v3
116+
with:
117+
name: artifact
118+
path: |
119+
out/jreleaser/trace.log
120+
out/jreleaser/output.properties
121+
122+
- name: Commit release version
123+
run: |
124+
VERSION=${{ github.event.inputs.version }}
125+
sed -i -e "s/^\:project-version\:\ \ \ \ .*/:project-version: $VERSION/g" README.adoc
126+
git add pom.xml
127+
git add README.adoc
128+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
129+
git config --global user.name "GitHub Action"
130+
git commit -a -m "Releasing version $VERSION"
131+
git push origin ${{ github.event.inputs.ref }}

0 commit comments

Comments
 (0)