Skip to content
Merged
Show file tree
Hide file tree
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
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and Release

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

jobs:
build:
runs-on: ubuntu-latest

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

- name: Install just
run: |
mkdir -p "$HOME/.local/bin"
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to "$HOME/.local/bin"
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version: '^1.13.1'

- name: Build binaries
run: just build

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: binaries
path: build/fgc-*

- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: build/fgc-*
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
output/*
test/*
test/*
build/*
32 changes: 32 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
set shell := ["bash", "-eu", "-o", "pipefail", "-c"]

build:
#!/usr/bin/env bash

# Determine version
if [ "$(git rev-parse --abbrev-ref HEAD)" = "main" ]; then
version="latest"
elif git describe --tags --exact-match >/dev/null 2>&1; then
version="$(git describe --tags --exact-match)"
else
version="$(git rev-parse --short HEAD)"
fi

echo "Building version: $version"

platforms=("linux" "windows" "darwin")
archs=("amd64" "arm64")

for GOOS in "${platforms[@]}"; do
for GOARCH in "${archs[@]}"; do
output="fgc-${GOOS}-${GOARCH}-${version}"
if [ "$GOOS" = "windows" ]; then
output+=".exe"
fi
echo "Building for $GOOS/$GOARCH: $output"

# Build the binary
env CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \
go build -ldflags="-s -w" -o "build/$output" .
done
done