-
Notifications
You must be signed in to change notification settings - Fork 4
90 lines (82 loc) · 2.89 KB
/
release.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
name: Release
permissions:
contents: write
packages: write
on:
workflow_dispatch:
inputs:
releaseType:
type: choice
description: "Release type"
required: true
default: minor
options:
- patch
- minor
- major
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: zulu
- uses: whelk-io/maven-settings-xml-action@v22
with:
servers: >
[
{ "id": "sonatype", "username": "${{ secrets.MVN_REPO_PRIVATE_REPO_USER }}", "password": "${{ secrets.MVN_REPO_PRIVATE_REPO_PASSWORD }}" }
]
- name: set name
run: |
git config --global user.name "release-bot";
git config --global user.email "[email protected]";
- name: add key
run: |
echo "${{ secrets.GPG_KEY }}" | base64 -d > private.key
gpg --batch --import ./private.key
rm ./private.key
gpg --list-secret-keys --keyid-format LONG
- name: Get current development version
id: get_version
run: |
VERSION=$( mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//' )
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Generate versions
id: generate_versions
uses: WyriHaximus/[email protected]
with:
version: ${{ steps.get_version.outputs.version }}
- name: Pick release version
id: pick_release_version
run: |
VERSION=$(
case ${{ github.event.inputs.releaseType }} in
("minor") echo "${{ steps.generate_versions.outputs.minor }}" ;;
("major") echo "${{ steps.generate_versions.outputs.major }}" ;;
("patch") echo "${{ steps.generate_versions.outputs.patch }}" ;;
esac
)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: prepare
run: |
mvn release:prepare -Dusername=${{ secrets.GITHUB_TOKEN }} \
-DreleaseVersion=${{ steps.pick_release_version.outputs.version }} \
-DdevelopmentVersion=${{ steps.pick_release_version.outputs.version }}-SNAPSHOT \
-P sonatype
- name: release
run: |
mvn release:perform -Dusername=${{ secrets.GITHUB_TOKEN }} \
-DreleaseVersion=${{ steps.pick_release_version.outputs.version }} \
-DdevelopmentVersion=${{ steps.pick_release_version.outputs.version }}-SNAPSHOT \
-Darguments="-DskipTests" \
-P sonatype