name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
with:
path: artifacts/tsgo.wasm.zst
key: tsgo-wasm-${{ hashFiles('artifacts/tsgo.rev') }}
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Ensure tsgo module
run: |
SHA=$(cat artifacts/tsgo.sha256)
if [ ! -f artifacts/tsgo.wasm.zst ] || [ "$(sha256sum artifacts/tsgo.wasm.zst | cut -d' ' -f1)" != "$SHA" ]; then
make tsgo
git diff --exit-code artifacts/tsgo.sha256
fi
- name: Attach module to release
env:
GH_TOKEN: ${{ github.token }}
run: |
cp artifacts/tsgo.wasm.zst tsgo.wasm.zst
gh release upload "$GITHUB_REF_NAME" tsgo.wasm.zst --clobber
rm tsgo.wasm.zst
- uses: dtolnay/rust-toolchain@stable
- name: Test
run: make test
- name: Login to crates.io
run: cargo login ${{ secrets.CRATES_TOKEN }}
- name: Publish
run: cargo publish --locked