-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (125 loc) · 3.58 KB
/
Copy pathrelease-proxy.yml
File metadata and controls
144 lines (125 loc) · 3.58 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Release proxy binaries
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Release tag to publish (e.g. v0.1.0)"
required: true
type: string
permissions:
contents: write
jobs:
prepare:
name: Prepare release tag
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.tag.outputs.release_tag }}
release_ref: ${{ steps.tag.outputs.release_ref }}
steps:
- name: Resolve release tag
id: tag
env:
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
run: |
case "$RELEASE_TAG" in
v*) ;;
*) echo "Release tag must start with v" >&2; exit 1 ;;
esac
printf 'release_tag=%s\n' "$RELEASE_TAG" >> "$GITHUB_OUTPUT"
printf 'release_ref=refs/tags/%s\n' "$RELEASE_TAG" >> "$GITHUB_OUTPUT"
test:
name: Test and vet
runs-on: ubuntu-latest
needs: prepare
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.prepare.outputs.release_ref }}
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Test
run: go test ./...
- name: Vet
run: go vet ./...
build:
name: Build ${{ matrix.goos }}-${{ matrix.goarch }}
runs-on: ubuntu-latest
needs:
- prepare
- test
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
- goos: windows
goarch: amd64
extension: .exe
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.prepare.outputs.release_ref }}
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "0"
EXTENSION: ${{ matrix.extension }}
run: |
mkdir -p dist
asset="freebuff-proxy-${GOOS}-${GOARCH}"
binary="${asset}${EXTENSION}"
go build -trimpath -ldflags="-s -w" -o "dist/${binary}" ./cmd/freebuff-proxy
tar -C dist -czf "dist/${asset}.tar.gz" "${binary}"
- name: Upload release artifact
uses: actions/upload-artifact@v7
with:
name: freebuff-proxy-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/*.tar.gz
if-no-files-found: error
retention-days: 7
release:
name: Publish GitHub Release
runs-on: ubuntu-latest
needs:
- prepare
- build
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.prepare.outputs.release_ref }}
- name: Download release artifacts
uses: actions/download-artifact@v5
with:
path: dist
pattern: freebuff-proxy-*
merge-multiple: true
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ needs.prepare.outputs.release_tag }}
run: |
gh release create "$RELEASE_TAG" dist/*.tar.gz \
--title "$RELEASE_TAG" \
--notes "freebuff-proxy $RELEASE_TAG — linux-amd64, linux-arm64, darwin-amd64, darwin-arm64, windows-amd64"