Skip to content

feat: inject build label into UI version and CI #11

feat: inject build label into UI version and CI

feat: inject build label into UI version and CI #11

Workflow file for this run

name: Build & Release
on:
push:
branches:
- '**'
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request:
branches:
- main
release:
types:
- published
workflow_dispatch:
jobs:
build_windows:
name: Build Windows Application
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@main
- name: Install flutter_rust_bridge_codegen
run: cargo binstall --no-confirm flutter_rust_bridge_codegen
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: Enable Windows desktop
run: flutter config --enable-windows-desktop
- name: Install dependencies
run: flutter pub get
- name: Resolve build label
id: meta
shell: bash
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
label="${{ github.event.release.tag_name }}"
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
label="${{ github.ref_name }}"
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
label="pr-${{ github.event.number }}-${GITHUB_SHA::7}"
else
label="commit-${GITHUB_SHA::7}"
fi
echo "build_label=$label" >> "$GITHUB_OUTPUT"
echo "Build label: $label"
- name: Build Application using PowerShell script
shell: pwsh
run: .\build.ps1 -BuildLabel "${{ steps.meta.outputs.build_label }}"
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: EndSwitcher_Standalone
path: EndSwitcher_Standalone.exe
if-no-files-found: error
release:
name: Create GitHub Release
needs: build_windows
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') # Only run on tag push
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: EndSwitcher_Standalone
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: EndSwitcher_Standalone.exe
generate_release_notes: true