pumpkin-api-c/.github/workflows/main.yml
2026-08-03 18:05:47 -07:00

76 lines
2.1 KiB
YAML

name: Main
on:
push:
pull_request:
workflow_dispatch:
workflow_run:
types:
- completed
workflows:
- "Update WIT"
permissions:
contents: write
pull-requests: write
jobs:
main:
name: Build, test, and release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: true
- name: Set up wasi-sdk
uses: bytecodealliance/setup-wasi-sdk-action@b2de090b44eb70013ee96b393727d473b35e1728
- name: Set up wit-bindgen
uses: bytecodealliance/actions/wit-bindgen/setup@v1
- name: Build
run: make install
- name: Test
run: wasm32-wasip2-clang -o test_plugin.wasm -mexec-model=reactor -Iinstall/include install/lib/libpumpkin-api.a example/main.c
- name: Set GITHUB_RELEASE_TAG & ARTIFACT_ID
run: |
set -eux
if [[ '${{ github.ref }}' = refs/tags/v* ]]; then
tag='${{ github.ref }}'
tag="${tag:10}"
artifactID="${tag:1}"
else
tag=CI
artifactID='${{ github.sha }}'
artifactID="${artifactID:0:7}"
fi
echo "GITHUB_RELEASE_TAG=$tag" >> $GITHUB_ENV
echo "ARTIFACT_ID=$artifactID" >> $GITHUB_ENV
- name: Bundle
run: |
mv install pumpkin-api-c-${ARTIFACT_ID}
tar -cvJf pumpkin-api-c-${ARTIFACT_ID}.tar.xz pumpkin-api-c-${ARTIFACT_ID}
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
archive: false
path: ${{ format('pumpkin-api-c-{0}.tar.xz', env.ARTIFACT_ID) }}
- name: Upload artifacts to release
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master'
uses: ncipollo/release-action@v1
with:
tag: ${{ env.GITHUB_RELEASE_TAG }}
artifacts: ${{ format('pumpkin-api-c-{0}.tar.xz', env.ARTIFACT_ID) }}
allowUpdates: true
omitPrereleaseDuringUpdate: true
omitName: true
omitBody: true
omitDraftDuringUpdate: true
removeArtifacts: true