-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (61 loc) · 1.99 KB
/
release.yml
File metadata and controls
71 lines (61 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: '版本号 (如 0.2.0,会自动加 v 前缀)'
required: true
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Resolve version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="v${{ github.event.inputs.version }}"
else
VERSION="${GITHUB_REF_NAME}"
fi
echo "tag=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Prepare build vars
id: buildvars
env:
VERSION: ${{ steps.version.outputs.tag }}
run: |
COMMIT=$(git rev-parse HEAD)
BUILDTIME=$(date -u '+%Y-%m-%dT%H:%M:%S')
LDFLAGS="-s -w -X github.com/cicbyte/reference/cmd/version.Version=${VERSION} -X github.com/cicbyte/reference/cmd/version.GitCommit=${COMMIT} -X github.com/cicbyte/reference/cmd/version.BuildTime=${BUILDTIME}"
echo "ldflags=${LDFLAGS}" >> "$GITHUB_OUTPUT"
- name: Build Windows
env:
GOOS: windows
GOARCH: amd64
run: go build -ldflags "${{ steps.buildvars.outputs.ldflags }}" -o dist/reference_windows_amd64.exe
- name: Build Linux
env:
GOOS: linux
GOARCH: amd64
run: go build -ldflags "${{ steps.buildvars.outputs.ldflags }}" -o dist/reference_linux_amd64
- name: Build macOS
env:
GOOS: darwin
GOARCH: amd64
run: go build -ldflags "${{ steps.buildvars.outputs.ldflags }}" -o dist/reference_darwin_amd64
- name: Upload Release Assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
files: dist/*
generate_release_notes: true