78 lines
2.2 KiB
YAML
78 lines
2.2 KiB
YAML
name: release
|
|
|
|
on:
|
|
push:
|
|
tags: ['v*']
|
|
workflow_dispatch:
|
|
inputs:
|
|
dry_run:
|
|
description: Build and verify the artifacts without publishing a release
|
|
type: boolean
|
|
default: true
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
verify:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: 1.3.14
|
|
- run: bun install --frozen-lockfile
|
|
- run: bun run typecheck
|
|
- run: bun test
|
|
|
|
build:
|
|
needs: verify
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: 1.3.14
|
|
- run: bun install --frozen-lockfile
|
|
|
|
# Bun cross-compiles every target from one host, so no build matrix is needed.
|
|
# release.ts also fails the build when the tag and src/version.ts disagree.
|
|
- run: bun run release
|
|
|
|
- name: Check the binary reports the right version
|
|
run: |
|
|
chmod +x dist/release/shiro-linux-x64
|
|
./dist/release/shiro-linux-x64 --version
|
|
./dist/release/shiro-linux-x64 --version | grep -q "$(bun -e 'console.log((await import("./src/version.ts")).VERSION)')"
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: shiro-binaries
|
|
path: dist/release/
|
|
retention-days: 7
|
|
|
|
publish:
|
|
needs: build
|
|
# Tag pushes always publish. A manual dispatch publishes only when dry_run is
|
|
# unchecked (false); the default true builds and verifies without a release.
|
|
if: >-
|
|
startsWith(github.ref, 'refs/tags/v') ||
|
|
(github.event_name == 'workflow_dispatch' && inputs.dry_run == false)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: shiro-binaries
|
|
path: dist/release
|
|
|
|
- name: Publish the release
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
gh release create "${{ github.ref_name }}" \
|
|
--title "shiro-neko ${{ github.ref_name }}" \
|
|
--generate-notes \
|
|
$([[ "${{ github.ref_name }}" == *-* ]] && echo --prerelease) \
|
|
dist/release/*
|