Skip to content

Merge pull request #3 from wasmCloud/fix_oci_vars #40

Merge pull request #3 from wasmCloud/fix_oci_vars

Merge pull request #3 from wasmCloud/fix_oci_vars #40

Workflow file for this run

name: Build and Test
on:
push:
branches:
- "main"
tags:
- "v*"
pull_request:
branches:
- "main"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Lint
run: |
cargo clippy -- --no-deps
- name: Test
run: |
cargo test
build:
needs:
- check
strategy:
matrix:
arch: ["x86_64", "aarch64"]
runs-on: ubuntu-latest
if: startswith(github.ref, 'refs/tags/v') # Only run on tag push
steps:
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
- name: Add musl targets
run: |
rustup target add ${{ matrix.arch }}-unknown-linux-musl
- name: Install cargo-zigbuild
run: |
cargo install cargo-zigbuild
- name: Build
run: |
cargo zigbuild --release --target ${{matrix.arch}}-unknown-linux-musl
- name: Store artifact
uses: actions/upload-artifact@v4
with:
name: wasmcloud-operator-${{matrix.arch}}
path: target/${{matrix.arch}}-unknown-linux-musl/release/wasmcloud-operator
release:
needs:
- build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: startswith(github.ref, 'refs/tags/v') # Only run on tag push
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,prefix=
type=semver,pattern={{version}}
- name: Load artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Fix permissions and architectures
run: |
mv artifacts/wasmcloud-operator-x86_64/wasmcloud-operator artifacts/wasmcloud-operator-amd64
mv artifacts/wasmcloud-operator-aarch64/wasmcloud-operator artifacts/wasmcloud-operator-arm64
chmod +x artifacts/wasmcloud-operator*
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
push: true
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
build-args: "BIN_PATH=artifacts/wasmcloud-operator"