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

.github/workflows: add wasi-demo-app to the publish pipeline #733

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
70e0475
.github/workflows: add wasi-demo-app to the publish pipeline
Mossaka Nov 17, 2024
c8a2c5f
refactor(workflows): extract wasi-demo-app release job to a dedicated…
Mossaka Dec 16, 2024
ded7be8
feat(workflows): add dry-run option for wasi-demo-app release workflo…
Mossaka Dec 16, 2024
285c30c
fix(workflows): update workflow name to 'Release wasi-demo-app' for c…
Mossaka Dec 16, 2024
56e8cc7
fix(ci): correct filename and indentation in release workflow
Mossaka Dec 16, 2024
9f0a4f7
fix(ci): remove unnecessary sudo in build commands
Mossaka Dec 16, 2024
bc2c389
refactor(ci): streamline image build and load steps
Mossaka Dec 16, 2024
ae1b941
fix(ci): use repository_owner for image push
Mossaka Dec 16, 2024
d3ed234
feat(ci): add image tagging before pushing
Mossaka Dec 16, 2024
f3197d9
feat(ci): push both versioned and latest tags for images
Mossaka Dec 16, 2024
89286c5
feat(ci): push both versioned and latest tags for images
Mossaka Dec 16, 2024
eb2e637
feat(ci): add SBOM and signing workflows for OCI images
Mossaka Dec 16, 2024
b0b91c2
fix(ci): correct image reference to use tag instead of digest
Mossaka Dec 16, 2024
833e1b0
feat(ci): use image digests for signing and SBOM generation
Mossaka Dec 16, 2024
b3fb61b
fix(ci): use github.repository_owner for image references
Mossaka Dec 16, 2024
13440cd
fix(ci): use github.repository for image reference
Mossaka Dec 16, 2024
9a59c26
fix(ci): use lowercase repository name
Mossaka Dec 16, 2024
28f742d
fix(ci): adjust syft command and repository reference for signing
Mossaka Dec 16, 2024
452c94f
fix(ci): Removed matrix strategy for architecture in sbom.yml
Mossaka Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions .github/workflows/release-wasi-demo-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json

name: Release wasi-demo-app
run-name: wasi-demo-app@${{ inputs.version }}

on:
workflow_dispatch:
inputs:
version:
description: "The version of the image to release. (e.g., 1.2.3)"
type: string
required: true
dry_run:
description: "Run the release without actually releasing bits"
type: boolean
default: true

env:
CARGO_TERM_COLOR: always

jobs:
release-wasi-demo:
permissions:
packages: write
runs-on: ubuntu-latest
outputs:
wasi_demo_app_digest: ${{ steps.get_digests.outputs.wasi_demo_app_digest }}
wasi_demo_oci_digest: ${{ steps.get_digests.outputs.wasi_demo_oci_digest }}
wasi_demo_oci_artifact_digest: ${{ steps.get_digests.outputs.wasi_demo_oci_artifact_digest }}
steps:
- uses: actions/checkout@v4
- name: Setup build env
run: ./scripts/setup-linux.sh
- name: Install Rust and wasm32-wasi target
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-wasi
override: true
- name: Build oci tarballs
run: |
make load
make load/oci
sudo ctr image ls
- name: Tagging images
run: |
sudo ctr image tag ghcr.io/containerd/runwasi/wasi-demo-app:latest ghcr.io/${{ github.repository }}/wasi-demo-app:${{ inputs.version }}
sudo ctr image tag ghcr.io/containerd/runwasi/wasi-demo-oci:latest ghcr.io/${{ github.repository }}/wasi-demo-app:latest

sudo ctr image tag ghcr.io/containerd/runwasi/wasi-demo-oci:latest ghcr.io/${{ github.repository }}/wasi-demo-oci:${{ inputs.version }}
sudo ctr image tag ghcr.io/containerd/runwasi/wasi-demo-oci:latest ghcr.io/${{ github.repository }}/wasi-demo-oci:latest

