Repository navigation
120 lines (118 loc) · 5.76 KB
/
Copy pathrelease.yml
File metadata and controls
120 lines (118 loc) · 5.76 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
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. (For cutting legacy release, use format X.Y.Z-legacy)
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. (For cutting legacy release, use format X.Y.${Z+1}-legacy-SNAPSHOT)
dry-run:
type: boolean
required: true
description: Dry run, will not push branches or upload the artifacts.
jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
env:
BAZELISK_SKIP_VERSION_CHECK: "1"
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-\d+$/'
echo "${{ github.event.inputs.releaseVersion }}" | perl -ne 'die unless m/^\d+\.\d+\.\d+$/'
echo "${{ github.event.inputs.nextDevelopmentVersion }}" | perl -ne 'die unless m/^\d+\.\d+\.\d+-SNAPSHOT$/'
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
token: ${{ github.token }}
- name: Check Actor
run: |
# Release actor should be in the OWNER list
cat OWNERS | grep ${{ github.actor }}
- name: Setup Java
uses: actions/setup-java@77dd5b2ce225ea11469928ac317850245a74ae78 # v6.2.0
with:
distribution: 'temurin'
java-version: 17.0.x
cache: maven
server-id: central
server-username: CENTRAL_USERNAME
server-password: CENTRAL_TOKEN
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Install Bazelisk
run: |
mkdir -p "$HOME/.local/bin"
curl -fsSL \
https://github.com/bazelbuild/bazelisk/releases/download/v1.24.1/bazelisk-linux-amd64 \
-o "$HOME/.local/bin/bazel"
chmod +x "$HOME/.local/bin/bazel"
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Restore Bazel caches
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cache/bazel-disk-cache
~/.cache/bazel/cache/repos/v1
key: bazel-${{ runner.os }}-release-${{ hashFiles('MODULE.bazel', '.bazelversion', 'maven_install.json') }}
restore-keys: |
bazel-${{ runner.os }}-release-
bazel-${{ runner.os }}-
- name: Bazel Build
run: bazel build --config=ci //...
- name: Bazel Test
run: bazel test --config=ci //...
- 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 "k8s-publishing-bot@users.noreply.github.com"
git config user.name "Kubernetes Publisher"
- name: Check Current Version
run: |
./mvnw -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 }}'
./mvnw --batch-mode \
org.apache.maven.plugins:maven-release-plugin: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 \
-Darguments=-DskipTests \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
- name: Release Perform
if: ${{ github.event.inputs.dry-run != 'true' }}
env:
CENTRAL_USERNAME: ${{ secrets.SNAPSHOT_UPLOAD_USER }}
CENTRAL_TOKEN: ${{ secrets.SNAPSHOT_UPLOAD_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSWORD }}
run: |
# The tests are already executed in the prepare, skipping
./mvnw -s /home/runner/.m2/settings.xml -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -DlocalCheckout=true -Darguments=-DskipTests org.apache.maven.plugins:maven-release-plugin: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: Publish Release
if: ${{ github.event.inputs.dry-run != 'true' }}
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create v${{ github.event.inputs.releaseVersion }} \
--title "v${{ github.event.inputs.releaseVersion }}" \
--generate-notes