-
-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate to a CI build with SLSA provenance #896
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3a92ad9
Set pom url to my fork
pnacht 5077716
Add release.sh and release.yml
pnacht 46dce9c
Add localCheckout to release:perform
pnacht a75a5bd
Rename jackson-release.sh to release.sh, document release.yml
pnacht dc4f2ca
Add provenance
pnacht 3549c72
Revert "Set pom url to my fork"
pnacht 07b35e1
Remove unnecessary output
pnacht d08eddb
Fix server-id, validate version
pnacht File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# This workflow publishes a new release to Maven central. | ||
# | ||
# The release MUST be initiated by running the release.sh script. That script will run | ||
# ./mvnw release:prepare and make the necessary changes for this workflow to then take | ||
# over and perform the actual release. | ||
|
||
name: Publish new release | ||
on: | ||
push: | ||
tags: | ||
- "*" | ||
- "!*.pr*" | ||
- "!*b" | ||
|
||
jobs: | ||
release: | ||
runs-on: "ubuntu-20.04" | ||
env: | ||
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" | ||
TAG: ${{ github.ref_name }} | ||
outputs: | ||
hash: ${{ steps.hash.outputs.hash }} | ||
artifact_name: ${{ steps.hash.outputs.artifact_name }} | ||
steps: | ||
- name: Validate version name | ||
run: | | ||
[[ "$TAG" =~ jackson-core-[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)? ]] || exit 1 | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: "temurin" | ||
java-version: "8" | ||
cache: "maven" | ||
server-id: sonatype-nexus-staging | ||
server-username: CI_DEPLOY_USERNAME | ||
server-password: CI_DEPLOY_PASSWORD | ||
# See https://github.com/actions/setup-java/blob/v2/docs/advanced-usage.md#Publishing-using-Apache-Maven | ||
# gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import | ||
# gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase | ||
- name: Perform release | ||
# The following command will only succeed if the preparation was done via the | ||
# release.sh script. | ||
run: ./mvnw -B -q -ff -ntp release:perform -DlocalCheckout=true | ||
- name: Generate hash | ||
id: hash | ||
run: | | ||
ARTIFACT_NAME="$( \ | ||
./mvnw help:evaluate \ | ||
-Dexpression=project.artifactId -q -DforceStdout)-$( \ | ||
./mvnw help:evaluate \ | ||
-Dexpression=project.version -q -DforceStdout)" | ||
echo "artifact_name=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT" | ||
|
||
cd ./target | ||
echo "hash=$( \ | ||
sha256sum $ARTIFACT_NAME*.jar | \ | ||
base64 -w0 \ | ||
)" >> "$GITHUB_OUTPUT" | ||
|
||
provenance: | ||
needs: [release] | ||
permissions: | ||
actions: read # To read the workflow path. | ||
id-token: write # To sign the provenance. | ||
contents: write # To add assets to a release. | ||
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected] | ||
with: | ||
base64-subjects: "${{ needs.release.outputs.hash }}" | ||
provenance-name: "${{ needs.release.outputs.artifact_name }}.jar.intoto.jsonl" | ||
upload-assets: true # Optional: Upload to a new release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
# This script simulates the Maven Release Plugin, but only performs | ||
# release:clean and release:prepare. The release:perform step is handled by the | ||
# CI when the tag is pushed. | ||
# | ||
# However, release:perform on Git requires the release.properties file. We must | ||
# therefore modify the first commit created by release:prepare to include this | ||
# file, and then delete the file in the second commit. | ||
# | ||
# This will ensure that release.properties is available to release:perform in | ||
# the CI, while keeping with the expectation that this file does not get | ||
# commited (long-term) to the repository. | ||
|
||
set -euo pipefail | ||
|
||
# Prepare but don't push, we'll need to modify the commits | ||
./mvnw release:clean release:prepare -DpushChanges=false | ||
|
||
# Step back to the first commit (from SNAPSHOT to release) | ||
git reset HEAD~1 | ||
|
||
# delete tag created by release:prepare | ||
tag_name="$(git tag --points-at)" | ||
git tag -d "$tag_name" | ||
|
||
# Add release.properties to that commit | ||
git add release.properties | ||
git commit --amend --no-edit | ||
|
||
# recreate tag | ||
git tag "$tag_name" -m "[maven-release-plugin] copy for tag $tag_name" | ||
|
||
# Recreate second commit (from release to SNAPSHOT), removing | ||
# release.properties from the repository | ||
git rm release.properties | ||
git add pom.xml | ||
git commit -m "[maven-release-plugin] prepare for next development iteration" | ||
|
||
# push everything | ||
git push | ||
git push origin "$tag_name" | ||
|
||
# clean up | ||
rm pom.xml.releaseBackup |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per my note, should perhaps verify that the tag ends in something like "2.15.3"; although if Release Candidates were to use this workflow too (should they?) would need to accommodate those too.