Skip to content

Commit 3da9f11

Browse files
committed
ci: GitHub Actions sync
1 parent 6df0be6 commit 3da9f11

File tree

7 files changed

+118
-71
lines changed

7 files changed

+118
-71
lines changed

.github/workflows/central-sync.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222
- name: Set up JDK
2323
uses: actions/setup-java@v3
2424
with:
25-
distribution: 'adopt'
2625
java-version: '11'
26+
distribution: 'temurin'
2727
- name: Publish to Sonatype OSSRH
2828
env:
2929
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}

.github/workflows/graalvm.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
runs-on: ubuntu-latest
2020
strategy:
2121
matrix:
22-
java: ['11', '17']
23-
graalvm: ['latest']
22+
graalvm: [ 'latest']
23+
java: [ '17' ]
2424
steps:
2525
# https://github.com/actions/virtual-environments/issues/709
2626
- name: Free disk space
@@ -42,7 +42,11 @@ jobs:
4242
version: ${{ matrix.graalvm }}
4343
java-version: ${{ matrix.java }}
4444
components: 'native-image'
45+
github-token: ${{ secrets.GITHUB_TOKEN }}
46+
- name: Setup Gradle
47+
uses: gradle/[email protected]
4548
- name: Build with Gradle
49+
id: gradle
4650
run: |
4751
if ./gradlew tasks --no-daemon --all | grep -w "testNativeImage"
4852
then
@@ -52,13 +56,15 @@ jobs:
5256
fi
5357
env:
5458
TESTCONTAINERS_RYUK_DISABLED: true
59+
GH_TOKEN_PUBLIC_REPOS_READONLY: ${{ secrets.GH_TOKEN_PUBLIC_REPOS_READONLY }}
60+
GH_USERNAME: ${{ secrets.GH_USERNAME }}
5561
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
5662
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
5763
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
5864
PREDICTIVE_TEST_SELECTION: "${{ github.event_name == 'pull_request' && 'true' || 'false' }}"
5965
- name: Publish Test Report
6066
if: always()
61-
uses: mikepenz/action-junit-report@v3.3.3
67+
uses: mikepenz/action-junit-report@v3.7.5
6268
with:
6369
check_name: GraalVM CE CI / Test Report (Java ${{ matrix.java }})
6470
report_paths: '**/build/test-results/test/TEST-*.xml'

.github/workflows/gradle.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,13 @@ jobs:
2929
sudo apt-get clean
3030
df -h
3131
- uses: actions/checkout@v3
32-
- uses: actions/cache@v3
33-
with:
34-
path: ~/.gradle/caches
35-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
36-
restore-keys: |
37-
${{ runner.os }}-gradle-
3832
- name: Set up JDK
3933
uses: actions/setup-java@v3
4034
with:
41-
distribution: 'adopt'
35+
distribution: 'temurin'
4236
java-version: ${{ matrix.java }}
37+
- name: Setup Gradle
38+
uses: gradle/[email protected]
4339
- name: Optional setup step
4440
env:
4541
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
@@ -48,32 +44,35 @@ jobs:
4844
run: |
4945
[ -f ./setup.sh ] && ./setup.sh || true
5046
- name: Build with Gradle
47+
id: gradle
5148
run: |
52-
# Awful hack for kapt and JDK 16. See https://youtrack.jetbrains.com/issue/KT-45545
53-
if [ ${{ matrix.java }} == 16 ]; then export GRADLE_OPTS="-Dorg.gradle.jvmargs=--illegal-access=permit"; fi
5449
./gradlew check --no-daemon --parallel --continue
5550
env:
51+
GH_TOKEN_PUBLIC_REPOS_READONLY: ${{ secrets.GH_TOKEN_PUBLIC_REPOS_READONLY }}
52+
GH_USERNAME: ${{ secrets.GH_USERNAME }}
5653
TESTCONTAINERS_RYUK_DISABLED: true
5754
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
5855
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
5956
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
6057
PREDICTIVE_TEST_SELECTION: "${{ github.event_name == 'pull_request' && 'true' || 'false' }}"
6158
- name: Publish Test Report
6259
if: always()
63-
uses: mikepenz/action-junit-report@v3.3.3
60+
uses: mikepenz/action-junit-report@v3.7.5
6461
with:
6562
check_name: Java CI / Test Report (${{ matrix.java }})
6663
report_paths: '**/build/test-results/test/TEST-*.xml'
6764
check_retries: 'true'
6865
- name: "📜 Upload binary compatibility check results"
6966
if: always()
70-
uses: actions/upload-artifact@v2
67+
uses: actions/upload-artifact@v3
7168
with:
7269
name: binary-compatibility-reports
7370
path: "**/build/reports/binary-compatibility-*.html"
7471
- name: Publish to Sonatype Snapshots
7572
if: success() && github.event_name == 'push' && matrix.java == '11'
7673
env:
74+
GH_TOKEN_PUBLIC_REPOS_READONLY: ${{ secrets.GH_TOKEN_PUBLIC_REPOS_READONLY }}
75+
GH_USERNAME: ${{ secrets.GH_USERNAME }}
7776
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
7877
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
7978
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}

