Skip to content

Merge pull request #3 from Timwood0x10/improve #32

Merge pull request #3 from Timwood0x10/improve

Merge pull request #3 from Timwood0x10/improve #32

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: 31, Col: 14): Unexpected symbol: 'ref#refs/tags/v'. Located at position 8 within expression: github.ref#refs/tags/v
on:
push:
branches: [master]
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.2.0)'
required: false
permissions:
contents: write
env:
ZIG_VERSION: 0.15.2
jobs:
get-version:
name: Get Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v4
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ inputs.version }}" ]; then
VERSION="${{ inputs.version }}"
elif [[ "${{ github.ref }}" == refs/tags/v* ]]; then
VERSION="${{ github.ref#refs/tags/v }}"
else
VERSION=$(cat VERSION 2>/dev/null || echo "0.2.0")
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
build-linux:
name: Build Linux
runs-on: ubuntu-latest
needs: [get-version]
steps:
- uses: actions/checkout@v4
- name: Install ZVM and Zig
run: |
curl -sSL https://www.zvm.app/install.sh | bash
export ZVM_INSTALL="$HOME/.zvm/self"
export PATH="$HOME/.zvm/bin:$ZVM_INSTALL:$PATH"
zvm install ${{ env.ZIG_VERSION }}
zvm use ${{ env.ZIG_VERSION }}
echo "$HOME/.zvm/bin" >> $GITHUB_PATH
echo "$HOME/.zvm/self" >> $GITHUB_PATH
- name: Install LLVM
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository -y "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-21 main"
sudo apt-get update
sudo apt-get install -y llvm-21-dev clang-21 libclang-21-dev
- name: Build
run: zig build -Doptimize=ReleaseFast
- name: Package
run: |
mkdir -p dist
cp zig-out/bin/OmniScope dist/OmniScope-${{ needs.get-version.outputs.version }}-linux-x86_64
cd dist && tar -czvf OmniScope-${{ needs.get-version.outputs.version }}-linux-x86_64.tar.gz OmniScope-${{ needs.get-version.outputs.version }}-linux-x86_64
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: linux-binary
path: dist/*.tar.gz
build-macos:
name: Build macOS
runs-on: macos-latest
needs: [get-version]
steps:
- uses: actions/checkout@v4
- name: Install ZVM and Zig
run: |
curl -sSL https://www.zvm.app/install.sh | bash
export ZVM_INSTALL="$HOME/.zvm/self"
export PATH="$HOME/.zvm/bin:$ZVM_INSTALL:$PATH"
zvm install ${{ env.ZIG_VERSION }}
zvm use ${{ env.ZIG_VERSION }}
echo "$HOME/.zvm/bin" >> $GITHUB_PATH
echo "$HOME/.zvm/self" >> $GITHUB_PATH
- name: Install LLVM
run: brew install llvm@21
- name: Build
run: zig build -Doptimize=ReleaseFast
- name: Package
run: |
mkdir -p dist
cp zig-out/bin/OmniScope dist/OmniScope-${{ needs.get-version.outputs.version }}-macos-x86_64
cd dist && tar -czvf OmniScope-${{ needs.get-version.outputs.version }}-macos-x86_64.tar.gz OmniScope-${{ needs.get-version.outputs.version }}-macos-x86_64
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: macos-binary
path: dist/*.tar.gz
build-macos-arm:
name: Build macOS ARM
runs-on: macos-latest
needs: [get-version]
steps:
- uses: actions/checkout@v4
- name: Install ZVM and Zig
run: |
curl -sSL https://www.zvm.app/install.sh | bash
export ZVM_INSTALL="$HOME/.zvm/self"
export PATH="$HOME/.zvm/bin:$ZVM_INSTALL:$PATH"
zvm install ${{ env.ZIG_VERSION }}
zvm use ${{ env.ZIG_VERSION }}
echo "$HOME/.zvm/bin" >> $GITHUB_PATH
echo "$HOME/.zvm/self" >> $GITHUB_PATH
- name: Install LLVM
run: brew install llvm@21
- name: Build
run: zig build -Doptimize=ReleaseFast -Dtarget=aarch64-macos
- name: Package
run: |
mkdir -p dist
cp zig-out/bin/OmniScope dist/OmniScope-${{ needs.get-version.outputs.version }}-macos-aarch64
cd dist && tar -czvf OmniScope-${{ needs.get-version.outputs.version }}-macos-aarch64.tar.gz OmniScope-${{ needs.get-version.outputs.version }}-macos-aarch64
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: macos-arm-binary
path: dist/*.tar.gz
create-release:
name: Create Release
runs-on: ubuntu-latest
needs: [get-version, build-linux, build-macos, build-macos-arm]
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Prepare release assets
run: |
mkdir -p release-assets
find dist -name "*.tar.gz" -exec cp {} release-assets/ \;
- name: Generate checksums
run: |
cd release-assets
sha256sum *.tar.gz > checksums.sha256
- name: Extract changelog for version
id: changelog
run: |
VERSION="${{ needs.get-version.outputs.version }}"
# Extract changelog section for this version
CHANGELOG_CONTENT=$(awk -v ver="$VERSION" '
/^## \[/ { in_section=0 }
/^## \['"$ver"'\]/ { in_section=1; next }
in_section { print }
' CHANGELOG.md | sed 's/^#*/#/g' | head -50)
echo "content<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.get-version.outputs.tag }}
name: OmniScope ${{ needs.get-version.outputs.tag }}
body: |
## OmniScope ${{ needs.get-version.outputs.version }}
${{ steps.changelog.outputs.content }}
See [CHANGELOG.md](CHANGELOG.md) for full history.
files: release-assets/*
draft: false
prerelease: ${{ contains(needs.get-version.outputs.version, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}