Skip to content

Commit

Permalink
Add GitHub Action: release
Browse files Browse the repository at this point in the history
  • Loading branch information
flavio committed Mar 20, 2021
1 parent a19bed7 commit 6dcdd90
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/release.yml
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

0 comments on commit 6dcdd90

Please sign in to comment.