-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (177 loc) · 6.43 KB
/
plugin_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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Plugin-Release
on:
workflow_dispatch:
push:
tags:
- "plugin-v*"
jobs:
build_frontend:
name: Build frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
cache-dependency-path: plugin/monitor/frontend/yarn.lock
- run: yarn
working-directory: plugin/monitor/frontend
- run: yarn build
working-directory: plugin/monitor/frontend
- uses: actions/upload-artifact@v4
with:
name: monitor-frontend
path: plugin/monitor/frontend/dist
retention-days: 1
build_plugin:
needs: build_frontend
name: Build plugin ${{ matrix.platform.os_name }}
runs-on: ${{ matrix.platform.os }}
strategy:
matrix:
platform:
- os_name: linux-x86_64
os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
lib: lib$d.so
- os_name: linux-i686
os: ubuntu-20.04
target: i686-unknown-linux-gnu
lib: lib$d.so
- os_name: linux-aarch64
os: ubuntu-20.04
target: aarch64-unknown-linux-gnu
lib: lib$d.so
- os_name: windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
lib: $d.dll
- os_name: macOS-x86_64
os: macOS-latest
target: x86_64-apple-darwin
lib: lib$d.dylib
- os_name: macOS-aarch64
os: macOS-latest
target: aarch64-apple-darwin
lib: lib$d.dylib
steps:
- uses: actions/checkout@v4
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
- uses: ilammy/setup-nasm@v1
if: ${{ matrix.platform.os == 'windows-latest'}}
- name: Install Protoc
id: protoc-install
uses: arduino/setup-protoc@v3
with:
version: "27.3"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set protoc path
shell: bash
run: |
echo "${{ steps.protoc-install.outputs.path }}" >> $GITHUB_PATH
- name: Update gcc
if: ${{ matrix.platform.os == 'ubuntu-20.04'}}
shell: bash
run: |
echo "CC=gcc-10" >> $GITHUB_ENV
echo "CXX=g++-10" >> $GITHUB_ENV
- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: "both"
target: ${{ matrix.platform.target }}
args: "--locked --release"
strip: false
- uses: actions/download-artifact@v4
with:
name: monitor-frontend
path: release/plugin/assets/_plugin/2eb2e1a5-66b4-45f9-ad24-3c4f05c858aa
- name: Package as archive
shell: bash
run: |
cd release
mkdir plugin/plugin
for d in `ls ../plugin`;do
if [ -f ../plugin/$d/config.yml ];then
mkdir plugin/plugin/$d;
cp ../target/${{ matrix.platform.target }}/release/${{ matrix.platform.lib }} plugin/plugin/$d;
cp ../plugin/$d/config.yml plugin/plugin/$d;
fi
done;
mkdir plugin/plugin/agent/bin
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
cp ../target/${{ matrix.platform.target }}/release/agent.exe plugin/plugin/agent/bin;
else
cp ../target/${{ matrix.platform.target }}/release/agent plugin/plugin/agent/bin;
fi
mv plugin plugin-${{ matrix.platform.os_name }}
cd -
- uses: actions/upload-artifact@v4
with:
name: plugin-${{ matrix.platform.os_name }}
path: release
retention-days: 1
publish_crate:
needs: build_plugin
name: Publish crate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login
run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
- name: Push to crate.io
run: |
cd plugin/monitor_api
cargo publish --no-verify || true
cd -
cd plugin/agent_api
cargo publish --no-verify || true
cd -
package_plugin:
needs: build_plugin
name: Package plugin
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: .
pattern: plugin-*
merge-multiple: true
- name: Merge output
shell: bash
run: |
mkdir bin
mv plugin-linux-x86_64/plugin/agent/bin/agent bin/agent_linux_x64
mv plugin-linux-i686/plugin/agent/bin/agent bin/agent_linux_x86
mv plugin-linux-aarch64/plugin/agent/bin/agent bin/agent_linux_arm64
mv plugin-windows-x86_64/plugin/agent/bin/agent.exe bin/agent_windows_x64.exe
mv plugin-macOS-x86_64/plugin/agent/bin/agent bin/agent_osx_x64
mv plugin-macOS-aarch64/plugin/agent/bin/agent bin/agent_osx_arm64
cp bin/* plugin-linux-x86_64/plugin/agent/bin/
cp bin/* plugin-linux-i686/plugin/agent/bin/
cp bin/* plugin-linux-aarch64/plugin/agent/bin/
cp bin/* plugin-windows-x86_64/plugin/agent/bin/
cp bin/* plugin-macOS-x86_64/plugin/agent/bin/
cp bin/* plugin-macOS-aarch64/plugin/agent/bin/
mkdir pak
tar czvf pak/plugin-linux-x86_64.tar.gz plugin-linux-x86_64
tar czvf pak/plugin-linux-i686.tar.gz plugin-linux-i686
tar czvf pak/plugin-linux-aarch64.tar.gz plugin-linux-aarch64
7z a pak/plugin-windows-x86_64.zip plugin-windows-x86_64
tar czvf pak/plugin-darwin-x86_64.tar.gz plugin-macOS-x86_64
tar czvf pak/plugin-darwin-aarch64.tar.gz plugin-macOS-aarch64
- name: Generate SHA-256
run: |
shasum -a 256 pak/plugin-linux-x86_64.tar.gz > pak/plugin-linux-x86_64.tar.gz.sha256
shasum -a 256 pak/plugin-linux-i686.tar.gz > pak/plugin-linux-i686.tar.gz.sha256
shasum -a 256 pak/plugin-linux-aarch64.tar.gz > pak/plugin-linux-aarch64.tar.gz.sha256
shasum -a 256 pak/plugin-windows-x86_64.zip > pak/plugin-windows-x86_64.zip.sha256
shasum -a 256 pak/plugin-darwin-x86_64.tar.gz > pak/plugin-darwin-x86_64.tar.gz.sha256
shasum -a 256 pak/plugin-darwin-aarch64.tar.gz > pak/plugin-darwin-aarch64.tar.gz.sha256
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
draft: true
files: pak/*