Repository navigation
68 lines (59 loc) · 1.95 KB
/
Copy pathrelease.yml
File metadata and controls
68 lines (59 loc) · 1.95 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
name: Release Go Binaries
on:
release:
types: [published]
permissions:
contents: write
jobs:
release:
name: Build and Release Binaries
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64, "386"]
exclude:
- goos: darwin
goarch: "386"
steps:
- name: Checkout Repository
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: '1.26'
- name: Run Vet
run: go vet ./...
- name: Run Tests
run: go test -race -v ./...
- name: Build Binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
BINARY_NAME="code-reducer"
if [ "${{ matrix.goos }}" = "windows" ]; then
BINARY_NAME="code-reducer.exe"
fi
# Compile with optimizations and strip symbols
go build -ldflags="-s -w" -o "dist/${BINARY_NAME}" main.go
- name: Package Binary
id: package
run: |
cd dist
BINARY_NAME="code-reducer"
if [ "${{ matrix.goos }}" = "windows" ]; then
BINARY_NAME="code-reducer.exe"
zip "../code-reducer-${{ matrix.goos }}-${{ matrix.goarch }}.zip" "${BINARY_NAME}"
echo "asset_path=code-reducer-${{ matrix.goos }}-${{ matrix.goarch }}.zip" >> $GITHUB_OUTPUT
else
tar -czvf "../code-reducer-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz" "${BINARY_NAME}"
echo "asset_path=code-reducer-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz" >> $GITHUB_OUTPUT
fi
- name: Upload to Release
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
with:
files: ${{ steps.package.outputs.asset_path }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}