sudo ctr image tag ghcr.io/containerd/runwasi/wasi-demo-oci-artifact:latest ghcr.io/${{ github.repository }}/wasi-demo-oci-artifact:${{ inputs.version }}
sudo ctr image tag ghcr.io/containerd/runwasi/wasi-demo-oci-artifact:latest ghcr.io/${{ github.repository }}/wasi-demo-oci-artifact:latest

- name: Push images to ghcr.io
if: ${{ inputs.dry_run == false }}
run: |
sudo ctr images push --user ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} ghcr.io/${{ github.repository }}/wasi-demo-app:${{ inputs.version }}
sudo ctr images push --user ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} ghcr.io/${{ github.repository }}/wasi-demo-app:latest

sudo ctr images push --user ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} ghcr.io/${{ github.repository }}/wasi-demo-oci:${{ inputs.version }}
sudo ctr images push --user ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} ghcr.io/${{ github.repository }}/wasi-demo-oci:latest

sudo ctr images push --user ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} ghcr.io/${{ github.repository }}/wasi-demo-oci-artifact:${{ inputs.version }}
sudo ctr images push --user ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} ghcr.io/${{ github.repository }}/wasi-demo-oci-artifact:latest

- name: Display image digests
id: get_digests
run: |
digest_wasi_demo_app=$(sudo ctr images ls | grep "ghcr.io/${{ github.repository }}/wasi-demo-app:${{ inputs.version }}" | awk '{print $3}')
echo "Digest for wasi-demo-app: $digest_wasi_demo_app"
echo "wasi_demo_app_digest=$digest_wasi_demo_app" >> $GITHUB_OUTPUT

digest_wasi_demo_oci=$(sudo ctr images ls | grep "ghcr.io/${{ github.repository }}/wasi-demo-oci:${{ inputs.version }}" | awk '{print $3}')
echo "Digest for wasi-demo-oci: $digest_wasi_demo_oci"
echo "wasi_demo_oci_digest=$digest_wasi_demo_oci" >> $GITHUB_OUTPUT

digest_wasi_demo_oci_artifact=$(sudo ctr images ls | grep "ghcr.io/${{ github.repository }}/wasi-demo-oci-artifact:${{ inputs.version }}" | awk '{print $3}')
echo "Digest for wasi-demo-oci-artifact: $digest_wasi_demo_oci_artifact"
echo "wasi_demo_oci_artifact_digest=$digest_wasi_demo_oci_artifact" >> $GITHUB_OUTPUT

sign-wasi-demo-app:
if: ${{ inputs.dry_run == false }}
needs:
- release-wasi-demo
uses: ./.github/workflows/sign.yml
with:
image-name: "wasi-demo-app"
image-digest: ${{ needs.release-wasi-demo.outputs.wasi_demo_app_digest }}

sbom-wasi-demo-app:
if: ${{ inputs.dry_run == false }}
needs:
- release-wasi-demo
uses: ./.github/workflows/sbom.yml
with:
image-name: "wasi-demo-app"
image-digest: ${{ needs.release-wasi-demo.outputs.wasi_demo_app_digest }}


sign-wasi-demo-oci:
if: ${{ inputs.dry_run == false }}
needs:
- release-wasi-demo
uses: ./.github/workflows/sign.yml
with:
image-name: "wasi-demo-oci"
image-digest: ${{ needs.release-wasi-demo.outputs.wasi_demo_oci_digest }}


sbom-wasi-demo-oci:
if: ${{ inputs.dry_run == false }}
needs:
- release-wasi-demo
uses: ./.github/workflows/sbom.yml
with:
image-name: "wasi-demo-oci"
image-digest: ${{ needs.release-wasi-demo.outputs.wasi_demo_oci_digest }}


sign-wasi-demo-oci-artifact:
if: ${{ inputs.dry_run == false }}
needs:
- release-wasi-demo
uses: ./.github/workflows/sign.yml
with:
image-name: "wasi-demo-oci-artifact"
image-digest: ${{ needs.release-wasi-demo.outputs.wasi_demo_oci_artifact_digest }}


