-
Notifications
You must be signed in to change notification settings - Fork 32
102 lines (89 loc) · 2.81 KB
/
build_upload_bin.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
name: Build and Upload netclient Binaries
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to build from'
required: true
default: 'develop'
version:
description: 'Version to build'
required: true
default: 'v0.0.0'
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
goos: linux
goarch: amd64
- os: windows-latest
goos: windows
goarch: amd64
- os: macos-latest
goos: darwin
goarch: amd64
- os: macos-latest
goos: darwin
goarch: arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
go version
go mod tidy
go build -v -ldflags "-X main.version=${{ github.event.inputs.version }}" -o netclient-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} .
- name: List built binary (Unix)
if: matrix.goos != 'windows'
run: ls -l netclient-*
- name: List built binary (Windows)
if: matrix.goos == 'windows'
run: Get-ChildItem netclient-*
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: netclient-${{ matrix.goos }}-${{ matrix.goarch }}
path: netclient-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }}
upload:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Display structure of downloaded files
run: ls -R
- name: Install SSH key
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H fileserver.clustercat.com >> ~/.ssh/known_hosts
- name: Test SSH connection
run: |
if ssh -o BatchMode=yes -o StrictHostKeyChecking=no -T [email protected]; then
echo "SSH connection successful"
else
echo "SSH connection failed"
exit 1
fi
- name: Upload to server
env:
UPLOAD_PATH_VERSION: /var/www/files/releases/download/${{ github.event.inputs.version }}
run: |
ssh [email protected] "mkdir -p $UPLOAD_PATH_VERSION"
find . -type f -name "netclient-*" -exec scp {} [email protected]:$UPLOAD_PATH_VERSION/ \;