Skip to content

Commit 894b3fb

Browse files
authored
Merge pull request #2065 from yue9944882/cherrypick-release-14-release-job
Cherrypick(release-14): Adding a release job receiving manual input
2 parents 6e35257 + 293a34d commit 894b3fb

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed

.github/workflows/release.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Maven Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
releaseVersion:
7+
type: string
8+
required: true
9+
description: The POM release version of this release.
10+
nextDevelopmentVersion:
11+
type: string
12+
required: true
13+
description: The next POM development version with suffix "-SNAPSHOT", will be the next development version after the release is done.
14+
dry-run:
15+
type: boolean
16+
required: true
17+
description: Dry run, will not push branches or upload the artifacts.
18+
19+
jobs:
20+
release:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Validate Input
24+
run: |
25+
echo "${{ github.ref_type }}" | perl -ne 'die unless m/^branch$/'
26+
echo "${{ github.ref_name }}" | perl -ne 'die unless m/^release-\d+$/'
27+
echo "${{ github.event.inputs.releaseVersion }}" | perl -ne 'die unless m/^\d+\.\d+\.\d+$/'
28+
echo "${{ github.event.inputs.nextDevelopmentVersion }}" | perl -ne 'die unless m/^\d+\.\d+\.\d+-SNAPSHOT$/'
29+
- name: Checkout
30+
uses: actions/checkout@v2
31+
- name: Check Actor
32+
run: |
33+
# Release actor should be in the OWNER list
34+
cat OWNERS | grep ${{ github.actor }}
35+
- name: Setup Java
36+
uses: actions/setup-java@v2
37+
with:
38+
distribution: 'temurin'
39+
java-version: 8.0.x
40+
server-id: ossrh
41+
server-username: OSSRH_USERNAME
42+
server-password: OSSRH_TOKEN
43+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
44+
gpg-passphrase: GPG_PASSPHRASE
45+
- name: Prepare
46+
run: |
47+
export GPG_TTY=$(tty)
48+
(echo 5; echo y; echo save) | gpg --command-fd 0 --no-tty --pinentry-mode loopback --passphrase ${{ secrets.GPG_PASSWORD }} --no-greeting --edit-key 'Kubernetes Client Publishers' trust
49+
(echo 0; echo y; echo save) | gpg --command-fd 0 --no-tty --pinentry-mode loopback --passphrase ${{ secrets.GPG_PASSWORD }} --no-greeting --edit-key 'Kubernetes Client Publishers' expire
50+
git config user.email "[email protected]"
51+
git config user.name "Kubernetes Prow Robot"
52+
- name: Check Current Version
53+
run: |
54+
mvn -q \
55+
-Dexec.executable=echo \
56+
-Dexec.args='${project.version}' \
57+
--non-recursive \
58+
exec:exec | perl -ne 'die unless m/${{ github.event.inputs.releaseVersion }}-SNAPSHOT/'
59+
- name: Release Prepare
60+
run: |
61+
mvn --batch-mode \
62+
release:prepare \
63+
-Dtag=v${{ github.event.inputs.releaseVersion }} \
64+
-DconnectionUrl=https://${{ github.token }}@github.com/${{ github.repository }}.git \
65+
-DreleaseVersion=${{ github.event.inputs.releaseVersion }} \
66+
-DdevelopmentVersion=${{ github.event.inputs.nextDevelopmentVersion }} \
67+
-DpushChanges=false
68+
- name: Release Perform
69+
if: ${{ github.event.inputs.dry-run != 'true' }}
70+
env:
71+
OSSRH_USERNAME: ${{ secrets.SNAPSHOT_UPLOAD_USER }}
72+
OSSRH_TOKEN: ${{ secrets.SNAPSHOT_UPLOAD_PASSWORD }}
73+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSWORD }}
74+
run: |
75+
# The tests are already executed in the prepare, skipping
76+
mvn -DlocalCheckout=true -Darguments=-DskipTests release:perform
77+
git push https://${{ github.token }}@github.com/${{ github.repository }}.git ${{ github.ref_name }}:${{ github.ref_name }}
78+
git push https://${{ github.token }}@github.com/${{ github.repository }}.git v${{ github.event.inputs.releaseVersion }}
79+
- name: Publish Release
80+
if: ${{ github.event.inputs.dry-run != 'true' }}
81+
uses: ncipollo/release-action@v1
82+
with:
83+
token: ${{ secrets.GITHUB_TOKEN }}
84+
tag: v${{ github.event.inputs.releaseVersion }}

RELEASES.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,55 @@ Releases are done on an as-needed basis, and this doc applies only to
1010
This does _not_ describe the process of cherry-picking changes onto release
1111
branches.
1212

13+
## Release via Github Action
14+
15+
Maintainers meet the following requirements will be able to perform automated
16+
release to maven central via Github Action job named "Maven Release":
17+
18+
* Has "collaborator" permission or greater access (otherwise the can't run the
19+
job manually).
20+
* Should be in the OWNERS file.
21+
22+
### Steps
23+
24+
#### Make sure the release job runs on the release branch
25+
26+
When cutting the next major release, firstly we need to fork out a new release
27+
branch named `release-<major>`. So the release job will execute the maven
28+
release plugin and push generated releasing commits to the release branch
29+
if the `release:prepare` process finishes successfully. Note that if we're
30+
bumping a new patch version from an existing release branch, this step can be
31+
omitted.
32+
33+
#### Filling release job input manually
34+
35+
The github action job will require three manual input:
36+
37+
* The POM releasing version, must be a valid semver `X.Y.Z` (without "v" prefix).
38+
* The next development POM version, conventionally we should bump a patch
39+
version from the current release version and add a `-SNAPSHOT` suffix. i.e.
40+
`X.Y.(Z+1)-SNAPSHOT`.
41+
* Dry-Run: Indicating whether the release job will push the generated release
42+
commits to the release branch and actually upload the artifacts.
43+
44+
Filling the inputs, then click "Run" to start the job.
45+
46+
> Note that during the release process, no commits shall be added the release
47+
> branch.
48+
49+
#### Release note, announcements
50+
51+
After the release job successfully finishes, we're supposed to see two generated
52+
commits automatically added to the release branch:
53+
54+
1. Bump the previous development version to the target release version.
55+
2. Bump the release version to the next development version.
56+
57+
And a git tag `vX.Y.Z` will also be pushed on the commit (1), a GITHUB release
58+
will also be packed on the tag.
59+
60+
In the end, don't forget to clarify the release notes on the GITHUB release.
61+
1362
## One time setup
1463

1564
You will need to have the following in place:

0 commit comments

Comments
 (0)