-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (98 loc) · 3.16 KB
/
release.yml
File metadata and controls
115 lines (98 loc) · 3.16 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
jobs:
frontend:
name: Build Frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 20
cache: npm
cache-dependency-path: web/package-lock.json
- run: cd web && npm ci && npm run build
- uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: web/dist/
build:
name: Build ${{ matrix.goos }}/${{ matrix.goarch }}
needs: frontend
strategy:
matrix:
include:
- os: ubuntu-latest
goos: linux
goarch: amd64
- os: ubuntu-latest
goos: linux
goarch: arm64
- os: macos-latest
goos: darwin
goarch: amd64
- os: macos-latest
goos: darwin
goarch: arm64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: "1.22"
cache: true
- uses: actions/download-artifact@v4
with:
name: frontend-dist
path: web/dist/
- name: Embed frontend
run: |
rm -rf cmd/opensnitch-web/frontend
cp -r web/dist cmd/opensnitch-web/frontend
- name: Install cross-compiler
if: matrix.goos == 'linux' && matrix.goarch == 'arm64'
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "1"
run: |
if [ "${{ matrix.goos }}" = "linux" ] && [ "${{ matrix.goarch }}" = "arm64" ]; then
export CC=aarch64-linux-gnu-gcc
fi
VERSION=${GITHUB_REF_NAME}
BUILD_TIME=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
LDFLAGS="-X github.com/bilalbayram/opensnitch-web/internal/version.Version=${VERSION} -X github.com/bilalbayram/opensnitch-web/internal/version.BuildTime=${BUILD_TIME}"
go build -ldflags "${LDFLAGS}" -o opensnitch-web-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/opensnitch-web
- uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.goos }}-${{ matrix.goarch }}
path: opensnitch-web-${{ matrix.goos }}-${{ matrix.goarch }}
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
sparse-checkout: deploy
- uses: actions/download-artifact@v4
with:
pattern: binary-*
merge-multiple: true
- name: Generate checksums
run: sha256sum opensnitch-web-* > checksums.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
prerelease: ${{ contains(github.ref_name, '-beta') || contains(github.ref_name, '-alpha') || contains(github.ref_name, '-rc') }}
generate_release_notes: true
files: |
opensnitch-web-*
checksums.txt
deploy/opensnitch-web.service