-
Notifications
You must be signed in to change notification settings - Fork 3
146 lines (123 loc) · 4.5 KB
/
Copy pathbuild-mainnet.yml
File metadata and controls
146 lines (123 loc) · 4.5 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
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Build Mainnet
on:
push:
branches:
- master
jobs:
build:
name: Build ${{ matrix.arch }}
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- arch: x64
runner: ubuntu-latest
targets: node16-linux-x64,node16-macos-x64,node16-win-x64
- arch: arm64
runner: ubuntu-24.04-arm
targets: node16-linux-arm64,node16-macos-arm64,node16-win-arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
- name: Install dependencies
run: npm ci
- name: Build TypeScript
run: npm run mainnet:build:src
- name: Install ldid
run: |
arch=$(uname -m)
curl -sL "https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus7/ldid_linux_${arch}" -o /usr/local/bin/ldid
chmod +x /usr/local/bin/ldid
- name: Build binaries
run: npx pkg out/src/main-mainnet.js -t ${{ matrix.targets }} --output bin/edge
- name: Sign macOS binary
run: ldid -S bin/edge-macos
- name: Rename binaries
run: |
cd bin
for f in edge-linux edge-macos edge-win.exe; do
[ -f "$f" ] || continue
case "$f" in
edge-win.exe) mv "$f" "edge-win-${{ matrix.arch }}.exe" ;;
*) mv "$f" "$f-${{ matrix.arch }}" ;;
esac
done
ls -la
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.arch }}
path: bin/
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
env:
SSH_PORT: ${{ secrets.FILESERVER_SSH_PORT != '' && secrets.FILESERVER_SSH_PORT || '22' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version
id: version
run: echo "version=$(node -p 'require("./package.json").version')" >> "$GITHUB_OUTPUT"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: bin/
merge-multiple: true
- name: Prepare artifacts
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
declare -A binaries=(
["linux/x64"]="edge-linux-x64"
["linux/arm64"]="edge-linux-arm64"
["macos/x64"]="edge-macos-x64"
["macos/arm64"]="edge-macos-arm64"
["windows/x64"]="edge-win-x64.exe"
["windows/arm64"]="edge-win-arm64.exe"
)
for combo in "${!binaries[@]}"; do
platform="${combo%%/*}"
arch="${combo##*/}"
binary="${binaries[$combo]}"
bin_name="edge"
if [[ "$platform" == "windows" ]]; then
bin_name="edge.exe"
fi
dir="dist/${platform}/${arch}/${VERSION}"
mkdir -p "$dir"
cp "bin/${binary}" "${dir}/${bin_name}"
sha256sum "${dir}/${bin_name}" | awk '{print $1}' > "${dir}/checksum"
echo "$VERSION" > "${dir}/version"
done
- name: Deploy to fileserver
env:
SSH_KEY: ${{ secrets.FILESERVER_SSH_KEY }}
SSH_HOST: ${{ secrets.FILESERVER_HOST }}
SSH_USER: ${{ secrets.FILESERVER_SSH_USER }}
BASE_PATH: ${{ secrets.FILESERVER_PATH }}
VERSION: ${{ steps.version.outputs.version }}
run: |
mkdir -p ~/.ssh
echo "$SSH_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan -p "$SSH_PORT" "$SSH_HOST" >> ~/.ssh/known_hosts 2>/dev/null
for platform in linux macos windows; do
for arch in x64 arm64; do
remote_dir="${BASE_PATH}/cli/mainnet/${platform}/${arch}"
ssh -i ~/.ssh/deploy_key -p "$SSH_PORT" -o StrictHostKeyChecking=accept-new \
"${SSH_USER}@${SSH_HOST}" "mkdir -p ${remote_dir}/${VERSION}"
scp -i ~/.ssh/deploy_key -P "$SSH_PORT" -o StrictHostKeyChecking=accept-new \
dist/${platform}/${arch}/${VERSION}/* \
"${SSH_USER}@${SSH_HOST}:${remote_dir}/${VERSION}/"
ssh -i ~/.ssh/deploy_key -p "$SSH_PORT" -o StrictHostKeyChecking=accept-new \
"${SSH_USER}@${SSH_HOST}" "cd ${remote_dir} && rm -rf latest && cp -r ${VERSION} latest"
done
done
rm -f ~/.ssh/deploy_key