-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (84 loc) · 2.5 KB
/
release.yml
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
name: release
on:
push:
branches: [ master, test ]
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
env:
VERSION: ""
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: 'stable'
- run: go version
- name: Check need release
id: check_release
run: |
version=""
new_ver=$(grep -Po "v\d+\.\d+\.\d+" cmd/compiledb/main.go)
cur_ver=$(git describe --abbrev=0 --tags)
if [ "$new_ver" != "$cur_ver" ]; then
version=$new_ver
else
id=$(git rev-parse --short HEAD)
sed -E "s|v[0-9]+\.[0-9]+\.[0-9]+|$id|" cmd/compiledb/main.go -i
fi
echo "VERSION=$version" >> $GITHUB_ENV
- name: Install dependencies
run: go mod tidy
- name: Build
run: |
out=$(pwd)/build
mkdir -p $out
cd ./cmd/compiledb
GOOS=linux GOARCH=amd64 go build
chmod +x compiledb
tar cJvf compiledb.txz compiledb
mv compiledb.txz $out/compiledb-linux-amd64.txz
GOOS=linux GOARCH=arm64 go build
chmod +x compiledb
tar cJvf compiledb.txz compiledb
mv compiledb.txz $out/compiledb-linux-arm64.txz
GOOS=windows GOARCH=amd64 go build
7z a compiledb.7z compiledb.exe
mv compiledb.7z $out/compiledb-windows-amd64.7z
GOOS=darwin GOARCH=arm64 go build
chmod +x compiledb
tar cJvf compiledb.txz compiledb
mv compiledb.txz $out/compiledb-darwin-arm64.txz
gh release delete latest -y || true
git push origin :latest || true
ls -la $out
- uses: actions/upload-artifact@v4
with:
name: binary
path: build/*
- name: Release
if: ${{ env.VERSION != '' }}
uses: ncipollo/release-action@v1
with:
tag: ${{ env.VERSION }}
allowUpdates: true
artifactErrorsFailBuild: true
generateReleaseNotes: true
artifacts: "build/*"
- name: Update latest
uses: ncipollo/release-action@v1
with:
tag: latest
artifactErrorsFailBuild: true
generateReleaseNotes: true
prerelease: false
draft: true
artifacts: "build/*"