Skip to content

ci: Attempting a different name for intermediate steps in provenance … #18

ci: Attempting a different name for intermediate steps in provenance …

ci: Attempting a different name for intermediate steps in provenance … #18

Workflow file for this run

# SPDX-License-Identifier: MPL-2.0
name: Create Complete Source Archive
on:
push:
tags: [ v* ]
branches: [ feature/hardening ]
jobs:
archive:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false # so that if one config fails, other won't be cancelled automatically
matrix:
config:
- {
name: "Windows",
os: windows-latest,
extension: ".zip"
}
- {
name: "Linux",
os: ubuntu-latest,
extension: ".tar.xz",
}
outputs:
#store hashes for slsa provenance
hash-SourceCode_With_Submodules-Windows: ${{ steps.hash.outputs.hash-SourceCode_With_Submodules-Windows }}
hash-SourceCode_With_Submodules-Linux: ${{ steps.hash.outputs.hash-SourceCode_With_Submodules-Linux }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Escape backslash in branch name
shell: bash
run: echo "BRANCH_NAME=$(echo ${{ github.ref_name }} | tr / -)" >> $GITHUB_ENV
- name: Setting release name
env:
ARCHIVENAME: ${{ format('openSeaChest-{0}', env.BRANCH_NAME) }}
run: |
echo "ARCHIVENAME=${ARCHIVENAME}" >> $GITHUB_ENV
shell: bash
- name: Create Source Archive
run: |
pip install git-archive-all
git-archive-all --prefix=${{ env.ARCHIVENAME }} SourceCode_With_Submodules${{ matrix.config.extension }}
- name: Generate Hashes
shell: bash
id: hash
run: |
# sha256sum generates sha256 hash for all artifacts.
# base64 -w0 encodes to base64 and outputs on a single line.
# sha256sum artifact | base64 -w0
# NOTE: Using suggested method to generate sha across OS's from slsa documentation
# https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/generic/README.md#provenance-for-artifacts-built-across-multiple-operating-systems
set -euo pipefail
(sha256sum -t ${{ format('SourceCode_With_Submodules{0}', matrix.config.extension) }} || shasum -a 256 ${{ format('SourceCode_With_Submodules{0}', matrix.config.extension) }}) > checksum
echo "checksum = $checksum"
echo "hash-SourceCode_With_Submodules-${{ matrix.config.name }}=$(base64 -w0 checksum || base64 checksum)" >> "${GITHUB_OUTPUT}"
- name: Upload Source Archive as Artifact
uses: actions/upload-artifact@v4
with:
name: SourceCode_With_Submodules-${{ matrix.config.name }}
path: SourceCode_With_Submodules${{ matrix.config.extension }}
- name: Publish Source Archive to Release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: softprops/action-gh-release@v2
with:
files: SourceCode_With_Submodules${{ matrix.config.extension }}
# Generate the slsa provenance
provenance:
needs: [archive]
strategy:
fail-fast: false #don't cancel other jobs if one is failing
matrix:
package_name: [ "SourceCode_With_Submodules-Windows",
"SourceCode_With_Submodules-Linux" ]
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/generator_generic_slsa3.yml@v2.0.0
with:
base64-subjects: "${{ needs.build.outputs[format('hash-{0}', matrix.package_name)] }}"
# Upload provenance to a new release
upload-assets: true