|
| 1 | +name: Nightly Binary Release |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 4 * * *' |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +env: |
| 12 | + CARGO_TERM_COLOR: always |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + name: Build ${{ matrix.target }} |
| 17 | + runs-on: ${{ matrix.runner }} |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - target: x86_64-unknown-linux-gnu |
| 23 | + runner: ubuntu-latest |
| 24 | + binary: presentar |
| 25 | + artifact: presentar-x86_64-linux |
| 26 | + use_cross: true |
| 27 | + - target: x86_64-apple-darwin |
| 28 | + runner: macos-latest |
| 29 | + binary: presentar |
| 30 | + artifact: presentar-x86_64-macos |
| 31 | + use_cross: false |
| 32 | + - target: aarch64-apple-darwin |
| 33 | + runner: macos-latest |
| 34 | + binary: presentar |
| 35 | + artifact: presentar-aarch64-macos |
| 36 | + use_cross: false |
| 37 | + - target: x86_64-pc-windows-msvc |
| 38 | + runner: windows-latest |
| 39 | + binary: presentar.exe |
| 40 | + artifact: presentar-x86_64-windows.exe |
| 41 | + use_cross: false |
| 42 | + |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + |
| 46 | + - name: Install Rust |
| 47 | + uses: dtolnay/rust-toolchain@stable |
| 48 | + with: |
| 49 | + targets: ${{ matrix.target }} |
| 50 | + |
| 51 | + - name: Install cross |
| 52 | + if: matrix.use_cross |
| 53 | + run: cargo install cross --locked |
| 54 | + |
| 55 | + - name: Build (cross) |
| 56 | + if: matrix.use_cross |
| 57 | + run: cross build --release --target ${{ matrix.target }} -p presentar-cli |
| 58 | + |
| 59 | + - name: Build (native) |
| 60 | + if: "!matrix.use_cross" |
| 61 | + run: cargo build --release --target ${{ matrix.target }} -p presentar-cli |
| 62 | + |
| 63 | + - name: Rename binary |
| 64 | + shell: bash |
| 65 | + run: cp target/${{ matrix.target }}/release/${{ matrix.binary }} ${{ matrix.artifact }} |
| 66 | + |
| 67 | + - name: Upload artifact |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: ${{ matrix.artifact }} |
| 71 | + path: ${{ matrix.artifact }} |
| 72 | + |
| 73 | + release: |
| 74 | + name: Publish Nightly Release |
| 75 | + needs: build |
| 76 | + runs-on: ubuntu-latest |
| 77 | + |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v4 |
| 80 | + |
| 81 | + - name: Download all artifacts |
| 82 | + uses: actions/download-artifact@v4 |
| 83 | + with: |
| 84 | + path: artifacts/ |
| 85 | + |
| 86 | + - name: Prepare release assets |
| 87 | + run: | |
| 88 | + mkdir -p release/ |
| 89 | + find artifacts/ -type f | while read f; do |
| 90 | + cp "$f" release/ |
| 91 | + done |
| 92 | + ls -lh release/ |
| 93 | +
|
| 94 | + - name: Delete existing nightly tag |
| 95 | + run: gh release delete nightly --cleanup-tag -y || true |
| 96 | + env: |
| 97 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + |
| 99 | + - name: Create nightly release |
| 100 | + uses: softprops/action-gh-release@v2 |
| 101 | + with: |
| 102 | + tag_name: nightly |
| 103 | + name: "Nightly Build (${{ github.sha }})" |
| 104 | + body: | |
| 105 | + Automated nightly build from `main` branch. |
| 106 | + Commit: ${{ github.sha }} |
| 107 | + Date: ${{ github.event.head_commit.timestamp || github.event.repository.updated_at }} |
| 108 | + prerelease: true |
| 109 | + files: release/* |
| 110 | + make_latest: false |
0 commit comments