action on all pushes, just for testing #2
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: Build and release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
# tags: | ||
# - "v*" | ||
jobs: | ||
github_build: | ||
name: Build release 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 | ||
- 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 (Other Targets) | ||
if: matrix.target != 'x86_64-pc-windows-msvc' | ||
run: | | ||
Check failure on line 59 in .github/workflows/release.yml
|
||
mkdir -p dist | ||
GOOS=${{ matrix.target%/* }} GOARCH=${{ matrix.target#*/ }} 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 }} | ||
# Create GitHub release with built binaries | ||
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 |