Skip to content

Commit b512f9a

Browse files
authored
Merge pull request #233 from Yubico/auto-signature-upload
Automate signature upload step in release procedure
2 parents 9ed156e + 16d7066 commit b512f9a

File tree

3 files changed

+91
-74
lines changed

3 files changed

+91
-74
lines changed
Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,42 @@
11
name: Reproducible binary
22

3+
# This workflow waits for release signatures to appear on Maven Central,
4+
# then rebuilds the artifacts and verifies them against those signatures,
5+
# and finally uploads the signatures to the GitHub release.
6+
37
on:
48
release:
5-
types: [published, created, edited, prereleased]
9+
types: [published, edited]
610

711
jobs:
12+
download:
13+
name: Download keys and signatures
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Fetch keys
18+
run: gpg --no-default-keyring --keyring ./yubico.keyring --keyserver hkps://keys.openpgp.org --recv-keys 57A9DEED4C6D962A923BB691816F3ED99921835E
19+
20+
- name: Download signatures from Maven Central
21+
timeout-minutes: 60
22+
run: |
23+
until wget https://repo1.maven.org/maven2/com/yubico/webauthn-server-attestation/${{ github.ref_name }}/webauthn-server-attestation-${{ github.ref_name }}.jar.asc; do sleep 180; done
24+
until wget https://repo1.maven.org/maven2/com/yubico/webauthn-server-core/${{ github.ref_name }}/webauthn-server-core-${{ github.ref_name }}.jar.asc; do sleep 180; done
25+
26+
- name: Store keyring and signatures as artifact
27+
uses: actions/upload-artifact@v3
28+
with:
29+
name: keyring-and-signatures
30+
retention-days: 1
31+
path: |
32+
yubico.keyring
33+
*.jar.asc
34+
835
verify:
936
name: Verify signatures (JDK ${{ matrix.java }} ${{ matrix.distribution }})
10-
37+
needs: download
1138
runs-on: ubuntu-latest
39+
1240
strategy:
1341
matrix:
1442
java: [17]
@@ -18,7 +46,7 @@ jobs:
1846
- name: check out code
1947
uses: actions/checkout@v3
2048
with:
21-
ref: ${{ github.ref }}
49+
ref: ${{ github.ref_name }}
2250

2351
- name: Set up JDK
2452
uses: actions/setup-java@v3
@@ -31,25 +59,34 @@ jobs:
3159
java --version
3260
./gradlew jar
3361
34-
- name: Fetch keys
35-
run: gpg --no-default-keyring --keyring yubico --keyserver hkps://keys.openpgp.org --recv-keys 57A9DEED4C6D962A923BB691816F3ED99921835E
62+
- name: Retrieve keyring and signatures
63+
uses: actions/download-artifact@v3
64+
with:
65+
name: keyring-and-signatures
3666

37-
- name: Verify signatures from GitHub release
67+
- name: Verify signatures from Maven Central
3868
run: |
39-
export TAGNAME=${GITHUB_REF#refs/tags/}
69+
gpg --no-default-keyring --keyring ./yubico.keyring --verify webauthn-server-attestation-${{ github.ref_name }}.jar.asc webauthn-server-attestation/build/libs/webauthn-server-attestation-${{ github.ref_name }}.jar
70+
gpg --no-default-keyring --keyring ./yubico.keyring --verify webauthn-server-core-${{ github.ref_name }}.jar.asc webauthn-server-core/build/libs/webauthn-server-core-${{ github.ref_name }}.jar
71+
72+
upload:
73+
name: Upload signatures to GitHub
74+
needs: verify
75+
runs-on: ubuntu-latest
4076

41-
wget https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAGNAME}/webauthn-server-attestation-${TAGNAME}.jar.asc
42-
wget https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAGNAME}/webauthn-server-core-${TAGNAME}.jar.asc
77+
permissions:
78+
contents: write # Allow uploading release artifacts
4379

44-
gpg --no-default-keyring --keyring yubico --verify webauthn-server-attestation-${TAGNAME}.jar.asc webauthn-server-attestation/build/libs/webauthn-server-attestation-${TAGNAME}.jar
45-
gpg --no-default-keyring --keyring yubico --verify webauthn-server-core-${TAGNAME}.jar.asc webauthn-server-core/build/libs/webauthn-server-core-${TAGNAME}.jar
80+
steps:
81+
- name: Retrieve signatures
82+
uses: actions/download-artifact@v3
83+
with:
84+
name: keyring-and-signatures
4685

