2024-05-10 17:44:16 +08:00
|
|
|
name: EasyTier Core
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2024-09-19 23:50:58 +08:00
|
|
|
branches: ["develop", "main", "releases/**"]
|
2024-05-10 17:44:16 +08:00
|
|
|
pull_request:
|
|
|
|
branches: ["develop", "main"]
|
|
|
|
|
|
|
|
env:
|
|
|
|
CARGO_TERM_COLOR: always
|
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
# necessary for windows
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
jobs:
|
2024-05-10 22:25:37 +08:00
|
|
|
pre_job:
|
|
|
|
# continue-on-error: true # Uncomment once integration is finished
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
# Map a step output to a job output
|
|
|
|
outputs:
|
2024-09-19 23:50:58 +08:00
|
|
|
# do not skip push on branch starts with releases/
|
|
|
|
should_skip: ${{ steps.skip_check.outputs.should_skip == 'true' && !startsWith(github.ref_name, 'releases/') }}
|
2024-05-10 22:25:37 +08:00
|
|
|
steps:
|
|
|
|
- id: skip_check
|
|
|
|
uses: fkirc/skip-duplicate-actions@v5
|
|
|
|
with:
|
|
|
|
# All of these options are optional, so you can remove them if you are happy with the defaults
|
2024-09-19 23:50:58 +08:00
|
|
|
concurrent_skipping: 'same_content_newer'
|
2024-05-10 22:25:37 +08:00
|
|
|
skip_after_successful_duplicate: 'true'
|
2024-09-19 23:50:58 +08:00
|
|
|
cancel_others: 'true'
|
2024-08-04 09:46:24 +08:00
|
|
|
paths: '["Cargo.toml", "Cargo.lock", "easytier/**", ".github/workflows/core.yml", ".github/workflows/install_rust.sh"]'
|
2024-05-10 17:44:16 +08:00
|
|
|
build:
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- TARGET: aarch64-unknown-linux-musl
|
|
|
|
OS: ubuntu-latest
|
2024-08-03 12:41:59 +08:00
|
|
|
ARTIFACT_NAME: linux-aarch64
|
2024-05-10 17:44:16 +08:00
|
|
|
- TARGET: x86_64-unknown-linux-musl
|
|
|
|
OS: ubuntu-latest
|
2024-08-03 12:41:59 +08:00
|
|
|
ARTIFACT_NAME: linux-x86_64
|
2024-05-10 17:44:16 +08:00
|
|
|
- TARGET: mips-unknown-linux-musl
|
|
|
|
OS: ubuntu-latest
|
2024-08-03 12:41:59 +08:00
|
|
|
ARTIFACT_NAME: linux-mips
|
2024-05-10 17:44:16 +08:00
|
|
|
- TARGET: mipsel-unknown-linux-musl
|
|
|
|
OS: ubuntu-latest
|
2024-08-03 12:41:59 +08:00
|
|
|
ARTIFACT_NAME: linux-mipsel
|
|
|
|
- TARGET: armv7-unknown-linux-musleabihf # raspberry pi 2-3-4, not tested
|
|
|
|
OS: ubuntu-latest
|
|
|
|
ARTIFACT_NAME: linux-armv7hf
|
|
|
|
- TARGET: armv7-unknown-linux-musleabi # raspberry pi 2-3-4, not tested
|
|
|
|
OS: ubuntu-latest
|
|
|
|
ARTIFACT_NAME: linux-armv7
|
|
|
|
- TARGET: arm-unknown-linux-musleabihf # raspberry pi 0-1, not tested
|
|
|
|
OS: ubuntu-latest
|
|
|
|
ARTIFACT_NAME: linux-armhf
|
|
|
|
- TARGET: arm-unknown-linux-musleabi # raspberry pi 0-1, not tested
|
|
|
|
OS: ubuntu-latest
|
|
|
|
ARTIFACT_NAME: linux-arm
|
2024-05-10 17:44:16 +08:00
|
|
|
|
|
|
|
- TARGET: x86_64-apple-darwin
|
|
|
|
OS: macos-latest
|
2024-08-03 12:41:59 +08:00
|
|
|
ARTIFACT_NAME: macos-x86_64
|
2024-05-10 17:44:16 +08:00
|
|
|
- TARGET: aarch64-apple-darwin
|
|
|
|
OS: macos-latest
|
2024-08-03 12:41:59 +08:00
|
|
|
ARTIFACT_NAME: macos-aarch64
|
2024-05-10 17:44:16 +08:00
|
|
|
|
|
|
|
- TARGET: x86_64-pc-windows-msvc
|
|
|
|
OS: windows-latest
|
2024-08-03 12:41:59 +08:00
|
|
|
ARTIFACT_NAME: windows-x86_64
|
2024-06-03 23:07:44 +08:00
|
|
|
|
2024-08-25 00:44:45 +08:00
|
|
|
- TARGET: x86_64-unknown-freebsd
|
|
|
|
OS: ubuntu-latest
|
|
|
|
ARTIFACT_NAME: freebsd-13.2-x86_64
|
|
|
|
BSD_VERSION: 13.2
|
|
|
|
|
2024-05-10 17:44:16 +08:00
|
|
|
runs-on: ${{ matrix.OS }}
|
|
|
|
env:
|
|
|
|
NAME: easytier
|
|
|
|
TARGET: ${{ matrix.TARGET }}
|
|
|
|
OS: ${{ matrix.OS }}
|
|
|
|
OSS_BUCKET: ${{ secrets.ALIYUN_OSS_BUCKET }}
|
2024-05-10 22:25:37 +08:00
|
|
|
needs: pre_job
|
|
|
|
if: needs.pre_job.outputs.should_skip != 'true'
|
2024-05-10 17:44:16 +08:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
2024-09-19 23:50:58 +08:00
|
|
|
- name: Set current ref as env variable
|
|
|
|
run: |
|
|
|
|
echo "GIT_DESC=$(git log -1 --format=%cd.%h --date=format:%Y-%m-%d_%H:%M:%S)" >> $GITHUB_ENV
|
|
|
|
|
2024-05-10 17:44:16 +08:00
|
|
|
- name: Cargo cache
|
|
|
|
uses: actions/cache@v4
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cargo
|
|
|
|
./target
|
|
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
|
|
|
|
- name: Setup protoc
|
|
|
|
uses: arduino/setup-protoc@v2
|
|
|
|
with:
|
|
|
|
# GitHub repo token to use to avoid rate limiter
|
|
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Build Core & Cli
|
2024-08-25 00:44:45 +08:00
|
|
|
if: ${{ ! endsWith(matrix.TARGET, 'freebsd') }}
|
2024-05-10 17:44:16 +08:00
|
|
|
run: |
|
2024-08-25 00:44:45 +08:00
|
|
|
bash ./.github/workflows/install_rust.sh
|
2024-05-10 17:44:16 +08:00
|
|
|
if [[ $OS =~ ^ubuntu.*$ && $TARGET =~ ^mips.*$ ]]; then
|
2024-06-02 09:15:40 +08:00
|
|
|
cargo +nightly build -r --verbose --target $TARGET -Z build-std=std,panic_abort --no-default-features --features mips
|
2024-05-10 17:44:16 +08:00
|
|
|
else
|
|
|
|
cargo build --release --verbose --target $TARGET
|
|
|
|
fi
|
|
|
|
|
2024-08-25 00:44:45 +08:00
|
|
|
# Copied and slightly modified from @lmq8267 (https://github.com/lmq8267)
|
|
|
|
- name: Build Core & Cli (X86_64 FreeBSD)
|
|
|
|
uses: cross-platform-actions/action@v0.23.0
|
|
|
|
if: ${{ endsWith(matrix.TARGET, 'freebsd') }}
|
|
|
|
env:
|
|
|
|
TARGET: ${{ matrix.TARGET }}
|
|
|
|
with:
|
|
|
|
operating_system: freebsd
|
|
|
|
environment_variables: TARGET
|
|
|
|
architecture: x86-64
|
|
|
|
version: ${{ matrix.BSD_VERSION }}
|
|
|
|
shell: bash
|
|
|
|
memory: 5G
|
|
|
|
cpu_count: 4
|
|
|
|
run: |
|
|
|
|
uname -a
|
|
|
|
echo $SHELL
|
|
|
|
pwd
|
|
|
|
ls -lah
|
|
|
|
whoami
|
|
|
|
env | sort
|
|
|
|
|
|
|
|
sudo pkg install -y git protobuf
|
|
|
|
curl --proto 'https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
|
|
source $HOME/.cargo/env
|
|
|
|
|
|
|
|
rustup set auto-self-update disable
|
|
|
|
|
|
|
|
rustup install 1.77
|
|
|
|
rustup default 1.77
|
|
|
|
|
|
|
|
export CC=clang
|
|
|
|
export CXX=clang++
|
|
|
|
export CARGO_TERM_COLOR=always
|
|
|
|
|
|
|
|
cargo build --release --verbose --target $TARGET
|
|
|
|
|
2024-06-03 23:07:44 +08:00
|
|
|
- name: Install UPX
|
2024-06-02 09:15:40 +08:00
|
|
|
if: ${{ matrix.OS != 'macos-latest' }}
|
|
|
|
uses: crazy-max/ghaction-upx@v3
|
|
|
|
with:
|
|
|
|
version: latest
|
2024-06-03 23:07:44 +08:00
|
|
|
install-only: true
|
2024-06-02 09:15:40 +08:00
|
|
|
|
2024-05-10 17:44:16 +08:00
|
|
|
- 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 easytier/third_party/Packet.dll ./artifacts/objects/
|
|
|
|
cp easytier/third_party/wintun.dll ./artifacts/objects/
|
|
|
|
fi
|
|
|
|
if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then
|
|
|
|
TAG=$GITHUB_REF_NAME
|
|
|
|
else
|
|
|
|
TAG=$GITHUB_SHA
|
|
|
|
fi
|
2024-06-03 23:07:44 +08:00
|
|
|
|
2024-08-25 00:44:45 +08:00
|
|
|
if [[ $OS =~ ^ubuntu.*$ && ! $TARGET =~ ^.*freebsd$ ]]; then
|
2024-06-03 23:07:44 +08:00
|
|
|
upx --lzma --best ./target/$TARGET/release/easytier-core"$SUFFIX"
|
|
|
|
upx --lzma --best ./target/$TARGET/release/easytier-cli"$SUFFIX"
|
|
|
|
fi
|
|
|
|
|
2024-05-10 17:44:16 +08:00
|
|
|
mv ./target/$TARGET/release/easytier-core"$SUFFIX" ./artifacts/objects/
|
|
|
|
mv ./target/$TARGET/release/easytier-cli"$SUFFIX" ./artifacts/objects/
|
|
|
|
|
2024-08-03 12:41:59 +08:00
|
|
|
mv ./artifacts/objects/* ./artifacts/
|
2024-05-10 17:44:16 +08:00
|
|
|
rm -rf ./artifacts/objects/
|
|
|
|
|
|
|
|
- name: Archive artifact
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
2024-08-03 12:41:59 +08:00
|
|
|
name: easytier-${{ matrix.ARTIFACT_NAME }}
|
2024-05-10 17:44:16 +08:00
|
|
|
path: |
|
|
|
|
./artifacts/*
|
|
|
|
|
|
|
|
- name: Upload OSS
|
|
|
|
if: ${{ env.OSS_BUCKET != '' }}
|
|
|
|
uses: Menci/upload-to-oss@main
|
|
|
|
with:
|
|
|
|
access-key-id: ${{ secrets.ALIYUN_OSS_ACCESS_ID }}
|
|
|
|
access-key-secret: ${{ secrets.ALIYUN_OSS_ACCESS_KEY }}
|
|
|
|
endpoint: ${{ secrets.ALIYUN_OSS_ENDPOINT }}
|
|
|
|
bucket: ${{ secrets.ALIYUN_OSS_BUCKET }}
|
|
|
|
local-path: ./artifacts/
|
2024-09-19 23:50:58 +08:00
|
|
|
remote-path: /easytier-releases/${{env.GIT_DESC}}/easytier-${{ matrix.ARTIFACT_NAME }}
|
2024-05-10 17:44:16 +08:00
|
|
|
no-delete-remote-files: true
|
|
|
|
retry: 5
|
2024-05-11 00:14:42 +08:00
|
|
|
core-result:
|
|
|
|
if: needs.pre_job.outputs.should_skip != 'true' && always()
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- pre_job
|
|
|
|
- build
|
|
|
|
steps:
|
|
|
|
- name: Mark result as failed
|
|
|
|
if: needs.build.result != 'success'
|
|
|
|
run: exit 1
|