watchdog/.github/workflows/release.yml
NotAShelf 781fa2af1a
ci: create a release on tag
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I718a6f8ce6ad08fe9da15225bf4009466a6a6964
2026-03-07 10:04:31 +03:00

66 lines
1.6 KiB
YAML

name: Release
on:
push:
tags:
- 'v*'
jobs:
build:
strategy:
matrix:
goos: [linux, darwin, freebsd]
goarch: [amd64, arm64]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
go build \
-ldflags="-s -w -X main.Version=${{ github.ref_name }} -X main.Commit=${{ github.sha }}" -o watchdog-${GOOS}-${GOARCH} .
- name: Create artifact
run: |
tar -czvf watchdog-${GOOS}-${{ matrix.goarch }}.tar.gz watchdog-${GOOS}-${{ matrix.goarch }}
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: watchdog-${{ matrix.goos }}-${{ matrix.goarch }}
path: watchdog-*
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/**/*.tar.gz artifacts/**/*.zip
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}