Skip to content

Release

Release #30

Workflow file for this run

# .github/workflows/release.yml
name: Release
on:
release:
types: [created]
env:
CARGO_TERM_COLOR: always
jobs:
release:
name: dist (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
exe: rwr-profile-server
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
exe: rwr-profile-server
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
exe: rwr-profile-server
- os: ubuntu-latest
target: arm-unknown-linux-musleabi
exe: rwr-profile-server
- os: ubuntu-latest
target: arm-unknown-linux-musleabihf
exe: rwr-profile-server
- os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
exe: rwr-profile-server
- os: ubuntu-latest
target: mips-unknown-linux-gnu
exe: rwr-profile-server
- os: ubuntu-latest
target: mips-unknown-linux-musl
exe: rwr-profile-server
- os: ubuntu-latest
target: mipsel-unknown-linux-gnu
exe: rwr-profile-server
- os: ubuntu-latest
target: mipsel-unknown-linux-musl
exe: rwr-profile-server
- os: ubuntu-latest
target: mips64-unknown-linux-gnuabi64
exe: rwr-profile-server
- os: ubuntu-latest
target: mips64el-unknown-linux-gnuabi64
exe: rwr-profile-server
- os: macos-latest
target: x86_64-apple-darwin
exe: rwr-profile-server
- os: ubuntu-latest
target: x86_64-pc-windows-gnu
exe: rwr-profile-server.exe
- os: windows-latest
target: x86_64-pc-windows-msvc
exe: rwr-profile-server.exe
steps:
- name: Checkout regpository
uses: actions/checkout@v4
- name: Install Rust toolchain
run: |
rustup update --no-self-update stable
rustup target add ${{ matrix.target }}
rustup component add rust-src
- 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"