|
| 1 | +name: Build and upload release |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + |
| 6 | +on: |
| 7 | + release: |
| 8 | + types: [published] |
| 9 | + |
| 10 | +env: |
| 11 | + CARGO_INCREMENTAL: 0 |
| 12 | + CARGO_NET_GIT_FETCH_WITH_CLI: true |
| 13 | + CARGO_NET_RETRY: 10 |
| 14 | + CARGO_TERM_COLOR: always |
| 15 | + CARGO_PROFILE_RELEASE_LTO: true |
| 16 | + RUST_BACKTRACE: 1 |
| 17 | + RUSTFLAGS: -D warnings |
| 18 | + RUSTUP_MAX_RETRIES: 10 |
| 19 | + |
| 20 | +defaults: |
| 21 | + run: |
| 22 | + shell: bash |
| 23 | + |
| 24 | +jobs: |
| 25 | + upload-assets: |
| 26 | + name: ${{ matrix.target }} |
| 27 | + runs-on: ${{ matrix.os }} |
| 28 | + timeout-minutes: 60 |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + include: |
| 33 | + - target: aarch64-unknown-linux-gnu |
| 34 | + os: ubuntu-22.04-arm |
| 35 | + - target: x86_64-unknown-linux-gnu |
| 36 | + os: ubuntu-22.04 |
| 37 | + |
| 38 | + - target: aarch64-apple-darwin |
| 39 | + os: macos-13 |
| 40 | + - target: x86_64-apple-darwin |
| 41 | + os: macos-13 |
| 42 | + |
| 43 | + - target: aarch64-pc-windows-msvc |
| 44 | + os: windows-2022 |
| 45 | + - target: x86_64-pc-windows-msvc |
| 46 | + os: windows-2022 |
| 47 | + steps: |
| 48 | + - name: Install Linux system dependencies |
| 49 | + if: startsWith(matrix.os, 'ubuntu') |
| 50 | + run: sudo apt-get install libxcb1-dev libdbus-1-dev |
| 51 | + - name: Checkout repository |
| 52 | + uses: actions/checkout@v4 |
| 53 | + - name: Install Rust toolchain |
| 54 | + uses: dtolnay/rust-toolchain@stable |
| 55 | + - uses: taiki-e/setup-cross-toolchain-action@v1 |
| 56 | + with: |
| 57 | + target: ${{ matrix.target }} |
| 58 | + if: startsWith(matrix.os, 'ubuntu') |
| 59 | + - run: echo "RUSTFLAGS=${RUSTFLAGS} -C target-feature=+crt-static" >> "${GITHUB_ENV}" |
| 60 | + if: endsWith(matrix.target, 'windows-msvc') |
| 61 | + - uses: taiki-e/upload-rust-binary-action@v1 |
| 62 | + with: |
| 63 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + bin: tattoy |
| 65 | + target: ${{ matrix.target }} |
| 66 | + locked: true |
| 67 | + tar: unix |
| 68 | + zip: windows |
| 69 | + checksum: sha256 |
| 70 | + |
| 71 | + publish-deb: |
| 72 | + name: Publish Debian package |
| 73 | + runs-on: ubuntu-22.04 |
| 74 | + steps: |
| 75 | + - name: Install Linux system dependencies |
| 76 | + run: sudo apt-get install libxcb1-dev libdbus-1-dev |
| 77 | + - name: Checkout |
| 78 | + uses: actions/checkout@v4 |
| 79 | + - name: Install Rust toolchain |
| 80 | + uses: dtolnay/rust-toolchain@stable |
| 81 | + with: |
| 82 | + targets: x86_64-unknown-linux-gnu |
| 83 | + - name: Install `cargo-deb` |
| 84 | + uses: taiki-e/install-action@v2 |
| 85 | + with: |
| 86 | + tool: cargo-deb |
| 87 | + - name: Build Debian package |
| 88 | + run: | |
| 89 | + cargo build --release --locked --package tattoy |
| 90 | + cargo-deb \ |
| 91 | + --deb-revision="" \ |
| 92 | + --strip \ |
| 93 | + --package tattoy \ |
| 94 | + --verbose \ |
| 95 | + --output tattoy${{ github.ref_name }}.deb |
| 96 | + - name: Upload .deb to the release |
| 97 | + uses: svenstaro/upload-release-action@v2 |
| 98 | + with: |
| 99 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 100 | + file: tattoy${{ github.ref_name }}.deb |
| 101 | + tag: ${{ github.ref_name }} |
| 102 | + |
| 103 | + publish-rpm: |
| 104 | + name: Publish RPM package |
| 105 | + runs-on: ubuntu-22.04 |
| 106 | + steps: |
| 107 | + - name: Install Linux system dependencies |
| 108 | + run: sudo apt-get install libxcb1-dev libdbus-1-dev |
| 109 | + - name: Checkout |
| 110 | + uses: actions/checkout@v4 |
| 111 | + - name: Install Rust toolchain |
| 112 | + uses: dtolnay/rust-toolchain@stable |
| 113 | + with: |
| 114 | + targets: x86_64-unknown-linux-gnu |
| 115 | + - name: Install `cargo-deb` |
| 116 | + uses: taiki-e/install-action@v2 |
| 117 | + with: |
| 118 | + tool: cargo-generate-rpm |
| 119 | + - name: Build RPM package |
| 120 | + run: | |
| 121 | + cargo build --release --locked --package tattoy |
| 122 | + cargo generate-rpm \ |
| 123 | + --package crates/tattoy \ |
| 124 | + --output tattoy-${{ github.ref_name }}.x86_64.rpm |
| 125 | + - name: Upload the release |
| 126 | + uses: svenstaro/upload-release-action@v2 |
| 127 | + with: |
| 128 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 129 | + file: tattoy-${{ github.ref_name }}.x86_64.rpm |
| 130 | + tag: ${{ github.ref }} |
0 commit comments