-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (130 loc) · 4.53 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true
type: string
permissions:
actions: write
id-token: write
contents: write
concurrency:
# On master, we don't want any jobs cancelled so the sha is used to name the group
# On PR branches, we cancel the job if new commits are pushed
# More info: https://stackoverflow.com/a/68422069/253468
group: ${{ (github.ref == 'refs/heads/master') && format('{0}-{1}', github.workflow_ref, github.sha) || format('{0}-{1}', github.workflow_ref, github.head_ref) }}
cancel-in-progress: true
env:
JAVA_VERSION: '21'
JAVA_DISTRO: 'adopt'
jobs:
determine-version:
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.vars.outputs.VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get or Set Version
id: vars
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ inputs.version }}" ]]; then
echo "Setting version from input: ${{ inputs.version }}"
echo "${{ inputs.version }}" > VERSION
sed -i "s/^version=.*/version=${{ inputs.version }}/" gradle.properties
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -am "Set version to ${{ inputs.version }}"
git push origin main
VERSION=${{ inputs.version }}
else
VERSION=$(awk -F'=' '/^version=/ {print $2}' gradle.properties)
echo "Detected version: $VERSION"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
build:
needs:
- determine-version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Project Version
run: |
VERSION=$(awk -F'=' '/^version=/ {print $2}' gradle.properties)
echo "Project version: $VERSION"
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRO }}
java-version: ${{ env.JAVA_VERSION }}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Build with Gradle
run: ./gradlew -q --no-daemon --scan build
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure()
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
- name: Sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: ${{ !cancelled() && env.SONAR_TOKEN != '' }}
run: ./gradlew sonar -Dsonar.gradle.skipCompile=true
release:
if: github.event_name != 'pull_request'
needs:
- determine-version
- build
runs-on: ubuntu-latest
env:
JRELEASER_PROJECT_VERSION: ${{ needs.determine-version.outputs.VERSION }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.JRELEASER_MAVENCENTRAL_TOKEN }}
USERNAME: ${{ secrets.USERNAME }}
TOKEN: ${{ secrets.TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Project Version
run: |
VERSION=$(awk -F'=' '/^version=/ {print $2}' gradle.properties)
echo "Project version: $VERSION"
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRO }}
java-version: ${{ env.JAVA_VERSION }}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Publish with Gradle
run: ./gradlew -q --no-daemon --scan publish
- name: Release with Gradle
run: ./gradlew -q --no-daemon --scan jreleaserFullRelease --no-configuration-cache --full-stacktrace