|
| 1 | +# This workflow publishes a new release to Maven central. |
| 2 | +# |
| 3 | +# The release MUST be initiated by running the release.sh script. That script will run |
| 4 | +# ./mvnw release:prepare and make the necessary changes for this workflow to then take |
| 5 | +# over and perform the actual release. |
| 6 | + |
| 7 | +name: Publish new release |
| 8 | +on: |
| 9 | + push: |
| 10 | + tags: |
| 11 | + - "*" |
| 12 | + - "!*.pr*" |
| 13 | + - "!*b" |
| 14 | + |
| 15 | +jobs: |
| 16 | + release: |
| 17 | + runs-on: "ubuntu-20.04" |
| 18 | + env: |
| 19 | + JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" |
| 20 | + TAG: ${{ github.ref_name }} |
| 21 | + outputs: |
| 22 | + hash: ${{ steps.hash.outputs.hash }} |
| 23 | + artifact_name: ${{ steps.hash.outputs.artifact_name }} |
| 24 | + steps: |
| 25 | + - name: Validate version name |
| 26 | + run: | |
| 27 | + [[ "$TAG" =~ jackson-core-[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)? ]] || exit 1 |
| 28 | + - uses: actions/checkout@v3 |
| 29 | + - name: Set up JDK |
| 30 | + uses: actions/setup-java@v3 |
| 31 | + with: |
| 32 | + distribution: "temurin" |
| 33 | + java-version: "8" |
| 34 | + cache: "maven" |
| 35 | + server-id: sonatype-nexus-staging |
| 36 | + server-username: CI_DEPLOY_USERNAME |
| 37 | + server-password: CI_DEPLOY_PASSWORD |
| 38 | + # See https://github.com/actions/setup-java/blob/v2/docs/advanced-usage.md#Publishing-using-Apache-Maven |
| 39 | + # gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import |
| 40 | + # gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase |
| 41 | + - name: Perform release |
| 42 | + # The following command will only succeed if the preparation was done via the |
| 43 | + # release.sh script. |
| 44 | + run: ./mvnw -B -q -ff -ntp release:perform -DlocalCheckout=true |
| 45 | + - name: Generate hash |
| 46 | + id: hash |
| 47 | + run: | |
| 48 | + ARTIFACT_NAME="$( \ |
| 49 | + ./mvnw help:evaluate \ |
| 50 | + -Dexpression=project.artifactId -q -DforceStdout)-$( \ |
| 51 | + ./mvnw help:evaluate \ |
| 52 | + -Dexpression=project.version -q -DforceStdout)" |
| 53 | + echo "artifact_name=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT" |
| 54 | +
|
| 55 | + cd ./target |
| 56 | + echo "hash=$( \ |
| 57 | + sha256sum $ARTIFACT_NAME*.jar | \ |
| 58 | + base64 -w0 \ |
| 59 | + )" >> "$GITHUB_OUTPUT" |
| 60 | +
|
| 61 | + provenance: |
| 62 | + needs: [release] |
| 63 | + permissions: |
| 64 | + actions: read # To read the workflow path. |
| 65 | + id-token: write # To sign the provenance. |
| 66 | + contents: write # To add assets to a release. |
| 67 | + uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.4.0 |
| 68 | + with: |
| 69 | + base64-subjects: "${{ needs.release.outputs.hash }}" |
| 70 | + provenance-name: "${{ needs.release.outputs.artifact_name }}.jar.intoto.jsonl" |
| 71 | + upload-assets: true # Optional: Upload to a new release |
0 commit comments