Repository navigation
108 lines (94 loc) · 3.89 KB
/
Copy pathrelease.yml
File metadata and controls
108 lines (94 loc) · 3.89 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
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
name: Release
on:
workflow_dispatch:
inputs:
releaseVersion:
description: "Release version, e.g. 0.0.2 (optional — auto-detected from the current POM)"
required: false
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write # to push the release commits and tag
steps:
- name: Validate release version
if: ${{ github.event.inputs.releaseVersion != '' }}
run: |
RELEASE=${{ github.event.inputs.releaseVersion }}
if [[ ! $RELEASE =~ ^[0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT)?$ ]]; then
echo "Error: releaseVersion '$RELEASE' is not in the correct format x.y.z or x.y.z-SNAPSHOT"
exit 1
fi
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
# Imports the signing key. Equivalent to setup-java's gpg-private-key input, but also
# accepts a secret that holds the ASCII-armored key without its BEGIN/END lines.
- name: Import GPG key
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
KEY_FILE=$(mktemp)
printf '%s\n' "$GPG_PRIVATE_KEY" > "$KEY_FILE"
if ! grep -q -- '-----BEGIN PGP PRIVATE KEY BLOCK-----' "$KEY_FILE"; then
echo "GPG_PRIVATE_KEY has no armor header; adding BEGIN/END lines"
{ echo '-----BEGIN PGP PRIVATE KEY BLOCK-----'
if ! head -1 "$KEY_FILE" | grep -q ':'; then echo; fi
cat "$KEY_FILE"
echo '-----END PGP PRIVATE KEY BLOCK-----'; } > "$KEY_FILE.asc"
mv "$KEY_FILE.asc" "$KEY_FILE"
fi
gpg --batch --import "$KEY_FILE"
rm -f "$KEY_FILE"
gpg --list-secret-keys --keyid-format long | grep -c '^sec' | xargs echo "secret keys imported:"
- name: Configure git
run: |
git config user.email "actions@github.com"
git config user.name "GitHub Actions"
- name: Prepare Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
MVN_ARGS=""
if [ -n "${{ github.event.inputs.releaseVersion }}" ]; then
MVN_ARGS="$MVN_ARGS -DreleaseVersion=${{ github.event.inputs.releaseVersion }}"
fi
./mvnw -B release:prepare $MVN_ARGS
- name: Check release.properties
run: |
if [ ! -f release.properties ]; then
echo "release.properties not found"
exit 1
fi
echo "Contents of release.properties:"
cat release.properties
- name: Determine release version
id: version
run: |
export TAG=$(grep 'scm.tag=' release.properties | cut -d'=' -f2)
export VERSION=${TAG#v}
echo "released_tag=${TAG}" >> $GITHUB_OUTPUT
echo "released_version=${VERSION}" >> $GITHUB_OUTPUT
echo "Releasing tag: ${TAG}"
echo "Releasing version: ${VERSION}"
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
MAVEN_GPG_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
run: |
./mvnw -B release:perform -Darguments="-DskipTests -DaltDeploymentRepository=id::default::njord: -Dnjord.autoPublish=true -Dnjord.publishingType=automatic" -s .github/release-settings.xml
- name: Create GitHub Release
run: gh release create "${{ steps.version.outputs.released_tag }}" --generate-notes --title "Version ${{ steps.version.outputs.released_version }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}