|
| 1 | +name: Release Builds |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + commit: |
| 7 | + description: 'Commit to build' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +env: |
| 12 | + # Show colored output in CI. |
| 13 | + CARGO_TERM_COLOR: always |
| 14 | + # The folder used to store release files - this will be uploaded. |
| 15 | + ARCHIVE: "__ARCHIVE" |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + os: [ |
| 22 | + windows-2022, # EOL = 2026-10-13 | <https://endoflife.date/windows-server> |
| 23 | + macos-15, # EOL = 2027-09-16 | <https://endoflife.date/macos> |
| 24 | + macos-13, # EOL = 2025-10-24 | For x64. |
| 25 | + ubuntu-22.04, # EOL = 2027-04-01 | <https://endoflife.date/ubuntu> |
| 26 | + ubuntu-22.04-arm, |
| 27 | + ] |
| 28 | + |
| 29 | + runs-on: ${{ matrix.os }} |
| 30 | + |
| 31 | + defaults: |
| 32 | + run: |
| 33 | + shell: bash |
| 34 | + |
| 35 | + steps: |
| 36 | + - name: Checkout |
| 37 | + uses: actions/checkout@v4 |
| 38 | + with: |
| 39 | + submodules: recursive |
| 40 | + ref: ${{ inputs.commit }} |
| 41 | + |
| 42 | + - name: Install Rust |
| 43 | + uses: dtolnay/rust-toolchain@master |
| 44 | + with: |
| 45 | + toolchain: stable |
| 46 | + |
| 47 | + - name: Build |
| 48 | + run: cargo build --release --package cuprated |
| 49 | + |
| 50 | + - name: Generate Archives |
| 51 | + run: | |
| 52 | + set -e -o pipefail # Exit on failures |
| 53 | + umask 0022 # 755 permissions |
| 54 | + export TZ=UTC # UTC timezone |
| 55 | +
|
| 56 | + # Reset archive directory in-case. |
| 57 | + rm -rf ${{ env.ARCHIVE }} |
| 58 | + mkdir -p ${{ env.ARCHIVE }} |
| 59 | + ARCHIVE=$(realpath ${{ env.ARCHIVE }}) |
| 60 | + VERSION=$(grep version binaries/cuprated/Cargo.toml | grep -oE [0-9]+.[0-9]+.[0-9]+) |
| 61 | +
|
| 62 | + # All archives have these files. |
| 63 | + cp LICENSE-AGPL target/release/LICENSE |
| 64 | + cp binaries/cuprated/config/Cuprated.toml target/release/ |
| 65 | +
|
| 66 | + OS=${{ matrix.os }} |
| 67 | +
|
| 68 | + # Generate archives for Linux. |
| 69 | + if [ "$RUNNER_OS" == "Linux" ]; then |
| 70 | + # FIXME: <https://github.com/Cuprate/cuprate/issues/396> |
| 71 | + # cp binaries/cuprated/cuprated.service target/release/ |
| 72 | + cd target/release |
| 73 | +
|
| 74 | + if [ "$OS" == "ubuntu-22.04" ]; then |
| 75 | + NAME="cuprated-${VERSION}-linux-x64.tar.gz" |
| 76 | + else |
| 77 | + NAME="cuprated-${VERSION}-linux-arm64.tar.gz" |
| 78 | + fi |
| 79 | +
|
| 80 | + # FIXME: #396 |
| 81 | + # tar -czpf "$ARCHIVE/$NAME" cuprated LICENSE Cuprated.toml cuprated.service |
| 82 | + tar -czpf "$ARCHIVE/$NAME" cuprated LICENSE Cuprated.toml |
| 83 | + fi |
| 84 | +
|
| 85 | + # Generate archives for macOS. |
| 86 | + if [ "$RUNNER_OS" == "macOS" ]; then |
| 87 | + cd target/release |
| 88 | +
|
| 89 | + if [ "$OS" == "macos-15" ]; then |
| 90 | + NAME="cuprated-${VERSION}-macos-arm64.tar.gz" |
| 91 | + else |
| 92 | + NAME="cuprated-${VERSION}-macos-x64.tar.gz" |
| 93 | + fi |
| 94 | +
|
| 95 | + tar -czpf "$ARCHIVE/$NAME" cuprated LICENSE Cuprated.toml |
| 96 | + fi |
| 97 | +
|
| 98 | + # Generate archives for Windows. |
| 99 | + if [ "$RUNNER_OS" == "Windows" ]; then |
| 100 | + mv target/release/cuprated.exe target/release/ |
| 101 | + cd target/release |
| 102 | +
|
| 103 | + NAME="cuprated-${VERSION}-windows-x64.zip" |
| 104 | + powershell Compress-Archive -LiteralPath cuprated.exe, LICENSE, Cuprated.toml -DestinationPath "$ARCHIVE/$NAME" |
| 105 | + fi |
| 106 | +
|
| 107 | + - name: Archive |
| 108 | + uses: actions/upload-artifact@v4 |
| 109 | + with: |
| 110 | + name: ${{ matrix.os }} |
| 111 | + compression-level: 0 |
| 112 | + path: ${{ env.ARCHIVE }}/** |
0 commit comments