|
| 1 | +name: Create Pre Release Binary |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [labeled] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build-artifacts: |
| 9 | + if: github.event.label.name == 'prerelease' |
| 10 | + runs-on: ubuntu-latest |
| 11 | + name: Build Artifacts |
| 12 | + env: |
| 13 | + binary_name: git-diff |
| 14 | + |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Cache cargo registry |
| 19 | + uses: actions/cache@v4 |
| 20 | + with: |
| 21 | + path: ~/.cargo/registry |
| 22 | + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
| 23 | + restore-keys: | |
| 24 | + ${{ runner.os }}-cargo-registry- |
| 25 | +
|
| 26 | + - name: Cache cargo index |
| 27 | + uses: actions/cache@v4 |
| 28 | + with: |
| 29 | + path: ~/.cargo/git |
| 30 | + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |
| 31 | + restore-keys: | |
| 32 | + ${{ runner.os }}-cargo-index- |
| 33 | +
|
| 34 | + - name: Cache cargo build |
| 35 | + uses: actions/cache@v4 |
| 36 | + with: |
| 37 | + path: target |
| 38 | + key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} |
| 39 | + restore-keys: | |
| 40 | + ${{ runner.os }}-cargo-build- |
| 41 | +
|
| 42 | + - name: Build |
| 43 | + run: cargo build --release |
| 44 | + |
| 45 | + - name: Create Archive Folder |
| 46 | + run: mkdir ${{ runner.os }} |
| 47 | + |
| 48 | + - name: Copy Artifact |
| 49 | + run: cp target/release/${{ env.binary_name }} ${{ runner.os }} |
| 50 | + |
| 51 | + - name: Create Tar Archive |
| 52 | + run: tar -czf ${{ runner.os }}.tgz ${{ runner.os }} |
| 53 | + |
| 54 | + - name: Store Archive |
| 55 | + uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + name: ${{ runner.os }} |
| 58 | + path: ${{ runner.os }}.tgz |
| 59 | + |
| 60 | + create-release: |
| 61 | + needs: [build-artifacts] |
| 62 | + runs-on: ubuntu-latest |
| 63 | + name: Create Release |
| 64 | + permissions: |
| 65 | + contents: write |
| 66 | + steps: |
| 67 | + - uses: actions/checkout@v4 |
| 68 | + - uses: actions/download-artifact@v4 |
| 69 | + - name: Get version |
| 70 | + id: get_version |
| 71 | + run: | |
| 72 | + VERSION=$(cat version | tr -d '\n') |
| 73 | + echo "Version: $VERSION" |
| 74 | + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT |
| 75 | + - name: Create Release |
| 76 | + uses: ncipollo/release-action@v1 |
| 77 | + with: |
| 78 | + artifacts: "Linux/Linux.tgz" |
| 79 | + tag: ${{ steps.get_version.outputs.VERSION }}-prerelease |
| 80 | + allowUpdates: true |
| 81 | + makeLatest: false |
0 commit comments