| 1 | name: Release |
| 2 | |
| 3 | # A tag like v0.1.1 builds budctl and budctl-gui for x86_64 and aarch64 Linux and publishes them, |
| 4 | # with install.sh and checksums, as a GitHub release. The builds run on Ubuntu 22.04, so they need |
| 5 | # glibc 2.35 or newer and nothing else at build time: Wayland and xkbcommon are loaded at runtime. |
| 6 | |
| 7 | on: |
| 8 | push: |
| 9 | tags: ["v[0-9]+.[0-9]+.[0-9]+"] |
| 10 | |
| 11 | permissions: |
| 12 | contents: write |
| 13 | |
| 14 | jobs: |
| 15 | build: |
| 16 | strategy: |
| 17 | matrix: |
| 18 | include: |
| 19 | - target: x86_64-unknown-linux-gnu |
| 20 | runner: ubuntu-22.04 |
| 21 | - target: aarch64-unknown-linux-gnu |
| 22 | runner: ubuntu-22.04-arm |
| 23 | runs-on: ${{ matrix.runner }} |
| 24 | steps: |
| 25 | - uses: actions/checkout@v6 |
| 26 | - name: The tag matches the version in Cargo.toml |
| 27 | run: | |
| 28 | version=$(sed -n 's/^version = "\(.*\)"$/\1/p' Cargo.toml | head -n 1) |
| 29 | if [ "v$version" != "$GITHUB_REF_NAME" ]; then |
| 30 | echo "tag $GITHUB_REF_NAME, but Cargo.toml says $version" |
| 31 | exit 1 |
| 32 | fi |
| 33 | - uses: dtolnay/rust-toolchain@stable |
| 34 | - run: sudo apt-get update && sudo apt-get install -y pkg-config libwayland-dev libxkbcommon-dev |
| 35 | - run: cargo test --workspace --locked |
| 36 | - run: cargo build --release --locked -p budctl -p budctl-gui |
| 37 | - name: Package |
| 38 | run: | |
| 39 | dir=budctl-${{ matrix.target }} |
| 40 | mkdir "$dir" |
| 41 | cp target/release/budctl target/release/budctl-gui contrib/budctl.desktop install.sh README.md LICENSE "$dir/" |
| 42 | cp crates/budctl-gui/fonts/OFL.txt "$dir/OFL-fonts.txt" |
| 43 | tar -czf "$dir.tar.gz" "$dir" |
| 44 | sha256sum "$dir.tar.gz" > "$dir.tar.gz.sha256" |
| 45 | - uses: actions/upload-artifact@v7 |
| 46 | with: |
| 47 | name: ${{ matrix.target }} |
| 48 | path: budctl-${{ matrix.target }}.tar.gz* |
| 49 | if-no-files-found: error |
| 50 | |
| 51 | publish: |
| 52 | needs: build |
| 53 | runs-on: ubuntu-latest |
| 54 | steps: |
| 55 | - uses: actions/checkout@v6 |
| 56 | - uses: actions/download-artifact@v8 |
| 57 | with: |
| 58 | path: dist |
| 59 | merge-multiple: true |
| 60 | - name: Release notes from CHANGELOG.md |
| 61 | run: | |
| 62 | awk -v v="${GITHUB_REF_NAME#v}" '/^## / { p = ($2 == v); next } p' CHANGELOG.md > notes.md |
| 63 | test -s notes.md || { echo "CHANGELOG.md has no section for ${GITHUB_REF_NAME#v}"; exit 1; } |
| 64 | - name: Publish |
| 65 | env: |
| 66 | GH_TOKEN: ${{ github.token }} |
| 67 | run: gh release create "$GITHUB_REF_NAME" --title "budctl $GITHUB_REF_NAME" --notes-file notes.md dist/* install.sh |