ci: support musl target #19
This file contains hidden or 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: CI and Release | |
| on: | |
| push: | |
| branches: [ main, ci ] | |
| pull_request: | |
| branches: [ main ] | |
| release: | |
| types: [ published ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| name: Build on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| target: x86_64-unknown-linux-gnu | |
| artifact_name: mwget | |
| asset_name: mwget-linux-x64 | |
| - os: ubuntu-22.04 | |
| target: x86_64-unknown-linux-musl | |
| artifact_name: mwget | |
| asset_name: mwget-linux-x64-musl | |
| - os: ubuntu-22.04-arm | |
| target: aarch64-unknown-linux-gnu | |
| artifact_name: mwget | |
| asset_name: mwget-linux-arm64 | |
| - os: ubuntu-22.04-arm | |
| target: aarch64-unknown-linux-musl | |
| artifact_name: mwget | |
| asset_name: mwget-linux-arm64-musl | |
| - os: macos-15 | |
| target: aarch64-apple-darwin | |
| artifact_name: mwget | |
| asset_name: mwget-macos-arm64 | |
| - os: macos-15-intel | |
| target: x86_64-apple-darwin | |
| artifact_name: mwget | |
| asset_name: mwget-macos-x64 | |
| - os: windows-2022 | |
| target: x86_64-pc-windows-msvc | |
| artifact_name: mwget.exe | |
| asset_name: mwget-windows-x64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install musl-tools (for musl target) | |
| if: contains(matrix.target, 'musl') | |
| run: sudo apt-get update && sudo apt-get install -y musl-tools | |
| - name: Install Rust target | |
| run: rustup target add ${{ matrix.target }} | |
| - name: Build binary | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Strip binary (Unix) | |
| if: runner.os != 'Windows' | |
| run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }} | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.asset_name }} | |
| path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} | |
| release: | |
| name: Create Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Display structure of downloaded files | |
| run: ls -la artifacts/ | |
| - name: Create release archives | |
| run: | | |
| mkdir -p release | |
| cd artifacts | |
| # Linux x64 | |
| tar -czf ../release/mwget-linux-x64.tar.gz mwget-linux-x64/mwget | |
| # Linux x64 musl | |
| tar -czf ../release/mwget-linux-x64-musl.tar.gz mwget-linux-x64-musl/mwget | |
| # Linux ARM64 | |
| tar -czf ../release/mwget-linux-arm64.tar.gz mwget-linux-arm64/mwget | |
| # Linux ARM64 musl | |
| tar -czf ../release/mwget-linux-arm64-musl.tar.gz mwget-linux-arm64-musl/mwget | |
| # macOS ARM64 | |
| tar -czf ../release/mwget-macos-arm64.tar.gz mwget-macos-arm64/mwget | |
| # macOS x64 | |
| tar -czf ../release/mwget-macos-x64.tar.gz mwget-macos-x64/mwget | |
| # Windows x64 | |
| cd mwget-windows-x64 | |
| zip -r ../../release/mwget-windows-x64.zip mwget.exe | |
| - name: Upload release assets | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| release/mwget-linux-x64.tar.gz | |
| release/mwget-linux-x64-musl.tar.gz | |
| release/mwget-linux-arm64.tar.gz | |
| release/mwget-linux-arm64-musl.tar.gz | |
| release/mwget-macos-arm64.tar.gz | |
| release/mwget-macos-x64.tar.gz | |
| release/mwget-windows-x64.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| test: | |
| name: Run tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run tests | |
| run: cargo test --verbose | |
| - name: Run clippy | |
| run: cargo clippy -- -D warnings | |
| - name: Check formatting | |
| run: cargo fmt -- --check |