-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #548 from containerd/opt-release
ci(*): merge build action
- Loading branch information
Showing
9 changed files
with
127 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json | ||
|
||
name: Run lint | ||
|
||
on: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json | ||
|
||
name: Signing | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
runtime: | ||
required: true | ||
type: string | ||
os: | ||
required: true | ||
type: string | ||
jobs: | ||
sign: | ||
name: Sign the binaries on ${{ inputs.os }} | ||
runs-on: ${{ inputs.os }} | ||
steps: | ||
- name: Setup cosign for signing | ||
uses: sigstore/[email protected] | ||
with: | ||
cosign-release: 'v2.2.2' | ||
- name: Sign the binaries | ||
run: | | ||
make dist-${{ inputs.runtime }} | ||
# Check if there's any files to archive as tar fails otherwise | ||
if stat dist/bin/* >/dev/null 2>&1; then | ||
echo "::notice::Signing the binary" | ||
cosign sign-blob --yes \ | ||
--output-signature containerd-shim-${{ inputs.runtime }}-v1.sig \ | ||
--output-certificate containerd-shim-${{ inputs.runtime }}-v1.pem \ | ||
--bundle containerd-shim-${{ inputs.runtime }}-v1.bundle \ | ||
dist/bin/containerd-shim-${{ inputs.runtime }}-v1 | ||
cosign sign-blob --yes \ | ||
--output-signature containerd-shim-${{ inputs.runtime }}d-v1.sig \ | ||
--output-certificate containerd-shim-${{ inputs.runtime }}d-v1.pem \ | ||
--bundle containerd-shim-${{ inputs.runtime }}d-v1.bundle \ | ||
dist/bin/containerd-shim-${{ inputs.runtime }}d-v1 | ||
cosign sign-blob --yes \ | ||
--output-signature containerd-${{ inputs.runtime }}d.sig \ | ||
--output-certificate containerd-${{ inputs.runtime }}d.pem \ | ||
--bundle containerd-${{ inputs.runtime }}d.bundle \ | ||
dist/bin/containerd-${{ inputs.runtime }}d | ||
# Copy the certs to the dist/bin folder | ||
cp *.sig dist/bin/ | ||
cp *.pem dist/bin/ | ||
else | ||
echo "::warning::No files to sign" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json | ||
|
||
name: Release | ||
run-name: ${{ inputs.crate }}@${{ inputs.version }} (DryRun:${{ inputs.dry_run }}) | ||
|
||
|
@@ -46,7 +48,7 @@ jobs: | |
- name: Fail if branch is not main | ||
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' | ||
run: | | ||
echo "This workflow should not be triggered with workflow_dispatch on a branch other than main" | ||
echo "::error::This workflow should not be triggered with workflow_dispatch on a branch other than main" | ||
exit 1 | ||
- uses: actions/checkout@v4 | ||
### Determine the name of the runtime and if it is a binary release or crates.io | ||
|
@@ -64,28 +66,32 @@ jobs: | |
with: | ||
script: | | ||
const crate = '${{ inputs.crate }}'; | ||
let runtime = crate.replace(/^containerd-shim-/, ''); | ||
core.setOutput('runtime', runtime); | ||
const non_shim_crates = ['wasm', 'wasm-test-modules', 'oci-tar-builder']; | ||
core.setOutput('is_shim', !non_shim_crates.includes(runtime)); | ||
if non_shim_crates.includes(runtime) { | ||
core.setOutput('runtime', 'common'); | ||
core.setOutput('is_shim', false) | ||
} else { | ||
const runtime = crate.replace(/^containerd-shim-/, ''); | ||
core.setOutput('runtime', runtime); | ||
core.setOutput('is_shim', true); | ||
} | ||
### If we are releasing a crate rather than producing a bin, check for crates.io access | ||
- name: Check crates.io ownership | ||
if: ${{ steps.runtime_sub.outputs.is_shim != 'true' }} | ||
run: | | ||
cargo owner --list ${{ inputs.crate }} | grep github:containerd:runwasi-committers || \ | ||
cargo owner --add github:containerd:runwasi-committers ${{ inputs.crate }} | ||
cargo owner --add github:containerd:runwasi-committers ${{ inputs.crate }} | ||
env: | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }} | ||
- name: Verify version matches | ||
run: | | ||
if [ "$(grep -c "version = \"${{ inputs.version }}\"" crates/${{ inputs.crate }}/Cargo.toml)" -ne 1 ]; then | ||
echo "Version in Cargo.toml does not match the version input" | ||
echo "::error::Version in Cargo.toml does not match the version input" | ||
exit 1 | ||
fi | ||
build-and-sign: | ||
permissions: | ||
# cosign uses the GitHub OIDC token | ||
id-token: write | ||
needs: | ||
- pre-release | ||
|
@@ -94,83 +100,14 @@ jobs: | |
arch: ["x86_64", "aarch64"] | ||
include: | ||
- ${{ needs.pre-release.outputs }} | ||
runs-on: "ubuntu-22.04" | ||
steps: | ||
- name: Matrix description | ||
run: | | ||
echo "Running job with dry_run: '${{ inputs.dry_run }}' crate: '${{ matrix.crate }}', version: '${{ matrix.version }}', runtime: '${{ matrix.runtime }}', and is_shim: '${{ matrix.is_shim }}'." | ||
- uses: actions/checkout@v4 | ||
- name: Setup build env | ||
run: ./scripts/setup-linux.sh | ||
- name: Setup rust toolchain | ||
uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
env: | ||
RUST_CACHE_KEY_OS: rust-release-cache-${{ matrix.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 | ||
if: ${{ matrix.is_shim == 'true' }} | ||
uses: sigstore/[email protected] | ||
with: | ||
cosign-release: 'v2.2.2' | ||
- name: Build | ||
timeout-minutes: 20 | ||
run: make build-${{ matrix.runtime }} | ||
- name: Test | ||
if: ${{ matrix.arch == 'x86_64' }} | ||
timeout-minutes: 10 | ||
run: make test-${{ matrix.runtime }} | ||
- name: Sign the binary | ||
if: ${{ matrix.is_shim == 'true' }} | ||
run: | | ||
make dist-${{ matrix.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-signature containerd-shim-${{ matrix.runtime }}-v1.sig \ | ||
--output-certificate containerd-shim-${{ matrix.runtime }}-v1.pem \ | ||
--bundle containerd-shim-${{ matrix.runtime }}-v1.bundle \ | ||
dist/bin/containerd-shim-${{ matrix.runtime }}-v1 | ||
cosign sign-blob --yes \ | ||
--output-signature containerd-shim-${{ matrix.runtime }}d-v1.sig \ | ||
--output-certificate containerd-shim-${{ matrix.runtime }}d-v1.pem \ | ||
--bundle containerd-shim-${{ matrix.runtime }}d-v1.bundle \ | ||
dist/bin/containerd-shim-${{ matrix.runtime }}d-v1 | ||
cosign sign-blob --yes \ | ||
--output-signature containerd-${{ matrix.runtime }}d.sig \ | ||
--output-certificate containerd-${{ matrix.runtime }}d.pem \ | ||
--bundle containerd-${{ matrix.runtime }}d.bundle \ | ||
dist/bin/containerd-${{ matrix.runtime }}d | ||
# Copy the certs to the dist/bin folder | ||
cp *.sig dist/bin/ | ||
cp *.pem dist/bin/ | ||
else | ||
echo "No files to sign" | ||
fi | ||
- name: Package artifacts | ||
if: ${{ matrix.is_shim == 'true' }} | ||
shell: bash | ||
run: | | ||
# 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-${{ matrix.runtime }}-${{ matrix.arch }}.tar.gz -C dist/bin . | ||
else | ||
tar -czf dist/containerd-shim-${{ matrix.runtime }}-${{ matrix.arch }}.tar.gz -T /dev/null | ||
fi | ||
- name: Upload artifacts | ||
if: ${{ matrix.is_shim == 'true' }} | ||
uses: actions/upload-artifact@master | ||
with: | ||
name: containerd-shim-${{ matrix.runtime }}-${{ matrix.arch }} | ||
path: dist/containerd-shim-${{ matrix.runtime }}-${{ matrix.arch }}.tar.gz | ||
uses: ./.github/workflows/action-build.yml | ||
with: | ||
os: "ubuntu-22.04" | ||
runtime: ${{ matrix.runtime }} | ||
target: "${{ matrix.arch }}-unknown-linux-musl" | ||
slug: "${{ matrix.arch }}-linux-musl" | ||
arch: ${{ matrix.arch }} | ||
sign: true | ||
|
||
release: | ||
permissions: | ||
|
@@ -187,7 +124,7 @@ jobs: | |
steps: | ||
- name: Matrix description | ||
run: | | ||
echo "Running job with dry_run: '${{ inputs.dry_run }}', crate: '${{ matrix.crate }}', version: '${{ matrix.version }}', runtime: '${{ matrix.runtime }}', and is_shim: '${{ matrix.is_shim }}'." | ||
echo "::notice::Running job with dry_run: '${{ inputs.dry_run }}', crate: '${{ matrix.crate }}', version: '${{ matrix.version }}', runtime: '${{ matrix.runtime }}', and is_shim: '${{ matrix.is_shim }}'." | ||
- uses: actions/checkout@v4 | ||
- name: Setup build env | ||
run: ./scripts/setup-linux.sh | ||
|