Repository navigation
136 lines (129 loc) · 5.55 KB
/
Copy pathrelease.yml
File metadata and controls
136 lines (129 loc) · 5.55 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#
# Release workflow
# Calling it:
# name: CI
#
# on:
# workflow_dispatch:
# inputs:
# version:
# description: The version to release (will be inferred from the pom version by default).
# required: false
# next-version:
# description: The next development version (will be inferred from the pom version by default).
# required: false
#
# jobs:
# build:
# name: Verify
# uses: maveniverse/parent/.github/workflows/release.yml@release-29
#
# Secrets:
# - GPG_SIGNING_KEY (private key with armor)
# - GPG_PASSPHRASE (the private key passphrase)
# - GPG_KEY_FINGERPRINT (fingerprint and not hash)
# - MAVEN_USER (token user generated by central.sonatype.org)
# - MAVEN_PASSWORD (token password generated by central.sonatype.org)
#
name: Release
on:
workflow_call:
inputs:
version:
type: string
description: The version to release (will be inferred from the pom version by default).
required: false
next-version:
type: string
description: The next development version (will be inferred from the pom version by default).
required: false
java-version:
type: string
description: The java version to use
required: false
default: 21
distribution:
type: string
description: The java distribution to use.
required: false
default: temurin
jobs:
release:
name: Release to Maven Central
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v6.2.0
with:
# generate settings.xml with the correct values
server-id: sonatype-central-portal # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USER # env variable for username in deploy
server-password: MAVEN_PASSWORD # env variable for token in deploy
distribution: ${{ github.event.inputs.distribution }}
java-version: ${{ github.event.inputs.java-version }}
- uses: crazy-max/ghaction-import-gpg@v7
with:
gpg_private_key: ${{ secrets.GPG_SIGNING_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
fingerprint: ${{ secrets.GPG_KEY_FINGERPRINT }}
- name: Release preparation
id: pre-release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
mavenMajorVersion=$(./mvnw -v -q | cut -d '.' -f 1)
if [[ $mavenMajorVersion == "3" ]] ; then
version=$(./mvnw -q -DforceStdout help:evaluate -N -Dexpression=project.version | sed -rn 's/([^-]+)(-SNAPSHOT|)$/\1/p')
else
version=$(./mvnw -q -DforceStdout --raw-streams help:evaluate -N -Dexpression=project.version | sed -rn 's/([^-]+)(-SNAPSHOT|)$/\1/p')
fi
echo "mavenMajorVersion=$mavenMajorVersion" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
gh extension install valeriobelli/gh-milestone
- name: Release
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
MAVEN_GPG_KEY: ${{ secrets.GPG_SIGNING_KEY }}
MAVEN_GPG_KEY_FINGERPRINT: ${{ secrets.GPG_KEY_FINGERPRINT }}
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
run: |
./mvnw -V -B release:prepare release:perform -Dmaveniverse.release.pushChanges -Darguments="-Dgpg.useagent=false -Dgpg.signer=bc" -DreleaseVersion=${{ github.event.inputs.version }} -DdevelopmentVersion=${{ github.event.inputs.next-version }}
- name: Post release
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
mavenMajorVersion=${{ steps.pre-release.outputs.mavenMajorVersion }}
version=${{ steps.pre-release.outputs.version }}
echo "Trying to find milestone $version"
milestone=$(gh milestone list --json id,title,state --jq "map_values(select(.title == \"${version}\" and .state == \"OPEN\")).[].number")
if [ ! -z "$milestone" ]; then
echo "Found milestone $version, closing it"
gh milestone edit $milestone --state closed
fi
if [[ $mavenMajorVersion == "3" ]] ; then
version=$(./mvnw -q -DforceStdout help:evaluate -N -Dexpression=project.version | sed -rn 's/([^-]+)(-SNAPSHOT|)$/\1/p')
else
version=$(./mvnw -q -DforceStdout --raw-streams help:evaluate -N -Dexpression=project.version | sed -rn 's/([^-]+)(-SNAPSHOT|)$/\1/p')
fi
echo "Preparing development $version"
echo "Trying to find milestone $version"
milestone=$(gh milestone list --json id,title,state --jq "map_values(select(.title == \"${version}\" and .state == \"OPEN\")).[].number")
if [ -z "$milestone" ]; then
echo "Creating milestone $version"
gh milestone create --title $version
fi
if [[ $mavenMajorVersion == "3" ]] ; then
name=$(./mvnw -q -DforceStdout help:evaluate -N -Dexpression=project.name)
else
name=$(./mvnw -q -DforceStdout --raw-streams help:evaluate -N -Dexpression=project.name)
fi
version=${{ steps.pre-release.outputs.version }}
tag=$(git describe --tags --abbrev=0)
echo "Creating release \"$name $version\" from tag $tag"
gh release create $tag --verify-tag --notes-from-tag --title "$version"