|
| 1 | +name: Rust |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ['main'] |
| 6 | + pull_request: |
| 7 | + branches: ['main'] |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + |
| 12 | +jobs: |
| 13 | + build-windows: |
| 14 | + name: Build (Windows) |
| 15 | + runs-on: windows-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Install toolchain |
| 19 | + uses: actions-rs/toolchain@v1 |
| 20 | + with: |
| 21 | + toolchain: nightly |
| 22 | + override: true |
| 23 | + |
| 24 | + - uses: actions/checkout@v3 |
| 25 | + with: |
| 26 | + submodules: recursive |
| 27 | + |
| 28 | + - uses: Swatinem/rust-cache@v2 |
| 29 | + with: |
| 30 | + cache-on-failure: true |
| 31 | + |
| 32 | + - name: Build |
| 33 | + run: | |
| 34 | + cargo build --verbose --release |
| 35 | + $ARTIFACT_HASH=git rev-parse --short HEAD |
| 36 | + echo "ARTIFACT_HASH=$ARTIFACT_HASH" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 |
| 37 | + id: build-step-windows |
| 38 | + |
| 39 | + - name: Rename Executable |
| 40 | + id: rename-windows |
| 41 | + run: copy target/release/collapsescanner.exe ./CollapseScanner-windows-${{ env.ARTIFACT_HASH }}.exe |
| 42 | + |
| 43 | + - name: Upload Artifact (Windows) |
| 44 | + uses: actions/upload-artifact@v4 |
| 45 | + with: |
| 46 | + name: CollapseScanner-windows-${{ env.ARTIFACT_HASH }} |
| 47 | + path: CollapseScanner-windows-${{ env.ARTIFACT_HASH }}.exe |
| 48 | + |
| 49 | + build-linux: |
| 50 | + name: Build (Linux) |
| 51 | + runs-on: ubuntu-latest |
| 52 | + outputs: |
| 53 | + artifact_hash: ${{ steps.build-step-linux.outputs.artifact_hash }} |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: Install toolchain |
| 57 | + uses: actions-rs/toolchain@v1 |
| 58 | + with: |
| 59 | + toolchain: nightly |
| 60 | + override: true |
| 61 | + |
| 62 | + - uses: actions/checkout@v3 |
| 63 | + with: |
| 64 | + submodules: recursive |
| 65 | + |
| 66 | + - uses: Swatinem/rust-cache@v2 |
| 67 | + with: |
| 68 | + cache-on-failure: true |
| 69 | + |
| 70 | + - name: Build |
| 71 | + run: | |
| 72 | + cargo build --verbose --release |
| 73 | + ARTIFACT_HASH=$(git rev-parse --short HEAD) |
| 74 | + echo "ARTIFACT_HASH=$ARTIFACT_HASH" >> $GITHUB_ENV |
| 75 | + echo "artifact_hash=$ARTIFACT_HASH" >> $GITHUB_OUTPUT |
| 76 | +
|
| 77 | + id: build-step-linux |
| 78 | + |
| 79 | + - name: Rename Executable |
| 80 | + id: rename-linux |
| 81 | + run: mv target/release/collapsescanner ./CollapseScanner-linux-${{ env.ARTIFACT_HASH }} |
| 82 | + |
| 83 | + - name: Upload Artifact (Linux) |
| 84 | + uses: actions/upload-artifact@v4 |
| 85 | + with: |
| 86 | + name: CollapseScanner-linux-${{ env.ARTIFACT_HASH }} |
| 87 | + path: CollapseScanner-linux-${{ env.ARTIFACT_HASH }} |
| 88 | + |
| 89 | + create-release: |
| 90 | + name: Create Release |
| 91 | + needs: [build-windows, build-linux] |
| 92 | + runs-on: ubuntu-latest |
| 93 | + if: github.ref == 'refs/heads/main' |
| 94 | + permissions: |
| 95 | + contents: write |
| 96 | + |
| 97 | + steps: |
| 98 | + - name: Download Artifacts |
| 99 | + uses: actions/download-artifact@v4 |
| 100 | + with: |
| 101 | + pattern: CollapseScanner-* |
| 102 | + |
| 103 | + - name: Release |
| 104 | + id: create_release |
| 105 | + uses: ncipollo/release-action@v1 |
| 106 | + with: |
| 107 | + body: | |
| 108 | + Automatic pre-release created by GitHub Actions |
| 109 | + Builded from commit ${{ needs.build-linux.outputs.ARTIFACT_HASH }} |
| 110 | + name: "Nightly Build ${{ needs.build-linux.outputs.ARTIFACT_HASH }}" |
| 111 | + tag: "prerelease-${{ needs.build-linux.outputs.ARTIFACT_HASH }}" |
| 112 | + prerelease: true |
| 113 | + artifacts: CollapseScanner-windows-${{ needs.build-linux.outputs.ARTIFACT_HASH }}/CollapseScanner-windows-${{ needs.build-linux.outputs.ARTIFACT_HASH }}.exe, CollapseScanner-linux-${{ needs.build-linux.outputs.ARTIFACT_HASH }}/CollapseScanner-linux-${{ needs.build-linux.outputs.artifact_hash }} |
0 commit comments