Repository navigation
137 lines (122 loc) · 5.46 KB
/
Copy pathmaven-central.yml
File metadata and controls
137 lines (122 loc) · 5.46 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
137
name: Maven Central
# Publishes python-multiplatform (library for every target, KSP processor, Gradle plugin and its
# plugin marker) to Maven Central through the Sonatype Central Portal, as ONE deployment.
#
# - A version tag (v<pythonVersion>-<libraryVersionSuffix>, the tag desktop-release.yml also reads)
# builds, signs with the release key and uploads.
# - A manual run is a dry run unless "dry_run" is turned off: it builds and signs with a key made in
# the job and thrown away, checks the bundle and keeps it as a workflow artifact. Nothing is
# uploaded. With dry_run off, pick the tag to publish in "tag".
#
# macOS is required: the Apple targets (iosArm64, iosSimulatorArm64, iosX64, macosArm64) only build
# there. Secrets read by a real upload, nothing else reads them:
# MAVEN_GPG_PRIVATE_KEY signing key, ASCII armoured (gpg --armor --export-secret-keys)
# MAVEN_GPG_PASSPHRASE its passphrase
# CENTRAL_TOKEN_USERNAME Central Portal user token, username half
# CENTRAL_TOKEN_PASSWORD Central Portal user token, password half
# The upload runs in the environment "maven-central", where required reviewers can be set.
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
dry_run:
description: 'Build and sign with a throwaway key, upload nothing'
type: boolean
default: true
tag:
description: 'Tag to publish when dry_run is off (e.g. v3.15.0-alpha02); ignored for a dry run'
required: false
default: ''
publishing_type:
description: 'USER_MANAGED waits in the Central Portal for someone to press Publish; AUTOMATIC publishes once validated'
type: choice
options: [USER_MANAGED, AUTOMATIC]
default: USER_MANAGED
permissions:
contents: read
concurrency:
group: maven-central-${{ github.event.inputs.tag || github.ref }}
cancel-in-progress: false
jobs:
bundle:
name: Build and sign the bundle (macOS)
runs-on: macos-latest
timeout-minutes: 180
env:
DRY_RUN: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.dry_run) }}
TAG: ${{ github.event.inputs.tag || github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ (github.event_name == 'push' || inputs.dry_run == false) && (github.event.inputs.tag || github.ref) || github.ref }}
# The tag's own gradle.properties decides the version, not the branch it was cut from.
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'zulu'
- name: Setup uv
# The KSP processor's typedpython-gate bundle is built with uv build.
uses: astral-sh/setup-uv@v6
- name: The tag names this build's version
if: env.DRY_RUN != 'true'
run: |
set -euo pipefail
version="$(sed -nE 's/^pythonVersion=(.*)$/\1/p' gradle.properties)-$(sed -nE 's/^libraryVersionSuffix=(.*)$/\1/p' gradle.properties)"
test "$TAG" = "v$version" || { echo "error: tag $TAG does not match version $version" >&2; exit 1; }
echo "VERSION=$version" >> "$GITHUB_ENV"
- name: Build and sign the bundle (dry run, throwaway key)
if: env.DRY_RUN == 'true'
run: .github/scripts/release/central-bundle.sh "$RUNNER_TEMP/central-bundle.zip" --throwaway-key
- name: Build and sign the bundle (release key)
if: env.DRY_RUN != 'true'
env:
MAVEN_GPG_PRIVATE_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
run: |
set -euo pipefail
[[ -n "$MAVEN_GPG_PRIVATE_KEY" ]] || { echo "::error::the MAVEN_GPG_PRIVATE_KEY secret is not set"; exit 1; }
.github/scripts/release/central-bundle.sh "$RUNNER_TEMP/central-bundle.zip"
- name: Keep the bundle
uses: actions/upload-artifact@v4
with:
name: central-bundle
path: ${{ runner.temp }}/central-bundle.zip
retention-days: 14
upload:
name: Upload to the Central Portal
needs: bundle
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.dry_run == false)
runs-on: ubuntu-24.04
timeout-minutes: 90
# Required reviewers can be set on this environment, so even a pushed tag waits for a person
# before anything reaches Central. A dry run never gets here.
environment: maven-central
env:
TAG: ${{ github.event.inputs.tag || github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag || github.ref }}
sparse-checkout: |
.github/scripts/release
gradle.properties
sparse-checkout-cone-mode: false
- uses: actions/download-artifact@v4
with:
name: central-bundle
path: ${{ runner.temp }}
- name: Upload
env:
CENTRAL_TOKEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
CENTRAL_TOKEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
TYPE: ${{ inputs.publishing_type || 'USER_MANAGED' }}
run: |
set -euo pipefail
version="$(sed -nE 's/^pythonVersion=(.*)$/\1/p' gradle.properties)-$(sed -nE 's/^libraryVersionSuffix=(.*)$/\1/p' gradle.properties)"
.github/scripts/release/central-upload.sh "$RUNNER_TEMP/central-bundle.zip" \
"python-multiplatform $version" "$TYPE"