-
Notifications
You must be signed in to change notification settings - Fork 2
123 lines (111 loc) · 3.74 KB
/
commit-stage.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
name: Commit Stage
on:
push:
branches:
- main
paths-ignore:
- '.editorconfig'
- '.gitignore'
- '.sdkmanrc'
- '*.adoc'
- '*.png'
- '*.md'
- 'docs/**'
- '.github/ISSUE_TEMPLATE/**'
- '.github/*.md'
- '.github/*.yml'
- '.github/*.yaml'
pull_request:
branches:
- main
paths-ignore:
- '.editorconfig'
- '.gitignore'
- '.sdkmanrc'
- '*.adoc'
- '*.png'
- '*.md'
- 'docs/**'
- '.github/ISSUE_TEMPLATE/**'
- '.github/*.md'
- '.github/*.yml'
- '.github/*.yaml'
permissions:
contents: read
jobs:
build:
name: Build
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- name: Check out source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Set up Java
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
java-version: 21
distribution: temurin
- name: Setup Gradle
uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2
- name: Compile and test
run: ./gradlew build -Dorg.gradle.parallel=false
- name: Generate SBOMs
run: ./gradlew cyclonedxBom
- name: Stage artifacts to local directory
if: ${{ github.ref == 'refs/heads/main' }}
run: ./gradlew publish
- name: Define environment variables for Java project
if: ${{ github.ref == 'refs/heads/main' }}
run: |
GROUP=$(./gradlew properties | grep 'group:' | awk '{print $2}')
echo "GROUP=$GROUP" >> $GITHUB_ENV
echo "group: $GROUP"
VERSION=$(./gradlew properties | grep 'version:' | awk '{print $2}')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "version: $VERSION"
- name: Release
if: ${{ github.ref == 'refs/heads/main' }}
uses: jreleaser/release-action@80ffb38fa759704eed4db5c7fcaae3ac1079473e # v2
with:
arguments: full-release
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
JRELEASER_DEPLOY_MAVEN_NEXUS2_CENTRAL_USERNAME: ${{ secrets.JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME }}
JRELEASER_DEPLOY_MAVEN_NEXUS2_CENTRAL_TOKEN: ${{ secrets.JRELEASER_NEXUS2_MAVEN_CENTRAL_TOKEN }}
JRELEASER_PROJECT_JAVA_GROUP_ID: ${{ env.GROUP }}
JRELEASER_PROJECT_VERSION: ${{ env.VERSION }}
- name: Upload JReleaser output
if: always()
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
retention-days: 1
name: jreleaser-output
path: |
out/jreleaser/trace.log
out/jreleaser/output.properties
# - name: Deploy and release artifacts
# if: ${{ github.ref == 'refs/heads/main' }}
# run: |
# VERSION=$(./gradlew properties | grep 'version:' | awk '{print $2}')
# if [[ $VERSION == *"SNAPSHOT"* ]]; then
# ./gradlew jreleaserDeploy
# else
# ./gradlew jreleaserFullRelease
# fi
# env:
#
# - name: Upload JReleaser output
# if: always()
# uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
# with:
# retention-days: 1
# name: jreleaser-output
# path: |
# build/jreleaser/trace.log
# build/jreleaser/output.properties