-
Notifications
You must be signed in to change notification settings - Fork 5
85 lines (73 loc) · 2.62 KB
/
release.yml
File metadata and controls
85 lines (73 loc) · 2.62 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Run go vet
run: go vet ./...
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
install-mode: "goinstall"
version: v1.64
build:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Get version
id: version
run: |
TAG="${GITHUB_REF#refs/tags/}"
if [[ "$TAG" == v* ]]; then
VERSION="$TAG"
else
VERSION="$(git rev-parse --short HEAD)"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Build all platforms
env:
CGO_ENABLED: 0
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
echo "version: $VERSION"
GOOS=linux GOARCH=amd64 go build -ldflags "-X github.com/liut/morign/pkg/settings.version=$VERSION -s -w" -o morign .
mv morign morign-linux-amd64
GOOS=darwin GOARCH=amd64 go build -ldflags "-X github.com/liut/morign/pkg/settings.version=$VERSION -s -w" -o morign .
mv morign morign-darwin-amd64
GOOS=darwin GOARCH=arm64 go build -ldflags "-X github.com/liut/morign/pkg/settings.version=$VERSION -s -w" -o morign .
mv morign morign-darwin-arm64
GOOS=windows GOARCH=amd64 go build -ldflags "-X github.com/liut/morign/pkg/settings.version=$VERSION -s -w" -o morign.exe .
mv morign.exe morign-windows-amd64.exe
- name: Package
run: |
tar -cvJf morign-linux-amd64-${{ steps.version.outputs.VERSION }}.tar.xz -C . morign-linux-amd64
tar -cvJf morign-darwin-amd64-${{ steps.version.outputs.VERSION }}.tar.xz -C . morign-darwin-amd64
tar -cvJf morign-darwin-arm64-${{ steps.version.outputs.VERSION }}.tar.xz -C . morign-darwin-arm64
zip morign-windows-amd64-${{ steps.version.outputs.VERSION }}.zip morign-windows-amd64.exe
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: |
morign-linux-amd64-*.tar.xz
morign-darwin-amd64-*.tar.xz
morign-darwin-arm64-*.tar.xz
morign-windows-amd64-*.zip
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}