Update Dockerfile #20
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
name: Release | |
on: | |
push: | |
branches: [ main, master ] | |
jobs: | |
check-version: | |
runs-on: ubuntu-latest | |
outputs: | |
should_release: ${{ steps.check.outputs.should_release }} | |
version: ${{ steps.check.outputs.version }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- name: Check if Cargo.toml version changed | |
id: check | |
run: | | |
git diff HEAD^ HEAD -G"^version\s*=" server/Cargo.toml | grep "^+.*version\s*=" || echo "No version change" | |
if git diff HEAD^ HEAD -G"^version\s*=" server/Cargo.toml | grep "^+.*version\s*=" > /dev/null; then | |
echo "should_release=true" >> $GITHUB_OUTPUT | |
VERSION=$(grep "^version\s*=" server/Cargo.toml | sed 's/version\s*=\s*"\(.*\)"/\1/') | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
else | |
echo "should_release=false" >> $GITHUB_OUTPUT | |
fi | |
build-and-release: | |
needs: check-version | |
if: needs.check-version.outputs.should_release == 'true' | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
binary_path: target/release/horizon-server | |
asset_name: horizon-linux-amd64 | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
binary_path: target/release/horizon-server.exe | |
asset_name: horizon-windows-amd64.exe | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
binary_path: target/release/horizon-server | |
asset_name: horizon-macos-amd64 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: nightly | |
target: ${{ matrix.target }} | |
- name: Install Linux dependencies | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y pkg-config libssl-dev musl-tools | |
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then | |
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
fi | |
- name: Install cross-compilation tools for musl | |
if: matrix.target == 'aarch64-unknown-linux-musl' | |
run: | | |
sudo apt-get install -y musl-tools | |
rustup target add aarch64-unknown-linux-musl | |
- name: Build | |
working-directory: ./server | |
run: | | |
cargo build --release --target ${{ matrix.target }} | |
env: | |
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
OPENSSL_STATIC: "1" | |
PKG_CONFIG_ALLOW_CROSS: "1" | |
- name: Prepare asset | |
run: | | |
mkdir -p release | |
if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
cp server/target/${{ matrix.target }}/release/horizon-server.exe release/${{ matrix.asset_name }} | |
else | |
cp server/target/${{ matrix.target }}/release/horizon-server release/${{ matrix.asset_name }} | |
fi | |
shell: bash | |
- name: Upload binary to release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: v${{ needs.check-version.outputs.version }} | |
files: release/${{ matrix.asset_name }} | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |