Repository navigation
74 lines (67 loc) · 2.22 KB
/
Copy pathpublish.yml
File metadata and controls
74 lines (67 loc) · 2.22 KB
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
name: Publish
on:
push:
branches:
- 'main'
tags:
- 'v*'
permissions:
contents: read
concurrency:
group: publish
cancel-in-progress: false
jobs:
publish:
name: Publish to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Amazon Corretto 25
uses: actions/setup-java@v6
with:
distribution: 'corretto'
java-version: '25'
cache: 'maven'
server-id: 'github'
server-username-env-var: 'GITHUB_ACTOR'
server-password-env-var: 'GITHUB_TOKEN'
# Branch builds are immutable release-candidate prereleases; tag builds use the tag version.
# Neither path may produce a Maven SNAPSHOT version.
- name: Resolve version
id: version
run: |
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
REVISION="${GITHUB_REF_NAME#v}"
SHA1=""
else
REVISION="$(./mvnw --batch-mode --quiet --no-transfer-progress -N help:evaluate -Dexpression=revision -DforceStdout)-rc"
SHA1=".${GITHUB_SHA::12}"
fi
CHANGELIST=""
VERSION="${REVISION}${SHA1}${CHANGELIST}"
case "${VERSION}" in
*-SNAPSHOT|*-snapshot)
echo "::error::refusing to publish Maven SNAPSHOT version ${VERSION}"
exit 1
;;
esac
echo "revision=${REVISION}" >> "$GITHUB_OUTPUT"
echo "sha1=${SHA1}" >> "$GITHUB_OUTPUT"
echo "changelist=${CHANGELIST}" >> "$GITHUB_OUTPUT"
echo "Publishing ${VERSION} to GitHub Packages"
# Build and test the full reactor before deployAtEnd publishes anything.
- name: Publish to GitHub Packages
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./mvnw --batch-mode clean deploy \
-Prelease \
-DdeployAtEnd=true \
-Drevision="${{ steps.version.outputs.revision }}" \
-Dsha1="${{ steps.version.outputs.sha1 }}" \
-Dchangelist="${{ steps.version.outputs.changelist }}"