47-
- name: Verify signatures from Maven Central
86+
- name: Upload signatures to GitHub
4887
run: |
49-
export TAGNAME=${GITHUB_REF#refs/tags/}
50-
51-
wget -O webauthn-server-core-${TAGNAME}.jar.mavencentral.asc https://repo1.maven.org/maven2/com/yubico/webauthn-server-core/${TAGNAME}/webauthn-server-core-${TAGNAME}.jar.asc
52-
wget -O webauthn-server-attestation-${TAGNAME}.jar.mavencentral.asc https://repo1.maven.org/maven2/com/yubico/webauthn-server-attestation/${TAGNAME}/webauthn-server-attestation-${TAGNAME}.jar.asc
88+
RELEASE_DATA=$(curl -H "Authorization: Bearer ${{ github.token }}" ${{ github.api_url }}/repos/${{ github.repository }}/releases/tags/${{ github.ref_name }})
89+
UPLOAD_URL=$(jq -r .upload_url <<<"${RELEASE_DATA}" | sed 's/{?name,label}//')
5390
54-
gpg --no-default-keyring --keyring yubico --verify webauthn-server-attestation-${TAGNAME}.jar.mavencentral.asc webauthn-server-attestation/build/libs/webauthn-server-attestation-${TAGNAME}.jar
55-
gpg --no-default-keyring --keyring yubico --verify webauthn-server-core-${TAGNAME}.jar.mavencentral.asc webauthn-server-core/build/libs/webauthn-server-core-${TAGNAME}.jar
91+
curl -X POST -H "Authorization: Bearer ${{ github.token }}" -H 'Content-Type: text/plain' --data-binary @webauthn-server-attestation-${{ github.ref_name }}.jar.asc "${UPLOAD_URL}?name=webauthn-server-attestation-${{ github.ref_name }}.jar.asc"
92+
curl -X POST -H "Authorization: Bearer ${{ github.token }}" -H 'Content-Type: text/plain' --data-binary @webauthn-server-core-${{ github.ref_name }}.jar.asc "${UPLOAD_URL}?name=webauthn-server-core-${{ github.ref_name }}.jar.asc"

build.gradle

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,12 @@ task assembleJavadoc(type: Sync) {
116116
destinationDir = file("${rootProject.buildDir}/javadoc")
117117
}
118118

119-
task collectSignatures(type: Sync) {
120-
destinationDir = file("${rootProject.buildDir}/dist")
121-
duplicatesStrategy DuplicatesStrategy.FAIL
122-
include '*.jar', '*.jar.asc'
119+
task checkJavaVersionBeforeRelease {
120+
doFirst {
121+
if (JavaVersion.current() != JavaVersion.VERSION_17) {
122+
throw new RuntimeException('Release must be built using JDK 17. Current JDK version: ' + JavaVersion.current())
123+
}
124+
}
123125
}
124126

125127
subprojects { project ->
@@ -154,16 +156,19 @@ subprojects { project ->
154156
reproducibleFileOrder = true
155157
}
156158

157-
tasks.withType(Sign) {
158-
it.dependsOn check
159-
}
160-
161159
tasks.withType(AbstractTestTask) {
162160
testLogging {
163161
showStandardStreams = isCiBuild
164162
}
165163
}
166164

165+
tasks.withType(AbstractCompile) { shouldRunAfter checkJavaVersionBeforeRelease }
166+
tasks.withType(AbstractTestTask) { shouldRunAfter checkJavaVersionBeforeRelease }
167+
tasks.withType(Sign) {
168+
it.dependsOn check
169+
dependsOn checkJavaVersionBeforeRelease
170+
}
171+
167172
if (project.hasProperty('publishMe') && project.publishMe) {
168173
task sourcesJar(type: Jar) {
169174
archiveClassifier = 'sources'
@@ -247,14 +252,6 @@ subprojects { project ->
247252
useGpgCmd()
248253
sign publishing.publications.jars
249254
}
250-
251-
tasks.withType(Sign) { Sign signTask ->
252-
rootProject.tasks.collectSignatures {
253-
from signTask.inputs.files
254-
from signTask.outputs.files
255-
}
256-
signTask.finalizedBy rootProject.tasks.collectSignatures
257-
}
258255
}
259256
}
260257

doc/releasing.md

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,27 @@ Release candidate versions
66

77
1. Make sure release notes in `NEWS` are up to date.
88

9-
2. Make sure you're running Gradle in JDK 17.
10-
11-
3. Run the tests one more time:
9+
2. Run the tests one more time:
1210

1311
```
1412
$ ./gradlew clean check
1513
```
1614
17-
4. Tag the head commit with an `X.Y.Z-RCN` tag:
15+
3. Tag the head commit with an `X.Y.Z-RCN` tag:
1816
1917
```
2018
$ git tag -a -s 1.4.0-RC1 -m "Pre-release 1.4.0-RC1"
2119
```
2220
2321
No tag body needed.
2422
25-
5. Publish to Sonatype Nexus:
23+
4. Publish to Sonatype Nexus:
2624
2725
```
2826
$ ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
2927
```
3028
31-
6. Wait for the artifacts to become downloadable at
32-
https://repo1.maven.org/maven2/com/yubico/webauthn-server-core/ . This is
33-
needed for one of the GitHub Actions release workflows and usually takes
34-
less than 30 minutes (long before the artifacts become searchable on the
35-
main Maven Central website).
36-
37-
7. Push to GitHub.
29+
5. Push to GitHub.
3830
3931
If the pre-release makes significant changes to the project README, such
4032
that the README does not accurately reflect the latest non-pre-release
@@ -52,28 +44,26 @@ Release candidate versions
5244
$ git push origin main 1.4.0-RC1
5345
```
5446
55-
8. Make GitHub release.
47+
6. Make GitHub release.
5648
5749
- Use the new tag as the release tag
5850
- Check the pre-release checkbox
5951
- Copy the release notes from `NEWS` into the GitHub release notes; reformat
6052
from ASCIIdoc to Markdown and remove line wraps. Include only
6153
changes/additions since the previous release or pre-release.
62-
- Attach the signature files from
63-
`build/dist/webauthn-server-attestation-X.Y.Z-RCN.jar.asc`
64-
and
65-
`build/dist/webauthn-server-core-X.Y.Z-RCN.jar.asc`.
6654
- Note which JDK version was used to build the artifacts.
6755
56+
7. Check that the ["Reproducible binary"
57+
workflow](/Yubico/java-webauthn-server/actions/workflows/release-verify-signatures.yml)
58+
runs and succeeds.
59+
6860
6961
Release versions
7062
---
7163
7264
1. Make sure release notes in `NEWS` are up to date.
7365
74-
2. Make sure you're running Gradle in JDK 17.
75-
76-
3. Make a no-fast-forward merge from the last (non release candidate) release
66+
2. Make a no-fast-forward merge from the last (non release candidate) release
7767
to the commit to be released:
7868
7969
```
@@ -95,60 +85,53 @@ Release versions
9585
$ git branch -d release-1.4.0
9686
```
9787
98-
4. Remove the "(unreleased)" tag from `NEWS`.
88+
3. Remove the "(unreleased)" tag from `NEWS`.
9989
100-
5. Update the version in the dependency snippets in the README.
90+
4. Update the version in the dependency snippets in the README.
10191
102-
6. Update the version in JavaDoc links in the READMEs.
92+
5. Update the version in JavaDoc links in the READMEs.
10393
104-
7. Amend these changes into the merge commit:
94+
6. Amend these changes into the merge commit:
10595
10696
```
10797
$ git add NEWS
10898
$ git commit --amend --reset-author
10999
```
110100
111-
8. Run the tests one more time:
101+
7. Run the tests one more time:
112102
113103
```
114104
$ ./gradlew clean check
115105
```
116106
117-
9. Tag the merge commit with an `X.Y.Z` tag:
107+
8. Tag the merge commit with an `X.Y.Z` tag:
118108
119109
```
120110
$ git tag -a -s 1.4.0 -m "Release 1.4.0"
121111
```
122112
123113
No tag body needed since that's included in the commit.
124114
125-
10. Publish to Sonatype Nexus:
115+
9. Publish to Sonatype Nexus:
126116
127117
```
128118
$ ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
129119
```
130120
131-
11. Wait for the artifacts to become downloadable at
132-
https://repo1.maven.org/maven2/com/yubico/webauthn-server-core/ . This is
133-
needed for one of the GitHub Actions release workflows and usually takes
134-
less than 30 minutes (long before the artifacts become searchable on the
135-
main Maven Central website).
136-
137-
12. Push to GitHub:
121+
10. Push to GitHub:
138122
139123
```
140124
$ git push origin main 1.4.0
141125
```
142126
143-
13. Make GitHub release.
127+
11. Make GitHub release.
144128
145129
- Use the new tag as the release tag
146130
- Copy the release notes from `NEWS` into the GitHub release notes; reformat
147131
from ASCIIdoc to Markdown and remove line wraps. Include all changes since
148132
the previous release (not just changes since the previous pre-release).
149-
- Attach the signature files from
150-
`build/dist/webauthn-server-attestation-X.Y.Z.jar.asc`
151-
and
152-
`build/dist/webauthn-server-core-X.Y.Z.jar.asc`.
153-
154133
- Note which JDK version was used to build the artifacts.
134+
135+
12. Check that the ["Reproducible binary"
136+
workflow](/Yubico/java-webauthn-server/actions/workflows/release-verify-signatures.yml)
137+
runs and succeeds.

0 commit comments

Comments
 (0)