chore: add pr workflow #15
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: build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| check_format: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Install Rustfmt | |
| run: rustup component add rustfmt | |
| - name: Check formatting | |
| run: cargo fmt -- --check | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Cache cargo & target directories | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Run tests | |
| run: cargo test | |
| build: | |
| if: false | |
| needs: [check_format, test] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - release_for: Linux-x86_64 | |
| os: ubuntu-latest | |
| target: x86_64-unknown-linux-musl | |
| bin: git-wippy | |
| name: pregit-wippy-Linux-x86_64.tar.gz | |
| command: build | |
| - release_for: Windows-x86_64 | |
| os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| bin: git-wippy.exe | |
| name: git-wippy-Windows-x86_64.zip | |
| command: both | |
| toolchain: stable | |
| - release_for: macOS-x86_64 | |
| os: macOS-latest | |
| target: x86_64-apple-darwin | |
| bin: git-wippy | |
| name: git-wippy-Darwin-x86_64.tar.gz | |
| command: both | |
| toolchain: stable | |
| - release_for: macOS-AARCH64 | |
| os: macOS-latest | |
| target: aarch64-apple-darwin | |
| bin: git-wippy | |
| name: git-wippy-Darwin-AARCH64.tar.gz | |
| command: both | |
| toolchain: stable | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Cache cargo & target directories | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Install musl-tools on Linux | |
| run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools | |
| if: contains(matrix.platform.name, 'musl') | |
| - name: Setup cross-compilation | |
| uses: houseabsolute/actions-rust-cross@v0 | |
| with: | |
| toolchain: stable | |
| command: ${{ matrix.platform.command }} | |
| target: ${{ matrix.platform.target }} | |
| args: "--locked --release" | |
| strip: true | |
| - name: Package as archive | |
| shell: bash | |
| run: | | |
| cd target/${{ matrix.platform.target }}/release | |
| if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then | |
| 7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} | |
| else | |
| tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} | |
| fi | |
| cd - | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: git-wippy-${{ matrix.platform.os_name }} | |
| path: "git-wippy-*" |