diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..dfebbbc --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,154 @@ +name: Rust + +on: + pull_request: + push: + branches: ["main"] + release: + types: [published] + +env: + CARGO_TERM_COLOR: always + +jobs: + style: + name: Check Style + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: rustfmt + profile: minimal + override: true + - name: Format + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + test: + name: Test + needs: [style] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build + - name: Test + uses: actions-rs/cargo@v1 + with: + command: test + args: --verbose + + deploy_linux: + name: Deploy Linux + needs: [test] + if: ${{ github.event_name == 'release' }} + runs-on: ubuntu-latest + strategy: + matrix: + target: + [ + x86_64-unknown-linux-gnu, + aarch64-unknown-linux-gnu, + arm-unknown-linux-gnueabihf, + ] + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + target: ${{ matrix.target }} + - name: Build target + uses: actions-rs/cargo@v1 + with: + use-cross: true + command: build + args: --release --target ${{ matrix.target }} + - name: Package + shell: bash + run: | + tar -czvf bfrs-${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release/ bfrs + - name: Publish + uses: softprops/action-gh-release@v1 + with: + files: "bfrs*" + + deploy_macos: + name: Deploy macOS + needs: [test] + if: ${{ github.event_name == 'release' }} + runs-on: macos-latest + strategy: + matrix: + target: [x86_64-apple-darwin, aarch64-apple-darwin] + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + target: ${{ matrix.target }} + - name: Build target + uses: actions-rs/cargo@v1 + with: + use-cross: true + command: build + args: --release --target ${{ matrix.target }} + - name: Package + shell: bash + run: | + tar -czvf bfrs-${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release/ bfrs + - name: Publish + uses: softprops/action-gh-release@v1 + with: + files: "bfrs*" + + deploy_windows: + name: Deploy Windows + needs: [test] + if: ${{ github.event_name == 'release' }} + runs-on: ubuntu-latest + strategy: + matrix: + target: [x86_64-pc-windows-gnu] + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + target: ${{ matrix.target }} + - name: Build target + uses: actions-rs/cargo@v1 + with: + use-cross: true + command: build + args: --release --target ${{ matrix.target }} + - name: Package + shell: bash + run: | + tar -czvf bfrs-${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release/ bfrs.exe + - name: Publish + uses: softprops/action-gh-release@v1 + with: + files: "bfrs*"