Skip to content

build workflow

build workflow #9

Workflow file for this run

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-latest
target: x86_64-unknown-linux-gnu
lib: lib$d.so
- os_name: linux-i686
os: ubuntu-latest
target: i686-unknown-linux-gnu
lib: lib$d.so
- os_name: linux-aarch64
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
lib: lib$d.so
- os_name: windows-x86_64
os: windows-latest
target: x86_64-pc-windows-gnu
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: 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/*