Skip to content

Build and Release

Build and Release #2

Workflow file for this run

name: Build and Release
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
output_name: hoster
- goos: linux
goarch: arm64
output_name: hoster
- goos: darwin
goarch: amd64
output_name: hoster
- goos: darwin
goarch: arm64
output_name: hoster
- goos: windows
goarch: amd64
output_name: hoster.exe
- goos: windows
goarch: arm64
output_name: hoster.exe
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
go build \
-ldflags="-X main.Version=${{ github.event.release.tag_name }}" \
-o ${{ matrix.output_name }} \
main.go
- name: Create archive (Linux/macOS)
if: matrix.goos != 'windows'
run: |
tar -czf hoster_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz ${{ matrix.output_name }}
- name: Create archive (Windows)
if: matrix.goos == 'windows'
shell: pwsh
run: |
Compress-Archive -Path ${{ matrix.output_name }} -DestinationPath hoster_${{ matrix.goos }}_${{ matrix.goarch }}.zip
- name: Upload to release
uses: softprops/action-gh-release@v2
with:
files: |
hoster_${{ matrix.goos }}_${{ matrix.goarch }}.*
overwrite_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}