-
Notifications
You must be signed in to change notification settings - Fork 1.9k
96 lines (94 loc) · 4.67 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
91
92
93
94
95
96
name: Maven Release
on:
workflow_dispatch:
inputs:
releaseVersion:
type: string
required: true
description: The POM release version of this release. Must be a semantic version of the form X.Y.Z.
nextDevelopmentVersion:
type: string
required: true
description: The next POM development version after the release is done. Must be of the form X.Y.${Z+1}-SNAPSHOT
dry-run:
type: boolean
required: true
description: Dry run, will not push branches or upload the artifacts.
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Validate Input
run: |
echo "${{ github.ref_type }}" | perl -ne 'die unless m/^branch$/'
echo "${{ github.ref_name }}" | perl -ne 'die unless m/^release-legacy-\d+$/'
echo "${{ github.event.inputs.releaseVersion }}" | perl -ne 'die unless m/^\d+\.\d+\.\d+-legacy$/'
echo "${{ github.event.inputs.nextDevelopmentVersion }}" | perl -ne 'die unless m/^\d+\.\d+\.\d+-legacy-SNAPSHOT$/'
- name: Checkout
uses: actions/checkout@v4
- name: Check Actor
run: |
# Release actor should be in the OWNER list
cat OWNERS | grep ${{ github.actor }}
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17.0.x
server-id: ossrh
server-username: OSSRH_USERNAME
server-password: OSSRH_TOKEN
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Prepare
run: |
export GPG_TTY=$(tty)
(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
(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
git config user.email "[email protected]"
git config user.name "Kubernetes Publisher"
- name: Check Current Version
run: |
mvn -q \
-Dexec.executable=echo \
-Dexec.args='${project.version}' \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
--non-recursive \
exec:exec | perl -ne 'die unless m/${{ github.event.inputs.releaseVersion }}-SNAPSHOT/'
- name: Release Prepare
run: |
git checkout -b 'automated-release-${{ github.event.inputs.releaseVersion }}'
mvn --batch-mode \
release:prepare \
-Dtag=v${{ github.event.inputs.releaseVersion }} \
-DconnectionUrl=https://${{ github.token }}@github.com/${{ github.repository }}.git \
-DreleaseVersion=${{ github.event.inputs.releaseVersion }} \
-DdevelopmentVersion=${{ github.event.inputs.nextDevelopmentVersion }} \
-DpushChanges=false \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
- name: Release Perform
if: ${{ github.event.inputs.dry-run != 'true' }}
env:
OSSRH_USERNAME: ${{ secrets.SNAPSHOT_UPLOAD_USER }}
OSSRH_TOKEN: ${{ secrets.SNAPSHOT_UPLOAD_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSWORD }}
run: |
# The tests are already executed in the prepare, skipping
mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -DlocalCheckout=true -Darguments=-DskipTests release:perform
git push https://${{ github.token }}@github.com/${{ github.repository }}.git \
automated-release-${{ github.event.inputs.releaseVersion }}:automated-release-${{ github.event.inputs.releaseVersion }}
git push https://${{ github.token }}@github.com/${{ github.repository }}.git v${{ github.event.inputs.releaseVersion }}
- name: Pull Request
if: ${{ github.event.inputs.dry-run != 'true' }}
uses: repo-sync/pull-request@v2
with:
source_branch: automated-release-${{ github.event.inputs.releaseVersion }}
destination_branch: ${{ github.ref_name }}
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: "Automated Release: ${{ github.event.inputs.releaseVersion }}"
- name: Publish Release
if: ${{ github.event.inputs.dry-run != 'true' }}
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ github.event.inputs.releaseVersion }}