must provide go version #4
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
# Based on https://github.com/badboy/mdbook-toc/blob/main/.github/workflows/deploy.yml | |
name: Release binaries | |
on: | |
push: | |
branches: | |
- main | |
# tags: | |
# - "v*" | |
jobs: | |
github_build: | |
name: Build binaries | |
strategy: | |
fail-fast: false | |
matrix: | |
target: | |
- x86_64-unknown-linux-gnu | |
- x86_64-unknown-linux-musl | |
- x86_64-apple-darwin | |
- aarch64-apple-darwin | |
- x86_64-pc-windows-msvc | |
include: | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
name: x86_64-unknown-linux-gnu.tar.gz | |
- target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
name: x86_64-unknown-linux-musl.tar.gz | |
- target: x86_64-apple-darwin | |
os: macOS-latest | |
name: x86_64-apple-darwin.tar.gz | |
- target: aarch64-apple-darwin | |
os: macOS-latest | |
name: aarch64-apple-darwin.tar.gz | |
- target: x86_64-pc-windows-msvc | |
os: windows-latest | |
name: x86_64-pc-windows-msvc.zip | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Setup | Checkout | |
uses: actions/checkout@v4 | |
- name: Setup | Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 'stable' | |
- name: Setup | Get repository name | |
run: echo "REPO_NAME=$(basename ${{ github.repository }})" >> $GITHUB_ENV | |
- name: Build (Windows) | |
if: matrix.target == 'x86_64-pc-windows-msvc' | |
run: | | |
mkdir -p dist | |
GOOS=windows GOARCH=amd64 go build -o dist/${REPO_NAME}-${{ matrix.target }}.exe | |
- name: Build | Cross-compile (Other Targets) | |
if: matrix.target != 'x86_64-pc-windows-msvc' | |
run: | | |
mkdir -p dist | |
OS=$(echo "${{ matrix.target }}" | cut -d'-' -f1) | |
ARCH=$(echo "${{ matrix.target }}" | cut -d'-' -f2) | |
GOOS=$OS GOARCH=$ARCH go build -o dist/${REPO_NAME}-${{ matrix.target }} | |
- name: Post Setup | Strip binaries (-nix) | |
if: matrix.os != 'windows-latest' | |
run: | | |
strip dist/${REPO_NAME}-${{ matrix.target }}${{ matrix.ext }} | |
- name: Post Setup | Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ github.repository }}-${{ matrix.target }} | |
path: dist/${REPO_NAME}-${{ matrix.target }}${{ matrix.ext }} | |
github_release: | |
name: Create GitHub Release | |
needs: github_build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup | Checkout | |
uses: actions/checkout@v4 | |
- name: Setup | Download artifacts | |
uses: actions/download-artifact@v4 | |
- name: Setup | Generate release notes | |
run: git log -1 --pretty='%s' > RELEASE.md | |
- name: Build | Publish | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: dist/* | |
body_path: RELEASE.md |