mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 02:09:06 +00:00
a0e59f5c56
fix artifacts upload.
109 lines
3.4 KiB
YAML
109 lines
3.4 KiB
YAML
name: Rust
|
|
|
|
on:
|
|
push:
|
|
branches: [ "develop", "main" ]
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
defaults:
|
|
run:
|
|
# necessary for windows
|
|
shell: bash
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
# a list of all the targets
|
|
# 选择使用openssl或者ring,并不是所有平台都支持
|
|
include:
|
|
- TARGET: i686-unknown-linux-musl # test in an alpine container on a mac
|
|
OS: ubuntu-latest
|
|
- TARGET: x86_64-unknown-linux-musl # test in an alpine container on a mac
|
|
OS: ubuntu-latest
|
|
- TARGET: x86_64-apple-darwin # tested on a mac, is not properly signed so there are security warnings
|
|
OS: macos-latest
|
|
- TARGET: aarch64-apple-darwin # tested on a mac, is not properly signed so there are security warnings
|
|
OS: macos-latest
|
|
- TARGET: x86_64-pc-windows-msvc # tested on a windows machine
|
|
OS: windows-latest
|
|
runs-on: ${{ matrix.OS }}
|
|
env:
|
|
NAME: easytier # change with the name of your project
|
|
TARGET: ${{ matrix.TARGET }}
|
|
OS: ${{ matrix.OS }}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Setup protoc
|
|
uses: arduino/setup-protoc@v2
|
|
with:
|
|
# GitHub repo token to use to avoid rate limiter
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Cargo cache
|
|
uses: actions/cache@v4.0.0
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
./target
|
|
key: build-cargo-registry-${{matrix.TARGET}}
|
|
- name: Install rust target
|
|
run: |
|
|
rustup install 1.75
|
|
rustup default 1.75
|
|
rustup target add $TARGET
|
|
- name: Run build
|
|
run: cargo build --release --verbose --target $TARGET
|
|
- name: Compress
|
|
run: |
|
|
mkdir -p ./artifacts/objects/
|
|
# windows is the only OS using a different convention for executable file name
|
|
if [[ $OS =~ ^windows.*$ ]]; then
|
|
SUFFIX=.exe
|
|
cp third_party/Packet.dll ./artifacts/objects/
|
|
cp third_party/wintun.dll ./artifacts/objects/
|
|
fi
|
|
if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then
|
|
TAG=$GITHUB_REF_NAME
|
|
else
|
|
TAG=$GITHUB_SHA
|
|
fi
|
|
mv ./target/$TARGET/release/easytier-core"$SUFFIX" ./artifacts/objects/
|
|
mv ./target/$TARGET/release/easytier-cli"$SUFFIX" ./artifacts/objects/
|
|
tar -cvf ./artifacts/$NAME-$TARGET-$TAG.tar ./artifacts/objects/*
|
|
rm -rf ./artifacts/objects/
|
|
- name: Archive artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: easytier-${{ matrix.OS }}-${{ matrix.TARGET }}
|
|
path: |
|
|
./artifacts/*
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Setup protoc
|
|
uses: arduino/setup-protoc@v2
|
|
with:
|
|
# GitHub repo token to use to avoid rate limiter
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Setup tools for test
|
|
run: sudo apt install bridge-utils
|
|
- name: Setup system for test
|
|
run: |
|
|
sudo sysctl net.bridge.bridge-nf-call-iptables=0
|
|
sudo sysctl net.bridge.bridge-nf-call-ip6tables=0
|
|
- name: Cargo cache
|
|
uses: actions/cache@v4.0.0
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
./target
|
|
key: build-cargo-registry-test
|
|
- name: Run tests
|
|
run: sudo -E env "PATH=$PATH" cargo test --verbose
|