|
| 1 | +name: Publish a Wasm Component package to GitHub Artifacts |
| 2 | + |
| 3 | +# Run this action whenever a new release is tagged |
| 4 | +on: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - v* |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +env: |
| 11 | + IMAGE_NAME: ${{ github.repository }} |
| 12 | + |
| 13 | +jobs: |
| 14 | + publish: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + permissions: |
| 17 | + id-token: write |
| 18 | + packages: write |
| 19 | + contents: read |
| 20 | + |
| 21 | + steps: |
| 22 | + # Checkout the repo and install dependencies |
| 23 | + - name: Checkout repository |
| 24 | + uses: actions/checkout@v2 |
| 25 | + - name: Install cargo-binstall |
| 26 | + uses: cargo-bins/[email protected] |
| 27 | + - name: Install wkg |
| 28 | + shell: bash |
| 29 | + run: cargo binstall wkg |
| 30 | + - name: Install cosign |
| 31 | + |
| 32 | + |
| 33 | + # To version our image we want to obtain the version from the tag |
| 34 | + - name: Get version |
| 35 | + id: meta |
| 36 | + uses: docker/metadata-action@v5 |
| 37 | + with: |
| 38 | + images: ghcr.io/webassembly/wasi/http |
| 39 | + tags: | |
| 40 | + type=semver,pattern={{version}} |
| 41 | + |
| 42 | + # To upload our image to the GitHub registry, we first have to login |
| 43 | + - name: Login to the GitHub registry |
| 44 | + uses: docker/login-action@v3 |
| 45 | + with: |
| 46 | + registry: ghcr.io |
| 47 | + username: ${{ github.actor }} |
| 48 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + |
| 50 | + # Build our `.wit` files into a Wasm binary |
| 51 | + - name: Build |
| 52 | + shell: bash |
| 53 | + run: wkg wit build -o wasi-http.wasm |
| 54 | + |
| 55 | + # Upload the Wasm binary to the GitHub registry |
| 56 | + - name: Publish to GitHub Container Registry |
| 57 | + id: publish |
| 58 | + uses: bytecodealliance/wkg-github-action@v5 |
| 59 | + with: |
| 60 | + oci-reference-without-tag: 'ghcr.io/webassembly/wasi/http' |
| 61 | + file: 'wasi-http.wasm' |
| 62 | + description: 'A WASI API for sending and receiving HTTP requests and responses.' |
| 63 | + source: 'https://github.com/webassembly/wasi' |
| 64 | + homepage: 'https://wasi.dev' |
| 65 | + version: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} |
| 66 | + licenses: 'Apache-2.0 WITH LLVM-exception' |
| 67 | + |
| 68 | + # Sign the output component |
| 69 | + - name: Sign the wasm component |
| 70 | + run: cosign sign --yes ghcr.io/webassembly/wasi/http@${{ steps.publish.outputs.digest }} |
0 commit comments