Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Release Build

on:
push:
tags:
- 'v*'
pull_request:
branches:
- main

env:
CARGO_TERM_COLOR: always

permissions:
contents: write

jobs:
build:
name: Build - ${{ matrix.platform.target }}
runs-on: ${{ matrix.platform.os }}

strategy:
fail-fast: false
matrix:
platform:
- name: Windows x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
binary_ext: ".exe"

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Validate semantic version tag
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
TAG="${GITHUB_REF_NAME}"
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
echo "Tag '$TAG' is not a valid semantic version (expected e.g. v1.2.3)."
exit 1
fi

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.target }}

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ matrix.platform.target }}-${{ hashFiles('**/Cargo.lock') }}

- name: Build
run: cargo build --release --target ${{ matrix.platform.target }}

- name: Package binary
shell: pwsh
run: |
$binaryName = "lfv${{ matrix.platform.binary_ext }}"
$binaryPath = "target/${{ matrix.platform.target }}/release/$binaryName"
$archiveName = "lfv-${{ matrix.platform.target }}.zip"

New-Item -ItemType Directory -Path dist -Force | Out-Null
Compress-Archive -Path $binaryPath -DestinationPath "dist/$archiveName" -Force

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: lfv-${{ matrix.platform.target }}
path: dist/*
if-no-files-found: error

release:
name: Create Release
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')

steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Upload artifacts to release page
uses: softprops/action-gh-release@v2
with:
files: artifacts/**/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading