1
0
Fork 0
mirror of https://github.com/adnanh/webhook.git synced 2026-07-23 02:08:39 +00:00
webhook/.github/workflows/release.yml
2026-06-02 15:22:55 +08:00

140 lines
3.4 KiB
YAML

name: release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Release version, for example v2.8.4"
required: true
type: string
permissions:
contents: write
jobs:
test:
env:
GOTOOLCHAIN: local
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.x"
- name: Test
run: go test -v ./...
build:
env:
CGO_ENABLED: "0"
GOTOOLCHAIN: local
needs: test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
- goos: freebsd
goarch: 386
- goos: freebsd
goarch: amd64
- goos: freebsd
goarch: arm64
- goos: linux
goarch: 386
- goos: linux
goarch: amd64
- goos: linux
goarch: arm
- goos: linux
goarch: arm64
- goos: openbsd
goarch: 386
- goos: openbsd
goarch: amd64
- goos: openbsd
goarch: arm64
- goos: windows
goarch: 386
- goos: windows
goarch: amd64
- goos: windows
goarch: arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.x"
- name: Resolve version
id: version
shell: bash
run: |
version="${{ github.event.inputs.version || github.ref_name }}"
version="${version#v}"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Build archive
shell: bash
run: |
target="webhook-${{ matrix.goos }}-${{ matrix.goarch }}"
mkdir -p "dist/$target"
binary="webhook"
if [ "${{ matrix.goos }}" = "windows" ]; then
binary="webhook.exe"
fi
GOOS="${{ matrix.goos }}" GOARCH="${{ matrix.goarch }}" \
go build -trimpath -ldflags="-s -w -X main.version=${{ steps.version.outputs.version }}" \
-o "dist/$target/$binary" .
cp LICENSE README.md "dist/$target/"
tar -czf "dist/$target.tar.gz" -C dist "$target"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: webhook-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/*.tar.gz
if-no-files-found: error
publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Generate checksums
shell: bash
run: |
cd dist
sha256sum *.tar.gz > checksums.txt
- name: Resolve tag
id: tag
shell: bash
run: |
tag="${{ github.event.inputs.version || github.ref_name }}"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: ${{ steps.tag.outputs.tag }}
files: |
dist/*.tar.gz
dist/checksums.txt
generate_release_notes: true