Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

Commit 47be03e

Browse files
devignedMossaka
andauthored
refactor build to use artifacts (#36)
* refactor build to use artifacts Signed-off-by: jiaxiao zhou <[email protected]> Co-authored-by: jiaxiao zhou <[email protected]>
1 parent 4569f73 commit 47be03e

File tree

3 files changed

+34
-40
lines changed

3 files changed

+34
-40
lines changed

.github/workflows/build.yaml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,7 @@ jobs:
2020
env:
2121
ARCH: ${{ matrix.config.arch }}
2222
steps:
23-
- uses: actions/checkout@v2
24-
- uses: actions/cache@v3
25-
with:
26-
path: |
27-
./deployments/k3d/.tmp/
28-
./bin
29-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
30-
restore-keys: |
31-
${{ runner.os }}-cargo-
23+
- uses: actions/checkout@v3
3224
- uses: Swatinem/rust-cache@v2
3325
with:
3426
workspaces: |
@@ -41,9 +33,24 @@ jobs:
4133
- name: build
4234
run: |
4335
make build
44-
rm -rf ./bin && mkdir ./bin
45-
cp containerd-shim-slight-v1/target/release/containerd-shim-*-v1 bin/
46-
cp containerd-shim-spin-v1/target/release/containerd-shim-*-v1 bin/
36+
- name: lowercase the runner OS name
37+
shell: bash
38+
run: |
39+
OS=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]')
40+
echo "RUNNER_OS=$OS" >> $GITHUB_ENV
41+
- name: package release assets
42+
run: |
43+
mkdir _dist
44+
cp containerd-shim-slight-v1/target/${{ matrix.config.arch }}-unknown-linux-musl/release/containerd-shim-*-v1 _dist/
45+
cp containerd-shim-spin-v1/target/${{ matrix.config.arch }}-unknown-linux-musl/release/containerd-shim-*-v1 _dist/
46+
cd _dist
47+
tar czf containerd-wasm-shims-v1-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz containerd-shim-*-v1
48+
- name: upload shim artifacts
49+
uses: actions/upload-artifact@v3
50+
with:
51+
name: containerd-wasm-shims-v1-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}
52+
path: _dist/containerd-wasm-shims-v1-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz
53+
retention-days: 5
4754
- name: build k3d demo
4855
run: make build-image
4956
working-directory: ./deployments/k3d

.github/workflows/release.yaml

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,13 @@ on:
66
jobs:
77
build:
88
uses: ./.github/workflows/build.yaml
9-
109
release:
11-
strategy:
12-
matrix:
13-
config:
14-
- {
15-
os: "ubuntu-latest",
16-
arch: "x86_64",
17-
}
18-
- {
19-
os: "ubuntu-latest",
20-
arch: "aarch64"
21-
}
2210
permissions:
2311
contents: write
2412
packages: write
2513
needs: build
2614
if: startsWith(github.ref, 'refs/tags/v')
27-
runs-on: ${{ matrix.config.os }}
15+
runs-on: ubuntu-latest
2816
steps:
2917
- uses: actions/checkout@v2
3018
- name: Set RELEASE_VERSION ENV var
@@ -34,36 +22,28 @@ jobs:
3422
run: |
3523
OS=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]')
3624
echo "RUNNER_OS=$OS" >> $GITHUB_ENV
37-
- uses: actions/cache@v3
38-
with:
39-
path: |
40-
./deployments/k3d/.tmp/
41-
./bin
42-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
43-
- name: package release assets
44-
run: |
45-
mkdir _dist
46-
cp bin/containerd-shim-*-v1 _dist/
47-
cd _dist
48-
tar czf containerd-wasm-shims-v1-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz containerd-shim-*-v1
4925
- name: copy release workload assets into _dist
5026
run: |
5127
cp ./deployments/workloads/spin/runtime.yaml _dist/spin_runtime.yaml
5228
cp ./deployments/workloads/spin/workload.yaml _dist/spin_workload.yaml
5329
cp ./deployments/workloads/slight/runtime.yaml _dist/slight_runtime.yaml
5430
cp ./deployments/workloads/slight/workload.yaml _dist/slight_workload.yaml
31+
- uses: actions/download-artifact@v3
32+
with:
33+
path: _artifacts
5534
- name: create release
5635
env:
5736
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5837
run: |
5938
gh release create ${{ env.RELEASE_VERSION }} \
6039
--generate-notes \
6140
-p \
62-
_dist/containerd-wasm-shims-v1-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz#containerd-wasm-shims-v1 \
6341
_dist/spin_runtime.yaml#example-spin-runtimes \
6442
_dist/spin_workload.yaml#example-spin-workloads \
6543
_dist/slight_runtime.yaml#example-slight-runtimes \
6644
_dist/slight_workload.yaml#example-slight-workloads
45+
46+
for f in ./_artifacts/*/*.tar.gz; do gh release upload ${{ env.RELEASE_VERSION }} $f; done
6747
- name: setup buildx
6848
uses: docker/setup-buildx-action@v2
6949
- name: login to GitHub container registry
@@ -88,6 +68,11 @@ jobs:
8868
ghcr.io/deislabs/containerd-wasm-shims/examples/slight-rust-hello:${{ env.RELEASE_VERSION }}
8969
ghcr.io/deislabs/containerd-wasm-shims/examples/slight-rust-hello:latest
9070
context: images/slight
71+
- name: untar x86_64 musl artifacts into ./deployments/k3d/.tmp dir
72+
run: |
73+
mkdir -p ./deployments/k3d/.tmp
74+
tar -xf ./_artifacts/containerd-wasm-shims-v1-linux-x86_64/containerd-wasm-shims-v1-linux-x86_64.tar.gz \
75+
--directory ./deployments/k3d/.tmp
9176
- name: build and push k3d shim image
9277
uses: docker/build-push-action@v3
9378
with:

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ PREFIX ?= /usr/local
22
INSTALL ?= install
33
TEST_IMG_NAME_SPIN ?= wasmtest_spin:latest
44
TEST_IMG_NAME_SLIGHT ?= wasmtest_slight:latest
5+
ARCH ?= x86_64
6+
TARGET ?= $(ARCH)-unknown-linux-musl
57

68
CONTAINERD_NAMESPACE ?= default
79

810
.PHONY: build
9-
build: build-spin build-slight
11+
build: build-spin-cross-$(TARGET) build-slight-cross-$(TARGET)
1012
echo "Build complete"
1113

1214
.PHONY: build-spin
@@ -64,4 +66,4 @@ run_slight: install load
6466
clean:
6567
sudo rm -rf $(PREFIX)/bin/containerd-shim-spin-v1
6668
sudo rm -rf $(PREFIX)/bin/containerd-shim-slight-v1
67-
sudo rm -rf ./test
69+
sudo rm -rf ./test

0 commit comments

Comments
 (0)