Repository navigation
157 lines (138 loc) · 5.81 KB
/
Copy pathrelease.yml
File metadata and controls
157 lines (138 loc) · 5.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
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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
verify-acceptance:
name: Verify accepted tag
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
steps:
- name: Require the package version and successful full CI
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
test "$GITHUB_REF_NAME" = v0.8.1 || { echo 'tag does not match package version' >&2; exit 1; }
target="$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_REF_NAME" --jq '.sha')"
test "$target" = "$GITHUB_SHA" || { echo 'tag does not match the built commit' >&2; exit 1; }
accepted="$(gh run list --repo "$GITHUB_REPOSITORY" --workflow ci.yml \
--commit "$GITHUB_SHA" --status success --limit 20 --json databaseId --jq 'length')"
test "$accepted" -gt 0 || { echo 'no successful full CI for this commit' >&2; exit 1; }
# ------------------------------------------------------------------
# Cross-compile the cdylib for six platforms. Each job uploads a
# single asset named the way `NativeLoader.assetName()` expects.
# ------------------------------------------------------------------
build-native:
uses: ./.github/workflows/native-distribution.yml
with:
source-ref: ${{ github.sha }}
# ------------------------------------------------------------------
# Build the Java JARs (main / sources / javadoc). publish-maven sends
# them to Maven Central; these copies are also attached to the GitHub
# Release as a direct-download fallback.
# ------------------------------------------------------------------
build-jars:
name: build JARs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- uses: gradle/actions/setup-gradle@v4
- name: Gradle build
# vanniktech maven-publish renames javadocJar to
# mavenPlainJavadocJar, so we either ask for that explicitly or
# let the publication-graph trigger the right task transitively.
run: >
./gradlew :lib:jar :lib:sourcesJar :lib:mavenPlainJavadocJar
:lib:generatePomFileForMavenPublication
:lib:generateMetadataFileForMavenPublication :lib:pureJarTest --no-daemon
- name: Verify publication metadata and exact JAR payload
run: |
set -euo pipefail
bash scripts/check-publish-metadata.sh
for jar in ktav-0.8.1.jar ktav-0.8.1-sources.jar lib-maven-javadoc-0.8.1-javadoc.jar; do
test -s "lib/build/libs/$jar" || { echo "missing JAR: $jar" >&2; exit 1; }
done
- uses: actions/upload-artifact@v4
with:
name: jars
path: |
lib/build/libs/ktav-0.8.1.jar
lib/build/libs/ktav-0.8.1-sources.jar
lib/build/libs/lib-maven-javadoc-0.8.1-javadoc.jar
if-no-files-found: error
# ------------------------------------------------------------------
# Publish the JARs to Maven Central via Sonatype Central Portal.
# The vanniktech plugin handles signing, staging upload, and (with
# automaticRelease=true on the build side) promotion to the public
# repository. Credentials and the GPG key come from repo secrets.
# ------------------------------------------------------------------
publish-maven:
name: publish to Maven Central
needs: [build-native, build-jars, verify-acceptance]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- uses: gradle/actions/setup-gradle@v4
- name: Publish to Maven Central
env:
# vanniktech plugin reads these as Gradle project properties
# (the ORG_GRADLE_PROJECT_ prefix is the standard pass-through).
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
# Armored ASCII private key (the literal `-----BEGIN PGP
# PRIVATE KEY BLOCK-----` block). Passphrase is empty (key was
# generated with %no-protection), so no GPG_PASSPHRASE secret.
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
set -euo pipefail
./gradlew :lib:pureJarTest :lib:generatePomFileForMavenPublication \
:lib:generateMetadataFileForMavenPublication --no-configuration-cache --no-daemon
bash scripts/check-publish-metadata.sh
./gradlew :lib:publishAndReleaseToMavenCentral --no-configuration-cache --no-daemon
# ------------------------------------------------------------------
# Attach artifacts to the GitHub Release matching the tag.
# ------------------------------------------------------------------
release:
needs: [build-native, build-jars, publish-maven, verify-acceptance]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: native-distribution-*
path: artifacts
merge-multiple: true
- uses: actions/download-artifact@v4
with:
name: jars
path: artifacts
- name: List artifacts
run: ls -la artifacts/
- name: Create / update GitHub Release
uses: softprops/action-gh-release@v3
with:
files: artifacts/*
fail_on_unmatched_files: true
generate_release_notes: true