-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (83 loc) · 2.33 KB
/
Copy pathrelease.yml
File metadata and controls
92 lines (83 loc) · 2.33 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
name: Release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-*"
permissions:
contents: write
jobs:
build:
name: build (${{ matrix.goos }}-${{ matrix.goarch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
ext: ""
- goos: linux
goarch: arm64
ext: ""
- goos: darwin
goarch: amd64
ext: ""
- goos: darwin
goarch: arm64
ext: ""
- goos: windows
goarch: amd64
ext: .exe
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: "1.27.1"
cache: true
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "0"
TAG: ${{ github.ref_name }}
COMMIT: ${{ github.sha }}
run: |
VERSION="${TAG}"
BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS="-s -w \
-X github.com/fuse/pmx/internal/cli.Version=${VERSION} \
-X github.com/fuse/pmx/internal/cli.Commit=${COMMIT:0:7} \
-X github.com/fuse/pmx/internal/cli.BuildTime=${BUILD_TIME}"
mkdir -p dist
go build -ldflags "${LDFLAGS}" -o "dist/pmx${{ matrix.ext }}" ./cmd/pmx
- name: Package
env:
TAG: ${{ github.ref_name }}
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
VERSION="${TAG}"
mkdir -p release
if [ "${GOOS}" = "windows" ]; then
zip -j "release/pmx_${VERSION}_${GOOS}_${GOARCH}.zip" dist/pmx.exe
else
tar -C dist -czf "release/pmx_${VERSION}_${GOOS}_${GOARCH}.tar.gz" pmx
fi
- uses: actions/upload-artifact@v7
with:
name: pmx-${{ matrix.goos }}-${{ matrix.goarch }}
path: release/*
release:
name: publish GitHub release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
path: artifacts
merge-multiple: true
- uses: softprops/action-gh-release@v3
with:
files: artifacts/*
generate_release_notes: true