Skip to content

feat: add releaser

feat: add releaser #1

Workflow file for this run

name: Release

Check failure on line 1 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

(Line: 12, Col: 3): Unexpected value 'releases'
on:
push:
branches:
- main
tags:
- 'v*'
permissions:
contents: write
releases: write
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: linux-x64
runner: ubuntu-latest
artifact: spm-linux-x64
- target: darwin-arm64
runner: macos-latest
artifact: spm-darwin-arm64
- target: darwin-x64
runner: macos-latest
artifact: spm-darwin-x64
- target: windows-x64
runner: windows-latest
artifact: spm-windows-x64.exe
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build binary
run: |
case "${{ matrix.target }}" in
linux-x64)
bun build index.ts --compile --target=bun-linux-x64 --outfile dist/spm-linux-x64
;;
darwin-arm64)
bun build index.ts --compile --target=bun-darwin-arm64 --outfile dist/spm-darwin-arm64
;;
darwin-x64)
bun build index.ts --compile --target=bun-darwin-x64 --outfile dist/spm-darwin-x64
;;
windows-x64)
bun build index.ts --compile --target=bun-windows-x64 --outfile dist/spm-windows-x64.exe
;;
esac
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: spm-${{ matrix.target }}
path: dist/${{ matrix.artifact }}
release:
name: Create Release
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release
for dir in artifacts/spm-*/; do
cp "$dir"/* release/ 2>/dev/null || true
done
ls -la release/
- name: Determine version
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "prerelease=false" >> $GITHUB_OUTPUT
else
VERSION=$(node -p "require('./package.json').version")
SHORT_SHA=$(git rev-parse --short HEAD)
echo "version=${VERSION}-main.${SHORT_SHA}" >> $GITHUB_OUTPUT
echo "tag=v${VERSION}-main.${SHORT_SHA}" >> $GITHUB_OUTPUT
echo "prerelease=true" >> $GITHUB_OUTPUT
fi
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
prerelease: ${{ steps.version.outputs.prerelease }}
generate_release_notes: true
files: release/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}