Skip to content

modified ci

modified ci #13

Workflow file for this run

on: [push, pull_request]
name: build
jobs:
build:
name: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux, macos, windows]
include:
- build: linux
os: ubuntu-latest
rust: nightly
target: x86_64-unknown-linux-musl
archive-name: chatroom-linux.tar.gz
- build: macos
os: macos-latest
rust: nightly
target: x86_64-apple-darwin
archive-name: chatroom-macos.tar.gz
- build: windows
os: windows-2019
rust: nightly-x86_64-msvc
target: x86_64-pc-windows-msvc
archive-name: chatroom-windows.7z
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
target: ${{ matrix.target }}
- name: install openssl-tools
if: matrix.build == 'linux'
run: |
sudo apt-get update
sudo apt-get install libssl-dev cmake pkg-config musl-tools
- name: Build binary
run: |
cargo build --target ${{ matrix.target }}
cargo build --release --target ${{ matrix.target }}
env:
RUST_BACKTRACE: 1
- name: Strip binary (linux and macos)
if: matrix.build == 'linux' || matrix.build == 'macos'
run: |
strip "target/${{ matrix.target }}/debug/chatroom"
strip "target/${{ matrix.target }}/release/chatroom"
- name: Build archive
shell: bash
run: |
mkdir archive
cd archive
if [ "${{ matrix.build }}" = "windows" ]; then
cp "../target/${{ matrix.target }}/debug/chatroom.exe" ./
cp "../target/${{ matrix.target }}/release/chatroom.exe" ./chatroom_release.exe
7z a "${{ matrix.archive-name }}" chatroom.exe
else
cp "../target/${{ matrix.target }}/debug/chatroom" ./
cp "../target/${{ matrix.target }}/release/chatroom" ./chatroom_release
tar -czf "${{ matrix.archive-name }}" chatroom
fi
- name: Upload archive
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.archive-name }}
path: archive/${{ matrix.archive-name }}