120 lines
No EOL
4.5 KiB
YAML
120 lines
No EOL
4.5 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '*'
|
|
tags:
|
|
- '*'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: 9950x
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.21'
|
|
|
|
- name: Install gox and UPX
|
|
run: |
|
|
go install github.com/mitchellh/gox@latest
|
|
wget -O upx.tar.xz https://github.com/upx/upx/releases/download/v5.0.1/upx-5.0.1-amd64_linux.tar.xz
|
|
tar -xf upx.tar.xz
|
|
cp upx-5.0.1-amd64_linux/upx /usr/local/bin/
|
|
cp upx-5.0.1-amd64_linux/upx.1 /usr/local/share/man/man1/ || true
|
|
chmod +x /usr/local/bin/upx
|
|
|
|
- name: Build cross-platform binaries
|
|
run: |
|
|
gox -os="darwin" -os="linux" -os="windows" -arch="amd64" -arch="arm64" -osarch="linux/386" -osarch="windows/386" -output="build/{{.Dir}}-{{.OS}}-{{.Arch}}"
|
|
|
|
- name: Compress Linux binaries with UPX
|
|
run: |
|
|
for file in build/*linux*; do
|
|
if [ -f "$file" ]; then
|
|
upx --brute "$file"
|
|
fi
|
|
done
|
|
|
|
- name: Get version
|
|
id: version
|
|
run: |
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "version=dev-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Create platform bundles
|
|
run: |
|
|
mkdir -p release
|
|
|
|
# Create Darwin (macOS) bundle
|
|
mkdir -p bundle-darwin
|
|
cp build/fps-go-brr-darwin-amd64 bundle-darwin/ 2>/dev/null || true
|
|
cp build/fps-go-brr-darwin-arm64 bundle-darwin/ 2>/dev/null || true
|
|
if [ "$(ls -A bundle-darwin 2>/dev/null)" ]; then
|
|
tar -czf release/fps-go-brr-darwin-${{ steps.version.outputs.version }}.tar.gz -C bundle-darwin .
|
|
fi
|
|
|
|
# Create Linux bundle
|
|
mkdir -p bundle-linux
|
|
cp build/fps-go-brr-linux-amd64 bundle-linux/ 2>/dev/null || true
|
|
cp build/fps-go-brr-linux-arm64 bundle-linux/ 2>/dev/null || true
|
|
cp build/fps-go-brr-linux-386 bundle-linux/ 2>/dev/null || true
|
|
if [ "$(ls -A bundle-linux 2>/dev/null)" ]; then
|
|
tar -czf release/fps-go-brr-linux-${{ steps.version.outputs.version }}.tar.gz -C bundle-linux .
|
|
fi
|
|
|
|
# Create Windows bundle
|
|
mkdir -p bundle-windows
|
|
cp build/fps-go-brr-windows-amd64.exe bundle-windows/ 2>/dev/null || true
|
|
cp build/fps-go-brr-windows-arm64.exe bundle-windows/ 2>/dev/null || true
|
|
cp build/fps-go-brr-windows-386.exe bundle-windows/ 2>/dev/null || true
|
|
if [ "$(ls -A bundle-windows 2>/dev/null)" ]; then
|
|
tar -czf release/fps-go-brr-windows-${{ steps.version.outputs.version }}.tar.gz -C bundle-windows .
|
|
fi
|
|
|
|
- name: Upload Darwin bundle
|
|
uses: forgejo/upload-artifact@v4
|
|
with:
|
|
name: fps-go-brr-darwin-${{ steps.version.outputs.version }}
|
|
path: release/fps-go-brr-darwin-${{ steps.version.outputs.version }}.tar.gz
|
|
if-no-files-found: ignore
|
|
|
|
- name: Upload Linux bundle
|
|
uses: forgejo/upload-artifact@v4
|
|
with:
|
|
name: fps-go-brr-linux-${{ steps.version.outputs.version }}
|
|
path: release/fps-go-brr-linux-${{ steps.version.outputs.version }}.tar.gz
|
|
if-no-files-found: ignore
|
|
|
|
- name: Upload Windows bundle
|
|
uses: forgejo/upload-artifact@v4
|
|
with:
|
|
name: fps-go-brr-windows-${{ steps.version.outputs.version }}
|
|
path: release/fps-go-brr-windows-${{ steps.version.outputs.version }}.tar.gz
|
|
if-no-files-found: ignore
|
|
|
|
- name: Create Release
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
uses: actions/forgejo-release@v2
|
|
with:
|
|
direction: upload
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
release-dir: release
|
|
release-notes: |
|
|
## fps-go-brr ${{ steps.version.outputs.version }}
|
|
|
|
### Downloads
|
|
- `fps-go-brr-darwin-${{ steps.version.outputs.version }}.tar.gz` - macOS builds (amd64, arm64)
|
|
- `fps-go-brr-linux-${{ steps.version.outputs.version }}.tar.gz` - Linux builds (amd64, arm64, 386) - compressed with UPX
|
|
- `fps-go-brr-windows-${{ steps.version.outputs.version }}.tar.gz` - Windows builds (amd64, arm64, 386)
|
|
|
|
Linux binaries are compressed with UPX for smaller size but may have slightly slower startup time due to decompression. |