From 6519df36ac47a410e0df48ed5d0f4c3159e3cdbc Mon Sep 17 00:00:00 2001 From: jiaxiao zhou Date: Sat, 2 Sep 2023 20:35:26 +0000 Subject: [PATCH] Fixed the release pipeline Signed-off-by: jiaxiao zhou --- .github/workflows/docker-build-push.yaml | 71 +++++++++++++++++------- .github/workflows/release.yaml | 28 ++++------ 2 files changed, 61 insertions(+), 38 deletions(-) diff --git a/.github/workflows/docker-build-push.yaml b/.github/workflows/docker-build-push.yaml index 82f612d7..2c9a9547 100644 --- a/.github/workflows/docker-build-push.yaml +++ b/.github/workflows/docker-build-push.yaml @@ -1,29 +1,60 @@ name: 'Build and push Docker images' on: workflow_call: - inputs: - images: - required: true - type: string - platforms: - required: true - type: string - secrets: - envPAT: - required: true + jobs: build_and_push: + permissions: + contents: write + packages: write runs-on: ubuntu-latest strategy: matrix: - image: ${{fromJson(github.event.inputs.images)}} + image: + - imageName: examples/spin-rust-hello + context: images/spin + - imageName: examples/spin-dotnet-hello + context: images/spin_dotnet + - imageName: examples/slight-rust-hello + context: images/slight + - imageName: examples/wws-js-hello + context: images/wws + - imageName: examples/spin-inbound-redis + context: images/spin-inbound-redis + - imageName: examples/spin-outbound-redis + context: images/spin-outbound-redis + - imageName: examples/lunatic-rust-hello + context: images/lunatic + - imageName: examples/lunatic-spawn-process + context: images/lunatic-spawn-process + - imageName: examples/lunatic-submillisecond + context: images/lunatic-submillisecond steps: - - name: build and push - uses: docker/build-push-action@v3 - with: - push: true - tags: | - ghcr.io/deislabs/containerd-wasm-shims/${{ matrix.image.imageName }}:${{ env.RELEASE_VERSION }} - ghcr.io/deislabs/containerd-wasm-shims/${{ matrix.image.imageName }}:latest - context: ${{ matrix.image.context }} - platforms: ${{ github.event.inputs.platforms }} \ No newline at end of file + - uses: actions/checkout@v3 + - name: Set RELEASE_VERSION ENV var + run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV + - name: lowercase the runner OS name + shell: bash + run: | + OS=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]') + echo "RUNNER_OS=$OS" >> $GITHUB_ENV + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: setup buildx + uses: docker/setup-buildx-action@v2 + - name: login to GitHub container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: build and push + uses: docker/build-push-action@v3 + with: + push: true + tags: | + ghcr.io/deislabs/containerd-wasm-shims/${{ matrix.image.imageName }}:${{ env.RELEASE_VERSION }} + ghcr.io/deislabs/containerd-wasm-shims/${{ matrix.image.imageName }}:latest + context: ${{ matrix.image.context }} + platforms: wasi/wasm + \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a2a9697e..b3951113 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -2,10 +2,14 @@ name: release on: push: tags: - - 'v[0-9]+.[0-9]+.*' + - "v[0-9]+.[0-9]+.*" jobs: build: uses: ./.github/workflows/build.yaml + + build-and-push-wasm-images: + uses: ./.github/workflows/docker-build-push.yaml + release: permissions: contents: write @@ -14,7 +18,7 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set RELEASE_VERSION ENV var run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV - name: lowercase the runner OS name @@ -32,7 +36,7 @@ jobs: path: _artifacts - name: create release env: - GH_TOKEN: ${{ secrets.envPAT }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh release create ${{ env.RELEASE_VERSION }} \ --generate-notes \ @@ -52,21 +56,9 @@ jobs: with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.envPAT }} - - name: Build and push images - uses: ./.github/workflows/build_and_push.yaml - with: - images: | - [{"imageName": "examples/spin-rust-hello", "context": "images/spin"}, - {"imageName": "examples/spin-dotnet-hello", "context": "images/spin_dotnet"}, - {"imageName": "examples/slight-rust-hello", "context": "images/slight"}, - {"imageName": "examples/wws-js-hello", "context": "images/wws"}, - {"imageName": "examples/spin-inbound-redis", "context": "images/spin-inbound-redis"}, - {"imageName": "examples/spin-outbound-redis", "context": "images/spin-outbound-redis"}], - {"imageName": "examples/lunatic-rust-hello", "context": "images/lunatic"}], - {"imageName": "examples/lunatic-spawn-process", "context": "images/lunatic-spawn-process"}], - {"imageName": "examples/lunatic-submillisecond", "context": "images/lunatic-submillisecond"}] - platforms: wasi/wasm + password: ${{ secrets.GITHUB_TOKEN }} + + # Build and push k3d shim image - name: untar x86_64 musl artifacts into ./deployments/k3d/.tmp dir run: | mkdir -p ./deployments/k3d/.tmp