diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..bb8815a --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,37 @@ +name: Check Build + +on: + push: + branches: [ "master" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Cargo Cache + uses: actions/cache@v1 + with: + path: ~/.cargo + key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }} + restore-keys: | + ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }} + ${{ runner.os }}-cargo + + - name: Cargo Target Cache + uses: actions/cache@v1 + with: + path: target + key: ${{ runner.os }}-cargo-target-${{ hashFiles('Cargo.toml') }} + restore-keys: | + ${{ runner.os }}-cargo-target-${{ hashFiles('Cargo.toml') }} + ${{ runner.os }}-cargo-target + + - uses: actions/checkout@v3 + - name: Build + run: cargo build --verbose \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..57bfe76 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,88 @@ +name: Rust + +on: + workflow_run: + workflows: ["Check Build"] + types: + - completed + +jobs: + build: + runs-on: ubuntu-latest + + if: ${{ github.event.workflow_run.conclusion == 'success' }} + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Install latest rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + default: true + override: true + + - name: Build + run: cargo build --all --release && strip target/release/PROJECT_NAME && mv target/release/PROJECT_NAME target/release/PROJECT_NAME_amd64 + + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + target/release/PROJECT_NAME_amd64 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build-win: + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Install latest rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + default: true + override: true + + - name: Build + run: cargo build --all --release + + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: target/release/PROJECT_NAME.exe + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build-mac: + runs-on: macos-latest + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Install latest rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: x86_64-apple-darwin + default: true + override: true + + - name: Build for mac + run: cargo build --all --release && strip target/release/PROJECT_NAME && mv target/release/PROJECT_NAME target/release/PROJECT_NAME_darwin + + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + target/release/PROJECT_NAME_darwin + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}