-
-
Notifications
You must be signed in to change notification settings - Fork 23
201 lines (184 loc) · 7.6 KB
/
release.yml
File metadata and controls
201 lines (184 loc) · 7.6 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: Release
on:
workflow_dispatch:
inputs:
# Auto-generated from .version by sync-version-file.yml
# VERSION_INPUT_BEGIN
version_preview:
description: "Version from .version (read-only preview)"
required: true
type: choice
options:
- "2.3.0"
default: "2.3.0"
# VERSION_INPUT_END
permissions:
contents: write
issues: write
pull-requests: write
concurrency:
group: release-${{ github.run_id }}
cancel-in-progress: false
jobs:
release:
name: Publish Release
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'HDCharts' }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
cache: gradle
- name: Resolve release version from Axion
id: version
shell: bash
run: |
set -euo pipefail
release_version="$(bash .github/scripts/resolve-release-version.sh)"
echo "release_version=${release_version}" >> "$GITHUB_OUTPUT"
echo "Resolved release version: ${release_version}"
- name: Verify release readiness with Axion
shell: bash
run: |
set -euo pipefail
./gradlew verifyRelease --no-daemon --stacktrace
- name: Verify tag does not already exist
shell: bash
run: |
set -euo pipefail
VERSION="${{ steps.version.outputs.release_version }}"
if git rev-parse -q --verify "refs/tags/${VERSION}" >/dev/null; then
echo "❌ Tag already exists: ${VERSION}" >&2
exit 1
fi
- name: Checkout charts-docs repository
uses: actions/checkout@v6
with:
repository: HDCharts/charts-docs
fetch-depth: 1
path: charts-docs-repo
- name: Validate release version exists in charts-docs registry
shell: bash
env:
EXPECTED_VERSION: ${{ steps.version.outputs.release_version }}
run: |
set -euo pipefail
registry_path="charts-docs-repo/registry/versions.json"
if [[ ! -f "${registry_path}" ]]; then
echo "Missing charts-docs registry: ${registry_path}" >&2
exit 1
fi
if ! jq -e --arg expected "${EXPECTED_VERSION}" \
'any((.versions // [])[]?; .id == $expected)' "${registry_path}" >/dev/null; then
available_versions="$(jq -r '[(.versions // [])[]? | .id | select(type == "string" and . != "")] | join(", ")' "${registry_path}")"
echo "Release version ${EXPECTED_VERSION} is not present in charts-docs registry." >&2
echo "Available registry versions: ${available_versions:-"(none)"}" >&2
exit 1
fi
- name: Check required secrets
id: secrets_check
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_IN_MEMORY_KEY: ${{ secrets.SIGNING_IN_MEMORY_KEY }}
shell: bash
run: |
set -euo pipefail
missing=0
for v in MAVEN_CENTRAL_USERNAME MAVEN_CENTRAL_PASSWORD SIGNING_KEY_ID SIGNING_PASSWORD SIGNING_IN_MEMORY_KEY; do
if [ -z "${!v:-}" ]; then
echo "Missing secret: $v" >&2
missing=1
fi
done
if [ "$missing" -eq 0 ]; then
echo "can_publish=true" >> "$GITHUB_OUTPUT"
else
echo "can_publish=false" >> "$GITHUB_OUTPUT"
echo "Release publish cannot proceed because required secrets are missing." >&2
exit 1
fi
- name: Create release tag locally with Axion
if: ${{ steps.secrets_check.outputs.can_publish == 'true' }}
shell: bash
run: |
set -euo pipefail
./gradlew createRelease --no-daemon --stacktrace
- name: Publish to Maven Central
if: ${{ steps.secrets_check.outputs.can_publish == 'true' }}
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_IN_MEMORY_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
run: |
./gradlew publishChartsModules \
-PchartsReleaseVersion="${{ steps.version.outputs.release_version }}" \
--no-daemon --no-build-cache --stacktrace
- name: Push release tag with Axion
if: ${{ steps.secrets_check.outputs.can_publish == 'true' }}
shell: bash
run: |
set -euo pipefail
./gradlew pushRelease --no-daemon --stacktrace
- name: Comment on success
if: ${{ steps.secrets_check.outputs.can_publish == 'true' }}
uses: actions/github-script@v7
with:
script: |
const version = '${{ steps.version.outputs.release_version }}';
const message = [
'🎉 **Release Published Successfully!**',
'',
`Version: \`${version}\``,
'',
'✅ Published to Maven Central',
'✅ Git tag created',
'',
'Umbrella artifact:',
'```kotlin',
`implementation("io.github.dautovicharis:charts:${version}")`,
'```',
'',
'Modular artifacts:',
'```kotlin',
`implementation("io.github.dautovicharis:charts-core:${version}")`,
`implementation("io.github.dautovicharis:charts-line:${version}")`,
`implementation("io.github.dautovicharis:charts-pie:${version}")`,
`implementation("io.github.dautovicharis:charts-bar:${version}")`,
`implementation("io.github.dautovicharis:charts-stacked-bar:${version}")`,
`implementation("io.github.dautovicharis:charts-stacked-area:${version}")`,
`implementation("io.github.dautovicharis:charts-radar:${version}")`,
'```',
'',
'BOM alignment (for Gradle platforms):',
'```kotlin',
`implementation(platform("io.github.dautovicharis:charts-bom:${version}"))`,
'implementation("io.github.dautovicharis:charts-core")',
'implementation("io.github.dautovicharis:charts-line")',
'implementation("io.github.dautovicharis:charts-pie")',
'implementation("io.github.dautovicharis:charts-bar")',
'implementation("io.github.dautovicharis:charts-stacked-bar")',
'implementation("io.github.dautovicharis:charts-stacked-area")',
'implementation("io.github.dautovicharis:charts-radar")',
'```',
'',
'📚 [Documentation](https://charts.harisdautovic.com/)',
`📦 [Maven Central](https://central.sonatype.com/artifact/io.github.dautovicharis/charts/${version})`,
].join('\n');
// Create a comment on the commit
github.rest.repos.createCommitComment({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.sha,
body: message
});