Skip to content
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

fix: gradle builds [TEST] #3242

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/builder_bazel_slsa3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ jobs:
id-token: write # For signing.
contents: read # For asset uploads.
actions: read # For the entrypoint.
uses: slsa-framework/slsa-github-generator/.github/workflows/delegator_lowperms-generic_slsa3.yml@main
uses: ramonpetgrave64/slsa-github-generator/.github/workflows/delegator_lowperms-generic_slsa3.yml@gradle-debug
with:
slsa-token: ${{ needs.slsa-setup.outputs.slsa-token }}
4 changes: 2 additions & 2 deletions .github/workflows/builder_gradle_slsa3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
steps:
- name: Generate the token
id: generate
uses: slsa-framework/slsa-github-generator/actions/delegator/setup-generic@main
uses: ramonpetgrave64/slsa-github-generator/actions/delegator/setup-generic@gradle-debug
with:
slsa-workflow-recipient: "delegator_lowperms-generic_slsa3.yml"
slsa-rekor-log-public: ${{ inputs.rekor-log-public }}
Expand All @@ -85,7 +85,7 @@ jobs:
id-token: write # For signing.
contents: read # For asset uploads.
actions: read # For the entrypoint.
uses: slsa-framework/slsa-github-generator/.github/workflows/delegator_lowperms-generic_slsa3.yml@main
uses: ramonpetgrave64/slsa-github-generator/.github/workflows/delegator_lowperms-generic_slsa3.yml@gradle-debug
with:
slsa-token: ${{ needs.slsa-setup.outputs.slsa-token }}

Expand Down
8 changes: 1 addition & 7 deletions internal/builders/gradle/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,9 @@ runs:
PROJECT_ROOT: ${{ steps.run_gradle_builder.outputs.validated_project_root }}
run: |
cd "${PROJECT_ROOT}" && "${GITHUB_WORKSPACE}"/../__TOOL_ACTION_DIR__/create_attestation.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cd "${PROJECT_ROOT}" && "${GITHUB_WORKSPACE}"/../__TOOL_ACTION_DIR__/create_attestation.sh
cd "${PROJECT_ROOT}" && "${GITHUB_WORKSPACE}"/../__TOOL_ACTION_DIR__/create_attestation.sh
mv "${PROJECT_ROOT}/slsa-build ${GITHUB_WORKSPACE}"/

move the slsa-build dir to the workspace so upload-build-dir can see slsa-build folder

- name: Move build dir to avoid making it a sub-dir when uploading
shell: bash
env:
PROJECT_ROOT: ${{ steps.run_gradle_builder.outputs.validated_project_root }}
run: |
mv "${PROJECT_ROOT}"/build "${GITHUB_WORKSPACE}"/
- name: Upload build dir
id: upload-build-dir
uses: slsa-framework/slsa-github-generator/.github/actions/secure-upload-folder@main
with:
name: "${{ steps.rng.outputs.random }}-build"
path: build
path: slsa-build
4 changes: 2 additions & 2 deletions internal/builders/gradle/collect_release_artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

set -euo pipefail

mkdir release-files-for-slsa
mkdir slsa-build
GRADLE_VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}')

# Move artifacts from the user-supplied artifact list
Expand All @@ -38,5 +38,5 @@ do

# Move the file
bn=$(basename -- "$path_with_version")
cp "$path_with_version" release-files-for-slsa/"$bn"
cp "$path_with_version" slsa-build/"$bn"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OR just work directly from GITHUB_WORKSPACE and make sure you use PROJECT_ROOT to prefix the path

Suggested change
cp "$path_with_version" slsa-build/"$bn"
cp ${PROJECT_ROOT}/"$path_with_version" slsa-build/"$bn"

done
4 changes: 2 additions & 2 deletions internal/builders/gradle/create_attestation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ SLSA_OUTPUTS_ARTIFACTS_FILE="${GITHUB_WORKSPACE}/${SLSA_OUTPUTS_ARTIFACTS_FILE}"
# "version" and "attestations" fields:
echo -e -n "{\n \"version\": 1,\n \"attestations\": [" >> "$SLSA_OUTPUTS_ARTIFACTS_FILE"

num_jar_files=$(find ./release-files-for-slsa -type f | wc -l)
num_jar_files=$(find ./slsa-build -type f | wc -l)
counter=1

# Add one attestation per .jar file:
find ./release-files-for-slsa -type f -print0 | while read -r -d $'\0' fname
find ./slsa-build -type f -print0 | while read -r -d $'\0' fname
do

bn=$(basename -- "$fname")
Expand Down