Skip to content

chore(release): publish 0.0.1 #9

chore(release): publish 0.0.1

chore(release): publish 0.0.1 #9

Workflow file for this run

name: ci
on:
push:
branches: [main, ci]
# tags:
# - "v*.*.*"
env:
CARGO_TERM_COLOR: always
jobs:
build-release:
if: "startsWith(github.event.head_commit.message, 'chore(release): publish')"
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-14, windows-latest]
include:
- os: ubuntu-latest
targets: "x86_64-unknown-linux-gnu,x86_64-unknown-linux-musl,aarch64-unknown-linux-musl,aarch64-unknown-linux-gnu"
- os: macos-14
targets: "x86_64-apple-darwin,aarch64-apple-darwin"
- os: windows-latest
targets: "x86_64-pc-windows-msvc"
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- name: Set release version
shell: pwsh
run: |
$regex = '(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?'
$ok = "${{ github.event.head_commit.message }}" -match $regex
if ($ok) {
$version = "v$Matches[0]"
Write-Host $version
echo "RELEASE_VERSION=$version" >> $env::GITHUB_ENV
} else {
throw 'Semver is not found in commit message.'
}
- name: Checkout
uses: actions/checkout@v4
- name: Setup rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.targets }}
- name: Install zig
uses: korandoru/setup-zig@v1
if: matrix.os == 'ubuntu-latest'
with:
zig-version: 0.11.0
- name: Install binstall
uses: cargo-bins/cargo-binstall@main
if: matrix.os == 'ubuntu-latest'
- name: Install zigbuild
run: cargo binstall -y cargo-zigbuild
if: matrix.os == 'ubuntu-latest'
- name: Build
shell: pwsh
run: |
("${{ matrix.targets }}" -split ",") | ForEach-Object {
Write-Host "Building $_"
if ("${{ matrix.os }}" -ne "ubuntu-latest") {
cargo build --verbose --release --target $_
} else {
cargo zigbuild --verbose --release --target $_
}
}
- name: List builds
shell: pwsh
run: |
Get-ChildItem (Join-Path . target)
- name: Archive artifacts
shell: pwsh
run: |
$isWin = "${{ matrix.os }}".StartsWith("windows-")
$ext = $isWin ? ".exe" : ""
("${{ matrix.targets }}" -split ",") | ForEach-Object {
$binaryName = "als$ext"
$targetBinaryName = "als-$_$ext"
Move-Item -Path (Join-Path . target $_ release $binaryName) -Destination (Join-Path . $targetBinaryName)
if ($isWin) {
Compress-Archive -Path (Join-Path . $targetBinaryName) -DestinationPath ".\als-$_.zip"
} else {
tar -czf "./als-$_.tar.gz" $targetBinaryName
}
Remove-Item (Join-Path . $targetBinaryName)
}
echo "ARCHIVE_PATH=./als-*" >> $env:GITHUB_ENV
- name: List archive
shell: pwsh
run: |
Get-ChildItem .
- name: Release
uses: softprops/action-gh-release@v1
with:
draft: true
name: ${{ env.RELEASE_VERSION }}
tag_name: ${{ env.RELEASE_VERSION }}
files: ${{ env.ARCHIVE_PATH }}