🔧 fix ci #31
This file contains 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
# .github/workflows/release.yml | ||
name: Release | ||
on: | ||
release: | ||
types: [created] | ||
env: | ||
CARGO_TERM_COLOR: always | ||
CARGO_NET_RETRY: 10 | ||
USTUP_MAX_RETRIES: 10 | ||
MACOSX_DEPLOYMENT_TARGET: 10.15 | ||
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | ||
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc | ||
jobs: | ||
release: | ||
strategy: | ||
matrix: | ||
include: | ||
- os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
exe: rwr-profile-server | ||
- os: windows-latest | ||
target: i686-pc-windows-msvc | ||
exe: rwr-profile-server.exe | ||
- os: windows-latest | ||
target: aarch64-pc-windows-msvc | ||
exe: rwr-profile-server.exe | ||
- os: ubuntu-20.04 | ||
target: x86_64-unknown-linux-gnu | ||
container: rockylinux:8 | ||
exe: rwr-profile-server | ||
- os: ubuntu-20.04 | ||
target: aarch64-unknown-linux-gnu | ||
exe: rwr-profile-server | ||
- os: ubuntu-20.04 | ||
target: arm-unknown-linux-gnueabihf | ||
exe: rwr-profile-server | ||
- os: macos-12 | ||
target: x86_64-apple-darwin | ||
exe: rwr-profile-server | ||
- os: macos-12 | ||
target: aarch64-apple-darwin | ||
exe: rwr-profile-server | ||
name: dist (${{ matrix.target }}) | ||
runs-on: ${{ matrix.os }} | ||
container: ${{ matrix.container }} | ||
steps: | ||
- name: Checkout regpository | ||
uses: actions/checkout@v4 | ||
- name: Install toolchain dependencies | ||
if: matrix.container == 'rockylinux:8' | ||
shell: bash | ||
run: | | ||
dnf install -y gcc | ||
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --profile minimal --default-toolchain none -y | ||
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH | ||
- name: Install Rust toolchain | ||
run: | | ||
rustup update --no-self-update stable | ||
rustup target add ${{ matrix.target }} | ||
rustup component add rust-src | ||
- name: Update apt repositories | ||
if: matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'arm-unknown-linux-gnueabihf' | ||
run: sudo apt-get update | ||
- name: Install AArch64 target toolchain | ||
if: matrix.target == 'aarch64-unknown-linux-gnu' | ||
run: sudo apt-get install gcc-aarch64-linux-gnu | ||
- name: Install ARM target toolchain | ||
if: matrix.target == 'arm-unknown-linux-gnueabihf' | ||
run: sudo apt-get install gcc-arm-linux-gnueabihf | ||
- name: Run tests | ||
run: cargo test --release --target ${{ matrix.target }} --verbose | ||
- name: Build release | ||
run: cargo build --release --target ${{ matrix.target }} | ||
- name: Run UPX | ||
# Upx may not support some platforms. Ignore the errors | ||
continue-on-error: true | ||
# Disable upx for mips. See https://github.com/upx/upx/issues/387 | ||
if: matrix.os == 'ubuntu-latest' && !contains(matrix.target, 'mips') | ||
uses: crazy-max/ghaction-upx@v3 | ||
with: | ||
version: v3.96 | ||
files: target/${{ matrix.target }}/release/${{ matrix.exe }} | ||
args: -q --best --lzma | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: rwr-profile-server-${{ matrix.target }} | ||
path: target/${{ matrix.target }}/release/${{ matrix.exe }} | ||
- name: Zip Release | ||
uses: TheDoctor0/[email protected] | ||
with: | ||
type: zip | ||
filename: rwr-profile-server-${{ matrix.target }}.zip | ||
directory: target/${{ matrix.target }}/release/ | ||
path: ${{ matrix.exe }} | ||
- name: Publish | ||
uses: softprops/action-gh-release@v2 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: target/${{ matrix.target }}/release/rwr-profile-server-${{ matrix.target }}.zip | ||
generate_release_notes: true | ||
draft: true | ||
docker: | ||
name: Publish to Docker Hub | ||
if: startsWith(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-latest | ||
needs: release | ||
steps: | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
push: true | ||
tags: zhaozisong0/rwr-profile-server:latest, zhaozisong0/rwr-profile-server:${{ github.ref_name }} | ||
# publish-crate: | ||
# name: Publish to crates.io | ||
# if: startsWith(github.ref, 'refs/tags/') | ||
# runs-on: ubuntu-latest | ||
# needs: release | ||
# steps: | ||
# - uses: actions/checkout@v2 | ||
# - uses: actions-rs/toolchain@v1 | ||
# with: | ||
# profile: minimal | ||
# toolchain: stable | ||
# - name: Publish | ||
# env: | ||
# CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_API_TOKEN }} | ||
# run: cargo publish | ||
# jobs: | ||
# release: | ||
# name: release ${{ matrix.target }} | ||
# runs-on: ubuntu-latest | ||
# strategy: | ||
# fail-fast: false | ||
# matrix: | ||
# target: [x86_64-pc-windows-gnu] | ||
# steps: | ||
# - uses: actions/checkout@master | ||
# - name: Compile and release | ||
# uses: rust-build/rust-build.action@latest | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# RUSTTARGET: ${{ matrix.target }} | ||
# EXTRA_FILES: "README.md LICENSE" | ||
# TOOLCHAIN_VERSION: "nightly" |