name: build on: push: tags: - "v*.*.*" workflow_dispatch: {} jobs: build: name: build runs-on: ${{ matrix.os }} strategy: matrix: build: [linux, macos, windows] include: - build: linux os: ubuntu-latest rust: stable target: x86_64-unknown-linux-musl archive-name: ncmmiao-linux.tar.gz - build: macos os: macos-latest rust: stable target: x86_64-apple-darwin archive-name: ncmmiao-macos.tar.gz - build: windows os: windows-latest rust: stable-x86_64-msvc target: x86_64-pc-windows-msvc archive-name: ncmmiao-windows.7z fail-fast: false steps: - name: Checkout repository uses: actions/checkout@v4.2.2 - name: Install Rust uses: actions-rs/toolchain@v1 with: toolchain: ${{ matrix.rust }} profile: minimal override: true components: rustfmt, clippy target: ${{ matrix.target }} - name: Test run: cargo test - name: Build binary run: cargo build --verbose --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 }}/release/ncmmiao" - name: Build archive shell: bash run: | mkdir archive # cp LICENSE README.md archive/ cp README.md archive/ cd archive if [ "${{ matrix.build }}" = "windows" ]; then cp "../target/${{ matrix.target }}/release/ncmmiao.exe" ./ # 7z a "${{ matrix.archive-name }}" LICENSE README.md ncmmiao.exe 7z a "${{ matrix.archive-name }}" README.md ncmmiao.exe else cp "../target/${{ matrix.target }}/release/ncmmiao" ./ # tar -czf "${{ matrix.archive-name }}" LICENSE README.md ncmmiao tar -czf "${{ matrix.archive-name }}" README.md ncmmiao fi - name: Release archive uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') with: # name: ${{ matrix.archive-name }} files: archive/${{ matrix.archive-name }} token: ${{ secrets.TOKEN }}