auto-build ci #1
Workflow file for this run
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
name: Build and Release | |
on: | |
push: | |
tags: | |
- 'v*' | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
goos: [windows, linux, darwin] | |
goarch: [amd64, arm64] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23.1' | |
- name: Build for ${{ matrix.goos }}_${{ matrix.goarch }} | |
run: | | |
if [ "${{ matrix.goos }}" = "windows" ]; then EXT=".exe"; else EXT=""; fi | |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -trimpath -o build/sudo_${{ github.ref_name }}_${{ matrix.goos }}_${{ matrix.goarch }}$EXT | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sudo_${{ github.ref_name }}_${{ matrix.goos }}_${{ matrix.goarch }} | |
path: ./build/sudo_${{ github.ref_name }}_${{ matrix.goos }}_${{ matrix.goarch }}* | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./build | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: ./build/** | |
name: "Release ${{ github.ref_name }}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |