-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*' | ||
|
||
name: publish Wasm module | ||
|
||
jobs: | ||
build: | ||
name: Create new release with Wasm artifact | ||
runs-on: ubuntu-latest | ||
env: | ||
WASM_BINARY_NAME: psp_capabilities | ||
OCI_TARGET: ghcr.io/chimera-kube/policies/psp-capabilities | ||
steps: | ||
- | ||
name: Checkout code | ||
uses: actions/checkout@v2 | ||
- | ||
name: Prepare Rust environment | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
target: wasm32-unknown-unknown | ||
- | ||
name: Download wasm-to-oci | ||
uses: i3h/download-release-asset@v1 | ||
with: | ||
owner: engineerd | ||
repo: wasm-to-oci | ||
tag: v0.1.1 | ||
file: linux-amd64-wasm-to-oci | ||
- | ||
name: fix wasm-to-oci permissions | ||
run: | | ||
chmod 755 linux-amd64-wasm-to-oci | ||
- | ||
name: Build Wasm module | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --target=wasm32-unknown-unknown --release | ||
- | ||
name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.CR_PAT }} | ||
- | ||
name: Publish Wasm policy artifact to OCI registry with the 'latest' tag | ||
if: ${{ startsWith(github.ref, 'refs/heads/') }} | ||
run: | | ||
./linux-amd64-wasm-to-oci push target/wasm32-unknown-unknown/release/${WASM_BINARY_NAME}.wasm ${OCI_TARGET}:latest | ||
- | ||
name: Publish Wasm policy artifact to OCI registry with the version tag and 'latest' | ||
if: ${{ startsWith(github.ref, 'refs/tags/') }} | ||
run: | | ||
export OCI_TAG=$(echo $GITHUB_REF | sed -e "s|refs/tags/||") | ||
./linux-amd64-wasm-to-oci push target/wasm32-unknown-unknown/release/${WASM_BINARY_NAME}.wasm ${OCI_TARGET}:${OCI_TAG} | ||
- | ||
name: Create Release | ||
if: ${{ startsWith(github.ref, 'refs/tags/') }} | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
- | ||
name: Upload Release Asset | ||
if: ${{ startsWith(github.ref, 'refs/tags/') }} | ||
id: upload-release-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: target/wasm32-unknown-unknown/release/${{ env.WASM_BINARY_NAME }}.wasm | ||
asset_name: policy.wasm | ||
asset_content_type: application/wasm |