diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf31efa..8bcf12f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,6 +58,8 @@ jobs: with: name: dist path: dist + if-no-files-found: error + retention-days: 7 codeql: name: analyze (${{ matrix.language }}) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a54487a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,86 @@ +name: release + +permissions: {} + +on: + push: + tags: + - "v*" + workflow_dispatch: + inputs: + tag: + description: "Tag to release (e.g. v1.3.0)" + required: true + type: string + prerelease: + description: "Mark as prerelease" + type: boolean + default: false + required: true + draft: + description: "Create as draft" + type: boolean + default: false + required: true + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + persist-credentials: true + + - if: github.event_name == 'workflow_dispatch' + run: | + tag="${{ inputs.tag }}" + if git rev-parse -q --verify "refs/tags/$tag" >/dev/null; then + echo "Tag $tag exists" + else + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag -a "$tag" -m "Release $tag" + git push origin "$tag" + fi + + - uses: pnpm/action-setup@v4 + with: + version: latest + run_install: false + + - uses: actions/setup-node@v6 + with: + node-version-file: ".nvmrc" + cache: "pnpm" + + - run: pnpm install --frozen-lockfile + - run: pnpm run fmt:check + - run: pnpm run lint:check + - run: pnpm run build + + - run: | + tar -czf dist.tar.gz -C dist . + sha256sum dist.tar.gz | tee dist.tar.gz.sha256 + + - id: meta + run: | + if [ "${{ github.event_name }}" = "push" ]; then + echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" + else + echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT" + fi + + - uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.meta.outputs.tag }} + name: ${{ steps.meta.outputs.tag }} + draft: ${{ github.event_name == 'workflow_dispatch' && inputs.draft || false }} + prerelease: ${{ github.event_name == 'workflow_dispatch' && inputs.prerelease || false }} + files: | + dist.tar.gz + dist.tar.gz.sha256 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}