.github/workflows/publish-snapshot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
- name: Set up JDK
2121
uses: actions/setup-java@v3
2222
with:
23-
distribution: 'adopt'
2423
java-version: '11'
24+
distribution: 'temurin'
2525
- name: Publish to Sonatype Snapshots
2626
if: success()
2727
env:

.github/workflows/release-notes.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
types: [published]
1010
jobs:
1111
release:
12+
outputs:
13+
artifacts-sha256: ${{ steps.hash.outputs.artifacts-sha256 }} # Computed hashes for build artifacts.
1214
runs-on: ubuntu-latest
1315
steps:
1416
- name: Checkout repository
@@ -19,18 +21,19 @@ jobs:
1921
- name: Set up JDK
2022
uses: actions/setup-java@v3
2123
with:
22-
distribution: 'adopt'
2324
java-version: '11'
25+
distribution: 'temurin'
2426
- name: Set the current release version
2527
id: release_version
26-
run: echo ::set-output name=release_version::${GITHUB_REF:11}
28+
run: echo "release_version=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
2729
- name: Run pre-release
2830
uses: micronaut-projects/github-actions/pre-release@master
2931
env:
3032
MICRONAUT_BUILD_EMAIL: ${{ secrets.MICRONAUT_BUILD_EMAIL }}
3133
with:
3234
token: ${{ secrets.GITHUB_TOKEN }}
3335
- name: Publish to Sonatype OSSRH
36+
id: publish
3437
env:
3538
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
3639
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
@@ -42,13 +45,46 @@ jobs:
4245
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
4346
run: |
4447
echo $GPG_FILE | base64 -d > secring.gpg
45-
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
48+
# Publish both locally and to Sonatype.
49+
# The artifacts stored locally will be used to generate the SLSA provenance.
50+
./gradlew publishAllPublicationsToBuildRepository publishToSonatype closeAndReleaseSonatypeStagingRepository
51+
# Read the current version from gradle.properties.
52+
VERSION=$(./gradlew properties | grep 'version:' | awk '{print $2}')
53+
# Read the project group from gradle.properties.
54+
GROUP_PATH=$(./gradlew properties| grep "projectGroup" | awk '{print $2}' | sed 's/\./\//g')
55+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
56+
echo "group=$GROUP_PATH" >> "$GITHUB_OUTPUT"
57+
- name: Generate subject
58+
id: hash
59+
run: |
60+
# Find the relevant published artifacts in the local repository.
61+
ARTIFACTS=$(find build/repo/${{ steps.publish.outputs.group }}/*/${{ steps.publish.outputs.version }}/* \
62+
-regextype sed -regex '\(.*\.jar\|.*\.pom\|.*\.module\|.*\.toml\)')
63+
# Compute the hashes for the artifacts.
64+
# Set the hash as job output for debugging.
65+
echo "artifacts-sha256=$(sha256sum $ARTIFACTS | base64 -w0)" >> "$GITHUB_OUTPUT"
66+
# Store the hash in a file, which is uploaded as a workflow artifact.
67+
echo $(sha256sum $ARTIFACTS | base64 -w0) > artifacts-sha256
68+
- name: Upload build artifacts
69+
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
70+
with:
71+
name: gradle-build-outputs
72+
path: build/repo/${{ steps.publish.outputs.group }}/*/${{ steps.publish.outputs.version }}/*
73+
retention-days: 5
74+
- name: Upload artifacts-sha256
75+
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
76+
with:
77+
name: artifacts-sha256
78+
path: artifacts-sha256
79+
retention-days: 5
4680
- name: Generate docs
81+
run: ./gradlew docs
4782
env:
4883
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
4984
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
5085
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
51-
run: ./gradlew docs
86+
GH_TOKEN_PUBLIC_REPOS_READONLY: ${{ secrets.GH_TOKEN_PUBLIC_REPOS_READONLY }}
87+
GH_USERNAME: ${{ secrets.GH_USERNAME }}
5288
- name: Export Gradle Properties
5389
uses: micronaut-projects/github-actions/export-gradle-properties@master
5490
- name: Publish to Github Pages
@@ -86,3 +122,57 @@ jobs:
86122
MICRONAUT_BUILD_EMAIL: ${{ secrets.MICRONAUT_BUILD_EMAIL }}
87123
with:
88124
token: ${{ secrets.GITHUB_TOKEN }}
125+
126+
provenance-subject:
127+
needs: [release]
128+
runs-on: ubuntu-latest
129+
outputs:
130+
artifacts-sha256: ${{ steps.set-hash.outputs.artifacts-sha256 }}
131+
steps:
132+
- name: Download artifacts-sha256
133+
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1
134+
with:
135+
name: artifacts-sha256
136+
# The SLSA provenance generator expects the hash digest of artifacts to be passed as a job
137+
# output. So we need to download the artifacts-sha256 and set it as job output. The hash of
138+
# the artifacts should be set as output directly in the release job. But due to a known bug
139+
# in GitHub Actions we have to use a workaround.
140+
# See https://github.com/community/community/discussions/37942.
141+
- name: Set artifacts-sha256 as output
142+
id: set-hash
143+
shell: bash
144+
run: echo "artifacts-sha256=$(cat artifacts-sha256)" >> "$GITHUB_OUTPUT"
145+
146+
provenance:
147+
needs: [release, provenance-subject]
148+
permissions:
149+
actions: read # To read the workflow path.
150+
id-token: write # To sign the provenance.
151+
contents: write # To add assets to a release.
152+
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
153+
with:
154+
base64-subjects: "${{ needs.provenance-subject.outputs.artifacts-sha256 }}"
155+
upload-assets: true # Upload to a new release.
156+
compile-generator: true # Build the generator from source.
157+
158+
github_release:
159+
needs: [release]
160+
runs-on: ubuntu-latest
161+
if: startsWith(github.ref, 'refs/tags/')
162+
steps:
163+
- name: Checkout repository
164+
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
165+
- name: Download artifacts
166+
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1
167+
with:
168+
name: gradle-build-outputs
169+
path: build/repo
170+
- name: Upload assets
171+
# Upload the artifacts and SLSA L3 provenance as assets to the existing
172+
# release. Note that the provenance will attest to each artifact file and
173+
# not the aggregated ZIP file.
174+
run: |
175+
find build/repo -regextype sed -regex '\(.*\.jar\|.*\.pom\|.*\.module\|.*\.toml\)' | xargs zip artifacts.zip
176+
gh release upload ${{ github.ref_name }} artifacts.zip
177+
env:
178+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/sonarqube.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ jobs:
3737
- name: Set up JDK
3838
uses: actions/setup-java@v3
3939
with:
40-
distribution: 'adopt'
4140
java-version: 11
41+
distribution: 'temurin'
4242
- name: Optional setup step
4343
env:
4444
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
@@ -56,3 +56,5 @@ jobs:
5656
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
5757
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
5858
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
GH_TOKEN_PUBLIC_REPOS_READONLY: ${{ secrets.GH_TOKEN_PUBLIC_REPOS_READONLY }}
60+
GH_USERNAME: ${{ secrets.GH_USERNAME }}

0 commit comments

Comments
 (0)