Skip to content

Commit

Permalink
add cosign to sign the released binaries
Browse files Browse the repository at this point in the history
Signed-off-by: jiaxiao zhou <[email protected]>
  • Loading branch information
Mossaka committed Jan 24, 2024
1 parent 4d4d680 commit 4c70ecf
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
shell: bash
run: ./scripts/parse_ref.sh ${{ github.ref }} >> ${GITHUB_OUTPUT}

build:
build-and-sign:
needs:
- parse
strategy:
Expand All @@ -38,30 +38,66 @@ jobs:
runs-on: "ubuntu-22.04"
steps:
- uses: actions/checkout@v3

- name: Setup build env
run: ./scripts/setup-linux.sh
- uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Setup rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
env:
RUST_CACHE_KEY_OS: rust-release-cache-${{ needs.parse.outputs.crate }}-${{ matrix.arch }}
with:
rustflags: '' #Disable. By default this action sets environment variable is set to -D warnings. We manage this in the Makefile

- name: Setup cross-rs
run: ./scripts/setup-cross.sh ${{ matrix.arch }}-unknown-linux-musl

- name: Setup build profile
shell: bash
run: echo "OPT_PROFILE=release" >> ${GITHUB_ENV}

- name: Setup cosign for signing
uses: sigstore/[email protected]
with:
cosign-release: 'v2.2.2'

- name: Build
timeout-minutes: 20
run: make build-${{ needs.parse.outputs.runtime }}

- name: Test
if: ${{ matrix.arch == 'x86_64' }}
timeout-minutes: 10
run: make test-${{ needs.parse.outputs.runtime }}

- name: Sign the binary
if: ${{ needs.parse.outputs.runtime != 'wasm' }}
run: |
make dist-${{ needs.parse.outputs.runtime }}
# Check if there's any files to archive as tar fails otherwise
if stat dist/bin/* >/dev/null 2>&1; then
cosign sign-blob --yes \
--output-certificate dist/bin/containerd-shim-${{ needs.parse.outputs.runtime }}-v1-crt.pem \
--output-signature dist/bin/containerd-shim-${{ needs.parse.outputs.runtime }}-v1.sig \
dist/bin/containerd-shim-${{ needs.parse.outputs.runtime }}-v1
cosign sign-blob --yes \
--output-certificate dist/bin/containerd-shim-${{ needs.parse.outputs.runtime }}d-v1-crt.pem \
--output-signature dist/bin/containerd-shim-${{ needs.parse.outputs.runtime }}d-v1.sig \
dist/bin/containerd-shim-${{ needs.parse.outputs.runtime }}d-v1
cosign sign-blob --yes \
--output-certificate dist/bin/containerd-${{ needs.parse.outputs.runtime }}d-v1-crt.pem \
--output-signature dist/bin/containerd-${{ needs.parse.outputs.runtime }}d-v1.sig \
dist/bin/containerd-${{ needs.parse.outputs.runtime }}d
else
echo "No files to sign"
fi
- name: Package artifacts
if: ${{ needs.parse.outputs.runtime != 'wasm' }}
shell: bash
run: |
make dist-${{ needs.parse.outputs.runtime }}
# Check if there's any files to archive as tar fails otherwise
if stat dist/bin/* >/dev/null 2>&1; then
tar -czf dist/containerd-shim-${{ needs.parse.outputs.runtime }}-${{ matrix.arch }}.tar.gz -C dist/bin .
Expand All @@ -79,7 +115,7 @@ jobs:
permissions:
contents: write
needs:
- build
- build-and-sign
- parse
runs-on: ubuntu-latest
steps:
Expand Down

0 comments on commit 4c70ecf

Please sign in to comment.