-
Notifications
You must be signed in to change notification settings - Fork 1
113 lines (98 loc) · 3.22 KB
/
build-and-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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Build and Release
on:
push:
tags:
- 'v*.*.*'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
platform: linux
arch: amd64
- os: ubuntu-latest
platform: linux
arch: arm64
- os: macos-latest
platform: darwin
arch: amd64
- os: macos-latest
platform: darwin
arch: arm64
- os: windows-latest
platform: windows
arch: amd64
- os: windows-latest
platform: windows
arch: arm64
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22.4'
- name: Install dependencies
run: go mod download
- name: Build project for ${{matrix.platform}} ${{matrix.arch}}
run: make build/gookme-${{matrix.platform}}-${{matrix.arch}}
- name: Upload build artifacts for ${{matrix.platform}} ${{matrix.arch}}
uses: actions/upload-artifact@v4
with:
name: build-artifacts-${{ matrix.platform }}-${{ matrix.arch }}
path: build/
merge:
runs-on: ubuntu-latest
needs: build
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: build-artifacts
delete-merged: true
retention-days: 1
compression-level: 9
release:
needs: merge
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: build
- name: Extract VERSION
id: extract_version
run: |
VERSION=$(grep -oP 'VERSION\s*=\s*"\K[^"]+' packages/meta/version.go)
echo "VERSION=$VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create GitHub Release
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
TAG_NAME="v$VERSION"
RELEASE_NAME="Release v$VERSION"
API_URL="https://api.github.com/repos/LMaxence/gookme/releases"
RESPONSE=$(curl -s -X POST -H "X-GitHub-Api-Version: 2022-11-28" -H "Authorization: Bearer $GH_PAT" $API_URL -d "{ \"tag_name\": \"$TAG_NAME\", \"name\": \"$RELEASE_NAME\", \"draft\": false, \"prerelease\": false, \"make_latest\": \"true\" }")
UPLOAD_URL=$(echo $RESPONSE | jq -r .upload_url | sed -e "s/{?name,label}//")
echo "UPLOAD_URL=$UPLOAD_URL" >> $GITHUB_ENV
- name: Upload Release Assets
env:
GH_PAT: ${{ secrets.GH_PAT }}
UPLOAD_URL: ${{ env.UPLOAD_URL }}
run: |
for FILE in build/*; do
FILENAME=$(basename $FILE)
curl -s -X POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Authorization: Bearer $GH_PAT" \
-H "Content-Type: application/octet-stream" \
"$UPLOAD_URL?name=$FILENAME" \
--data-binary "@$FILE"
done