sbom-wasi-demo-oci-artifact:
if: ${{ inputs.dry_run == false }}
needs:
- release-wasi-demo
uses: ./.github/workflows/sbom.yml
with:
image-name: "wasi-demo-oci-artifact"
image-digest: ${{ needs.release-wasi-demo.outputs.wasi_demo_oci_artifact_digest }}
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,4 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
RELEASE_NAME: ${{ matrix.crate }}/v${{ matrix.version }}

83 changes: 83 additions & 0 deletions .github/workflows/sbom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Generate SBOMs

on:
workflow_call:
inputs:
image-name:
type: string
required: true
image-digest:
type: string
required: true

jobs:
sbom:
name: Generate SBOM, sign and attach them to OCI image
permissions:
packages: write
id-token: write

runs-on: ubuntu-latest
steps:
- name: Install cosign
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0

- name: Install syft
uses: anchore/sbom-action/download-syft@e8d2a6937ecead383dfe75190d104edd1f9c5751 # v0.16.0

- name: Install crane
uses: IAreKyleW00t/crane-installer@66858ae469ebd32ce731051d9c2bae9b811537e9 # v1.3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Find platform digest
shell: bash
run: |
set -e
IMG_REPOSITORY_NAME=$( echo ${{ github.repository }} | awk '{print tolower($0)}' )
echo IMG_REPOSITORY_NAME=${IMG_REPOSITORY_NAME} >> $GITHUB_ENV
DIGEST=$(crane digest \
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can accomplish the same thing with docker which is already installed. I would prefer not installing extra GitHub actions if not needed.

ghcr.io/${IMG_REPOSITORY_NAME}/${{ inputs.image-name }}@${{ inputs.image-digest }})
echo "PLATFORM_DIGEST=${DIGEST}" >> "$GITHUB_ENV"

- name: Create SBOM file
shell: bash
run: |
SYFT=$(which syft)
sudo $SYFT \
-o spdx-json \
--file ${{ inputs.image-name }}-sbom.spdx \
ghcr.io/${{ env.IMG_REPOSITORY_NAME }}/${{ inputs.image-name }}@${{ env.PLATFORM_DIGEST }}

- name: Sign SBOM file
run: |
cosign sign-blob --yes \
--output-certificate ${{ inputs.image-name }}-sbom.spdx.cert \
--output-signature ${{ inputs.image-name }}-sbom.spdx.sig \
${{ inputs.image-name }}-sbom.spdx

- name: Attach SBOM to container image
shell: bash
run: |
cosign attach \
sbom --sbom ${{ inputs.image-name }}-sbom.spdx \
ghcr.io/${{ env.IMG_REPOSITORY_NAME }}/${{ inputs.image-name }}@${{ env.PLATFORM_DIGEST }}

- name: Sign SBOM file pushed to OCI registry
shell: bash
run: |
set -e
SBOM_TAG="$(echo ${{ env.PLATFORM_DIGEST }} | sed -e 's/:/-/g').sbom"
cosign sign --yes \
ghcr.io/${{ env.IMG_REPOSITORY_NAME }}/${{ inputs.image-name }}:${SBOM_TAG}

- name: Upload SBOMs as artifacts
uses: actions/upload-artifact@v4
with:
name: sbom
path: ${{ inputs.image-name }}-sbom-*
36 changes: 36 additions & 0 deletions .github/workflows/sign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Sign image

on:
workflow_call:
inputs:
image-name:
type: string
required: true
image-digest:
type: string
required: true

jobs:
sign:
name: Sign image
permissions:
packages: write
id-token: write

runs-on: ubuntu-latest
steps:
- name: Install cosign
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0

- name: Login to GitHub Container Registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
registry: ghcr.io
username: ${{ github.repository }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Sign container image
run: |
IMG_REPOSITORY_NAME=$( echo ${{ github.repository }} | awk '{print tolower($0)}' )
cosign sign --yes \
ghcr.io/${IMG_REPOSITORY_NAME}/${{ inputs.image-name }}@${{ inputs.image-digest }}
Loading