mirror of
https://github.com/synomal/Flint.git
synced 2026-07-16 08:51:09 +00:00
123 lines
3.7 KiB
YAML
123 lines
3.7 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
pull_request:
|
|
branches: [ master ]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
name: Build
|
|
runs-on: ubuntu-latest
|
|
environment: PAT_TOKEN
|
|
permissions:
|
|
contents: write
|
|
outputs:
|
|
new_tag: ${{ steps.bump_version.outputs.new_tag }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
# ── Version bump FIRST, before any build, so the binary contains the real tag ──
|
|
|
|
- name: Bump version and push tag
|
|
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
|
|
id: bump_version
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
|
|
run: |
|
|
LATEST=$(git tag --list 'v*' --sort=-version:refname | head -n1)
|
|
if [ -z "$LATEST" ]; then
|
|
NEW_TAG="v0.1.0"
|
|
else
|
|
VERSION="${LATEST#v}"
|
|
MAJOR=$(echo $VERSION | cut -d. -f1)
|
|
MINOR=$(echo $VERSION | cut -d. -f2)
|
|
PATCH=$(echo $VERSION | cut -d. -f3)
|
|
PATCH=$((PATCH + 1))
|
|
NEW_TAG="v${MAJOR}.${MINOR}.${PATCH}"
|
|
fi
|
|
echo "Bumped version to $NEW_TAG"
|
|
echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git tag $NEW_TAG
|
|
git push origin $NEW_TAG
|
|
|
|
# Write the real version tag into src/version.txt so @embedFile picks it up at compile time.
|
|
# On PR builds, leave the file as-is (it will contain "v0.0.0-dev" from source control).
|
|
- name: Write version.txt
|
|
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
|
|
run: echo "${{ steps.bump_version.outputs.new_tag }}" > src/version.txt
|
|
|
|
# ── Build ──
|
|
|
|
- name: Setup Zig
|
|
uses: mlugg/setup-zig@v2.2.1
|
|
with:
|
|
version: 0.15.2
|
|
|
|
- name: Build Linux
|
|
run: zig build -Dtarget=x86_64-linux-gnu -Doptimize=ReleaseSafe
|
|
|
|
- name: Package Linux
|
|
run: |
|
|
mv zig-out/bin/flint flint-linux-x86_64
|
|
tar -czvf flint-linux-x86_64.tar.gz flint-linux-x86_64
|
|
|
|
- name: Build Windows
|
|
run: |
|
|
rm -rf zig-out zig-cache
|
|
zig build -Dtarget=x86_64-windows-gnu -Doptimize=ReleaseSafe
|
|
|
|
- name: Package Windows
|
|
run: |
|
|
mv zig-out/bin/flint.exe flint-windows-x86_64.exe
|
|
zip flint-windows-x86_64.zip flint-windows-x86_64.exe
|
|
|
|
- name: Upload Linux Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: flint-linux-x86_64.tar.gz
|
|
path: flint-linux-x86_64.tar.gz
|
|
|
|
- name: Upload Windows Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: flint-windows-x86_64.zip
|
|
path: flint-windows-x86_64.zip
|
|
|
|
release:
|
|
name: Release
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
environment: PAT_TOKEN
|
|
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- name: Download Linux Artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: flint-linux-x86_64.tar.gz
|
|
|
|
- name: Download Windows Artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: flint-windows-x86_64.zip
|
|
|
|
- name: Publish Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ needs.build.outputs.new_tag }}
|
|
name: ${{ needs.build.outputs.new_tag }}
|
|
files: |
|
|
flint-linux-x86_64.tar.gz
|
|
flint-windows-x86_64.zip
|
|
generate_release_notes: true |