-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v3 | ||
|
||
- 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@v3 | ||
with: | ||
go-version: '1.23.x" | ||
- 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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
output/* | ||
test/* | ||
test/* | ||
build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |