-
Notifications
You must be signed in to change notification settings - Fork 52
133 lines (118 loc) · 3.74 KB
/
release-cli.yml
File metadata and controls
133 lines (118 loc) · 3.74 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Build CLI Binaries
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., v1.0.0)'
required: true
type: string
create_release:
description: 'Create a GitHub release'
required: false
type: boolean
default: true
jobs:
build-cli:
strategy:
fail-fast: false
matrix:
include:
- goos: darwin
goarch: amd64
suffix: darwin-amd64
- goos: darwin
goarch: arm64
suffix: darwin-arm64
- goos: linux
goarch: amd64
suffix: linux-amd64
- goos: linux
goarch: arm64
suffix: linux-arm64
- goos: linux
goarch: arm
goarm: '7'
suffix: linux-armv7
- goos: windows
goarch: amd64
suffix: windows-amd64
ext: .exe
runs-on: ubuntu-latest
env:
HAS_KEY: ${{ secrets.CONFIG_ENCRYPTION_KEY != '' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.SUBMODULE_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: cli/go.mod
- name: Install garble
run: go install mvdan.cc/garble@latest
- name: Copy resolver list for embedding
run: cp app/src/main/res/raw/resolvers.txt cli/resolvers.txt
- name: Generate obfuscated config key
if: env.HAS_KEY == 'true'
working-directory: cli
env:
CONFIG_ENCRYPTION_KEY: ${{ secrets.CONFIG_ENCRYPTION_KEY }}
run: go run ./cmd/keygen > key_generated.go
- name: Build
working-directory: cli
env:
CGO_ENABLED: '0'
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
run: |
VERSION="${{ github.event.inputs.version || github.ref_name }}"
LDFLAGS="-s -w -X main.version=${VERSION}"
TAGS=""
if [ "$HAS_KEY" = "true" ]; then
TAGS="has_config_key"
fi
garble -seed=random build \
-tags "${TAGS}" -trimpath \
-ldflags="${LDFLAGS}" \
-o ../slipnet-${{ matrix.suffix }}${{ matrix.ext }} .
- name: Compress with UPX
if: matrix.goos != 'windows' && matrix.goos != 'darwin'
run: |
sudo apt-get install -y upx-ucl > /dev/null 2>&1
upx --best --lzma slipnet-${{ matrix.suffix }} || true
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: slipnet-${{ matrix.suffix }}
path: slipnet-${{ matrix.suffix }}${{ matrix.ext }}
release:
needs: build-cli
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && github.event.inputs.create_release == 'true')
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Collect binaries
run: |
mkdir -p release
find artifacts -type f -name 'slipnet-*' -exec mv {} release/ \;
ls -la release/
- name: Create or update release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.version || github.ref_name }}
files: release/*
generate_release_notes: true
prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alpha') || contains(github.ref, 'rc') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}