-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (87 loc) · 3.81 KB
/
Copy pathrelease.yml
File metadata and controls
99 lines (87 loc) · 3.81 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
name: Release
# Sends a deployment to the Maven Central Portal. It is not released automatically: the deployment
# waits in the Portal until someone looks at it and presses publish. A pending deployment can be
# dropped; a released one cannot be unpublished, and that asymmetry is the whole reason for the
# manual step.
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
version:
description: 'Version to publish, for example 0.0.1-alpha.1'
required: true
type: string
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install tmux
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y tmux
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '21'
- uses: gradle/actions/setup-gradle@v6
with:
validate-wrappers: true
# A tag names the version; a manual run states it. Either way it is passed in rather than
# committed, so no commit ever carries a release version in gradle.properties.
- name: Work out the version
id: version
env:
REF_NAME: ${{ github.ref_name }}
INPUT_VERSION: ${{ inputs.version }}
run: |
if [ -n "$INPUT_VERSION" ]; then
version="$INPUT_VERSION"
else
version="${REF_NAME#v}"
fi
# Validated rather than trusted. This value reaches a command line, and a tag name is
# whatever the person pushing the tag typed; anything outside this shape is not a version
# this project publishes. It also catches the spellings Maven orders wrongly — see
# RELEASING.md for why 0.0.1-a.1 sorts after 0.0.1.
case "$version" in
*-SNAPSHOT) echo "::error::refusing to release a snapshot: $version"; exit 1 ;;
esac
printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|milestone|rc)\.[0-9]+)?$' || {
echo "::error::not a version this project publishes: $version"
exit 1
}
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "releasing $version"
# The gate runs before anything is uploaded. A deployment can be dropped, but a broken one
# should never get as far as needing to be.
- name: Check
env:
VERSION: ${{ steps.version.outputs.version }}
run: ./gradlew check -PlibtmuxVersion="$VERSION" --stacktrace
# A signing key may or may not carry a passphrase, and an unset secret arrives as an empty
# string rather than as nothing. The publisher does not treat blank as absent, so an empty
# value is offered as the passphrase and decryption fails. Set it only when there is one.
- name: Carry the passphrase only if the key has one
env:
PASSPHRASE: ${{ secrets.SIGNING_PASSWORD }}
run: |
if [ -n "$PASSPHRASE" ]; then
echo "ORG_GRADLE_PROJECT_signingInMemoryKeyPassword=$PASSPHRASE" >> "$GITHUB_ENV"
echo "signing key has a passphrase"
else
echo "signing key has no passphrase"
fi
- name: Publish to the Central Portal
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.CENTRAL_PORTAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.CENTRAL_PORTAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
VERSION: ${{ steps.version.outputs.version }}
run: ./gradlew publishToMavenCentral -PlibtmuxVersion="$VERSION" --stacktrace
- name: What to do next
run: |
echo "::notice::Deployment uploaded. Open https://central.sonatype.com/publishing/deployments and publish or drop it."