-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (145 loc) · 4.84 KB
/
Copy pathpublish.yml
File metadata and controls
168 lines (145 loc) · 4.84 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Release
on:
workflow_dispatch:
inputs:
operation:
description: "Run validation only, or publish to Maven Central."
required: true
default: "validate"
type: choice
options:
- validate
- publish
release_ref:
description: "Branch or tag to check out. Publishing requires v<release_version>."
required: true
default: "main"
release_version:
description: "Vigil release version."
required: true
default: "6.0.0"
doppler_project:
description: "Doppler project containing release secrets."
required: true
default: "sequel-releases"
doppler_config:
description: "Doppler config containing release secrets."
required: true
default: "prd"
confirmation:
description: "Required for publish: publish <release_version>"
required: false
default: ""
permissions:
contents: read
concurrency:
group: release-${{ inputs.operation }}-${{ inputs.release_ref }}
cancel-in-progress: false
jobs:
validate:
name: Validate release candidate
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
validated_sha: ${{ steps.capture-sha.outputs.sha }}
env:
RELEASE_VERSION: ${{ inputs.release_version }}
OPERATION: ${{ inputs.operation }}
RELEASE_REF: ${{ inputs.release_ref }}
CONFIRMATION: ${{ inputs.confirmation }}
steps:
- name: Checkout release ref
uses: actions/checkout@v7
with:
ref: ${{ inputs.release_ref }}
fetch-depth: 0
- name: Capture validated commit
id: capture-sha
shell: bash
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 25
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
with:
gradle-version: wrapper
- name: Validate release inputs
shell: bash
run: |
set -euo pipefail
if [[ "$OPERATION" != "validate" && "$OPERATION" != "publish" ]]; then
echo "Unsupported operation: $OPERATION"
exit 1
fi
if [[ "$OPERATION" == "validate" ]]; then
exit 0
fi
expected_ref="v${RELEASE_VERSION}"
expected_confirmation="publish ${RELEASE_VERSION}"
if [[ "$RELEASE_REF" != "$expected_ref" ]]; then
echo "Publishing requires release_ref=$expected_ref."
exit 1
fi
if [[ "$CONFIRMATION" != "$expected_confirmation" ]]; then
echo "Publishing requires confirmation='$expected_confirmation'."
exit 1
fi
- name: Validate version alignment
shell: bash
run: grep -F "version = \"$RELEASE_VERSION\"" build.gradle.kts
- name: Quality gate
run: ./gradlew qualityCheck --no-daemon
- name: Build
run: ./gradlew build --no-daemon
- name: Maven local publish dry run
run: ./gradlew publishToMavenLocal --no-daemon --no-configuration-cache
publish:
name: Publish Maven Central artifact
needs: validate
if: ${{ inputs.operation == 'publish' }}
runs-on: ubuntu-latest
environment: release
permissions:
contents: read
env:
GRADLE_OPTS: -Dorg.gradle.jvmargs=-Xmx2g
steps:
- name: Checkout release ref
uses: actions/checkout@v7
with:
ref: ${{ needs.validate.outputs.validated_sha }}
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 25
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
with:
gradle-version: wrapper
- name: Fetch release secrets
uses: dopplerhq/secrets-fetch-action@v2.0.0
with:
doppler-token: ${{ secrets.DOPPLER_TOKEN }}
doppler-project: ${{ inputs.doppler_project }}
doppler-config: ${{ inputs.doppler_config }}
inject-env-vars: true
- name: Verify Maven publish secrets
shell: bash
run: |
set -euo pipefail
test -n "${MAVEN_USERNAME:-}"
test -n "${MAVEN_PASSWORD:-}"
test -n "${GPG_PRIVATE_KEY:-}"
test -n "${GPG_PASSPHRASE:-}"
- name: Publish to Maven Central
run: ./gradlew publishAllPublicationsToMavenCentralRepository --no-configuration-cache
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ env.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ env.MAVEN_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ env.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ env.GPG_PASSPHRASE }}