-
Notifications
You must be signed in to change notification settings - Fork 12
83 lines (68 loc) · 2.29 KB
/
publish.yaml
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
name: Publish YOJ
on:
push:
tags:
- 'v*'
jobs:
validate:
name: Validate YOJ
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
- name: Extract SDK versions
run: |
YOJ_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "YOJ_VERSION=$YOJ_VERSION" >> "$GITHUB_ENV"
- name: Fail workflow if SDK version is snapshot
if: endsWith(env.YOJ_VERSION, 'SNAPSHOT')
uses: actions/github-script@v7
with:
script: core.setFailed('SNAPSHOT version cannot be published')
- name: Fail workflow if SDK version is not equal to tag name
if: format('v{0}', env.YOJ_VERSION) != github.ref_name
uses: actions/github-script@v7
with:
script: core.setFailed('Release name must be equal to project version')
- name: Download dependencies
run: mvn $MAVEN_ARGS dependency:go-offline
- name: Build with Maven
run: mvn $MAVEN_ARGS package
publish:
name: Publish YOJ
runs-on: ubuntu-latest
needs: validate
env:
MAVEN_ARGS: --batch-mode --no-transfer-progress -Dstyle.color=always
steps:
- name: Install gpg secret key
run: |
# Install gpg secret key
cat <(echo -e "${{ secrets.MAVEN_OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
# Verify gpg secret key
gpg --list-secret-keys --keyid-format LONG
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
server-id: ossrh-s01
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Publish package
run: |
mvn $MAVEN_ARGS -Possrh-s01 -Plombok -Dgpg.passphrase=${{ secrets.MAVEN_OSSRH_GPG_PASSWORD }} clean deploy
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_OSSRH_TOKEN }}