build #30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Releases | |
on: | |
workflow_dispatch: | |
repository_dispatch: | |
types: build | |
permissions: | |
contents: write | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build-cross: | |
runs-on: ubuntu-24.04 | |
env: | |
RUST_BACKTRACE: full | |
strategy: | |
fail-fast: false | |
matrix: | |
target: | |
- mips-unknown-linux-musl | |
- mipsel-unknown-linux-musl | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
run: | | |
bash <(curl --proto '=https' --tlsv1.2 -sS ${{ secrets.rustup }}) ${{ matrix.target }} | |
- name: Install upx | |
run: | | |
wget https://github.com/upx/upx/releases/download/v4.2.4/upx-4.2.4-amd64_linux.tar.xz | |
tar Jxf upx-4.2.4-amd64_linux.tar.xz | |
sudo \cp -a upx-4.2.4-amd64_linux/upx /usr/bin/upx | |
rm -rf upx-4.2.4-amd64_linux* | |
- name: Build ${{ matrix.target }} | |
timeout-minutes: 120 | |
run: | | |
git clone https://github.com/shadowsocks/shadowsocks-rust | |
cd shadowsocks-rust | |
shadowsocks_version="$(git describe --tags `git rev-list --tags --max-count=1`)" | |
echo shadowsocks_version="$shadowsocks_version" >> "$GITHUB_ENV" | |
git checkout $(git describe --tags `git rev-list --tags --max-count=1`) | |
cd .. | |
[ "${{ matrix.target }}" = "mips-unknown-linux-musl" ] && target=mips || target=mipsel | |
export $(echo "CARGO_TARGET_$(echo "$target" | tr '[:lower:]' '[:upper:]')_UNKNOWN_LINUX_MUSL_LINKER"="$target-openwrt-linux-musl-gcc") | |
CARGO_BUILD_TARGET=${{ matrix.target }} \ | |
CARGO_HOME=install \ | |
RUSTFLAGS="-Ctarget-feature=-crt-static -lssp_nonshared -Clink-arg=-fuse-ld=bfd" \ | |
TARGET_CC=$target-openwrt-linux-musl-gcc \ | |
cargo install --profile release --features "full" --path "shadowsocks-rust" | |
upx -9 install/bin/* | |
tar -Jcf shadowsocks-$shadowsocks_version.${{ matrix.target }}.tar.xz -C install/bin . | |
sha256sum shadowsocks-$shadowsocks_version.${{ matrix.target }}.tar.xz > shadowsocks-$shadowsocks_version.${{ matrix.target }}.tar.xz.sha256 | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: shadowsocks-${{ env.shadowsocks_version }}.${{ matrix.target }} | |
path: shadowsocks-${{ env.shadowsocks_version }}.${{ matrix.target }}.tar.xz | |
- name: Create release | |
continue-on-error: true | |
uses: ncipollo/release-action@v1 | |
with: | |
name: ${{ env.shadowsocks_version }} | |
allowUpdates: true | |
replacesArtifacts: true | |
commit: main | |
tag: ${{ env.shadowsocks_version }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
artifacts: | | |
shadowsocks-${{ env.shadowsocks_version }}.${{ matrix.target }}.tar.xz | |
shadowsocks-${{ env.shadowsocks_version }}.${{ matrix.target }}.tar.xz.sha256 |