From 45ca50ecf32524371b66ca3fd72bfeaf9a2834ef Mon Sep 17 00:00:00 2001 From: Muhammad Rayhan Hamada Budiman Date: Thu, 19 Nov 2026 04:46:54 +0700 Subject: [PATCH 1/4] ci: release through Knope bot Add knope.toml so Knope Bot maintains release PRs and draft releases. Build artifacts when its release PR merges, upload them to the draft, publish the GitHub release, and update the Homebrew tap. --- .github/workflows/release.yml | 114 +++++++++++++++++++--------------- knope.toml | 16 +++++ 2 files changed, 80 insertions(+), 50 deletions(-) create mode 100644 knope.toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4626f42..41bffda 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,66 +1,73 @@ name: Release on: - push: - tags: - - "v[0-9]+.[0-9]+.[0-9]+" + pull_request: + types: [closed] + branches: [main] + workflow_dispatch: permissions: contents: read concurrency: - group: release-${{ github.ref_name }} + group: release cancel-in-progress: false env: CARGO_TERM_COLOR: always jobs: - test: - name: Test - uses: ./.github/workflows/ci.yml - - validate: - name: Validate tag + get-tag: + name: Find draft release + if: (github.event_name == 'pull_request' && github.head_ref == 'knope/release' && github.event.pull_request.merged == true) || github.event_name == 'workflow_dispatch' runs-on: ubuntu-24.04 + permissions: + contents: write outputs: - version: ${{ steps.version.outputs.version }} + tag: ${{ steps.find.outputs.tag }} + version: ${{ steps.find.outputs.version }} steps: - uses: actions/checkout@v7 with: - fetch-depth: 0 - - uses: dtolnay/rust-toolchain@stable - - name: Verify version and main branch - id: version + ref: main + - name: Find Knope draft release + id: find shell: bash + env: + GH_TOKEN: ${{ github.token }} run: | set -euo pipefail - tag="${GITHUB_REF_NAME}" - if [[ ! "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Tag $tag is not a stable semantic version (vX.Y.Z)." >&2 - exit 1 - fi + package_version="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n 1)" - version="${tag#v}" - package_version="$(cargo metadata --no-deps --format-version 1 \ - | jq -r '.packages[] | select(.name == "android-cli-gui") | .version')" - if [[ "$package_version" != "$version" ]]; then - echo "Tag $tag does not match Cargo.toml version $package_version." >&2 - exit 1 - fi + for attempt in $(seq 1 30); do + tag="$(gh release list --repo "$GITHUB_REPOSITORY" --limit 20 \ + --json isDraft,tagName \ + --jq '[.[] | select(.isDraft and (.tagName | startswith("v")))][0].tagName // ""')" - git fetch --no-tags origin main - if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then - echo "Tag $tag is not on main." >&2 - exit 1 - fi + if [[ -n "$tag" ]]; then + version="${tag#v}" + if [[ "$version" != "$package_version" ]]; then + echo "Draft release $tag does not match Cargo.toml version $package_version." >&2 + exit 1 + fi + echo "tag=$tag" >> "$GITHUB_OUTPUT" + echo "version=$version" >> "$GITHUB_OUTPUT" + echo "Found draft release $tag." + exit 0 + fi + + echo "No draft release yet (attempt $attempt/30); waiting 10s..." + sleep 10 + done - echo "version=$version" >> "$GITHUB_OUTPUT" + echo "No draft release found. Install Knope Bot and merge its release PR first." >&2 + exit 1 build: name: Build (${{ matrix.target }}) - needs: validate + needs: get-tag + if: needs.get-tag.outputs.tag != '' strategy: fail-fast: false matrix: @@ -79,9 +86,12 @@ jobs: artifact: windows-x86_64 runs-on: ${{ matrix.os }} env: + VERSION: ${{ needs.get-tag.outputs.version }} MACOSX_DEPLOYMENT_TARGET: "15.0" steps: - uses: actions/checkout@v7 + with: + ref: main - name: Install Linux dependencies if: runner.os == 'Linux' uses: ./.github/actions/linux-deps @@ -99,16 +109,14 @@ jobs: shell: bash run: | set -euo pipefail - version="${GITHUB_REF_NAME#v}" - asset="android-cli-gui-v${version}-${{ matrix.target }}.tar.gz" + asset="android-cli-gui-v${VERSION}-${{ matrix.target }}.tar.gz" mkdir -p dist tar -C "target/${{ matrix.target }}/release" -czf "dist/${asset}" android-cli-gui - name: Package (Windows) if: runner.os == 'Windows' shell: pwsh run: | - $version = $env:GITHUB_REF_NAME -replace '^v', '' - $asset = "android-cli-gui-v$version-${{ matrix.target }}.zip" + $asset = "android-cli-gui-v$($env:VERSION)-${{ matrix.target }}.zip" New-Item -ItemType Directory -Force -Path dist | Out-Null Compress-Archive -Path "target/${{ matrix.target }}/release/android-cli-gui.exe" -DestinationPath "dist/$asset" - uses: actions/upload-artifact@v7 @@ -117,9 +125,10 @@ jobs: path: dist/* if-no-files-found: error - release: - name: Publish GitHub release - needs: [test, build] + publish: + name: Upload assets and publish + needs: [get-tag, build] + if: needs.get-tag.outputs.tag != '' runs-on: ubuntu-24.04 permissions: contents: write @@ -128,27 +137,31 @@ jobs: with: path: dist merge-multiple: true - - name: Write checksums + - name: Upload assets and publish shell: bash + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + TAG: ${{ needs.get-tag.outputs.tag }} run: | set -euo pipefail cd dist sha256sum -- * > SHA256SUMS.txt cat SHA256SUMS.txt - - uses: softprops/action-gh-release@v3 - with: - files: dist/* - fail_on_unmatched_files: true - generate_release_notes: true + gh release upload "$TAG" --clobber ./* + gh release edit "$TAG" --draft=false --latest homebrew: name: Update Homebrew tap - needs: [release, validate] + needs: [publish, get-tag] + if: needs.get-tag.outputs.tag != '' runs-on: ubuntu-24.04 permissions: contents: read steps: - uses: actions/checkout@v7 + with: + ref: main - uses: actions/download-artifact@v8 with: path: dist @@ -156,7 +169,7 @@ jobs: - name: Render formula shell: bash env: - VERSION: ${{ needs.validate.outputs.version }} + VERSION: ${{ needs.get-tag.outputs.version }} run: | set -euo pipefail @@ -175,6 +188,7 @@ jobs: - name: Push formula to tap shell: bash env: + TAG: ${{ needs.get-tag.outputs.tag }} HOMEBREW_TAP_DEPLOY_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }} run: | set -euo pipefail @@ -198,6 +212,6 @@ jobs: if git -C tap diff --cached --quiet; then echo "Formula is already up to date." else - git -C tap commit -m "android-cli-gui ${GITHUB_REF_NAME}" + git -C tap commit -m "android-cli-gui ${TAG}" git -C tap push origin HEAD:main fi diff --git a/knope.toml b/knope.toml new file mode 100644 index 0000000..65d123f --- /dev/null +++ b/knope.toml @@ -0,0 +1,16 @@ +[package] +versioned_files = [ + "Cargo.toml", + { path = "Cargo.lock", dependency = "android-cli-gui" }, +] +changelog = "CHANGELOG.md" +# Knope Bot creates a draft release when assets are configured. The Release +# workflow attaches the binaries and publishes it. +assets = "marker" + +[bot.releases] +enabled = true + +[github] +owner = "RayhanHamada" +repo = "android-cli-gui" From a40962616ca77ae7132d2a245cef66e9e86097e4 Mon Sep 17 00:00:00 2001 From: Muhammad Rayhan Hamada Budiman Date: Thu, 19 Nov 2026 04:47:56 +0700 Subject: [PATCH 2/4] docs: describe the Knope release flow --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index b46f928..107fbd0 100644 --- a/README.md +++ b/README.md @@ -26,3 +26,10 @@ Requires Rust stable and the [GPUI platform dependencies](https://gpui-kit.com/d ```sh cargo run --release ``` + +## Releases + +Releases are managed by [Knope Bot](https://knope.tech/tutorials/bot-workflow/). +Install the bot for this repository; it keeps a `knope/release` PR up to date. +Merging that PR creates a draft GitHub release, and the Release workflow builds +the binaries, uploads them, publishes the release, and updates the Homebrew tap. From e5a803e8e2e037725acda9b69a3a61f1da7f8422 Mon Sep 17 00:00:00 2001 From: Muhammad Rayhan Hamada Budiman Date: Thu, 19 Nov 2026 04:48:32 +0700 Subject: [PATCH 3/4] ci: build release assets from the release tag --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 41bffda..e559423 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -91,7 +91,7 @@ jobs: steps: - uses: actions/checkout@v7 with: - ref: main + ref: ${{ needs.get-tag.outputs.tag }} - name: Install Linux dependencies if: runner.os == 'Linux' uses: ./.github/actions/linux-deps @@ -161,7 +161,7 @@ jobs: steps: - uses: actions/checkout@v7 with: - ref: main + ref: ${{ needs.get-tag.outputs.tag }} - uses: actions/download-artifact@v8 with: path: dist From f3e00f63e6bc3e21899aee7786003faeee303f6c Mon Sep 17 00:00:00 2001 From: Muhammad Rayhan Hamada Budiman Date: Thu, 19 Nov 2026 04:49:23 +0700 Subject: [PATCH 4/4] ci: wait for the matching Knope draft release --- .github/workflows/release.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e559423..74cd571 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,18 +46,17 @@ jobs: --jq '[.[] | select(.isDraft and (.tagName | startswith("v")))][0].tagName // ""')" if [[ -n "$tag" ]]; then - version="${tag#v}" - if [[ "$version" != "$package_version" ]]; then - echo "Draft release $tag does not match Cargo.toml version $package_version." >&2 - exit 1 + if [[ "${tag#v}" == "$package_version" ]]; then + echo "tag=$tag" >> "$GITHUB_OUTPUT" + echo "version=${tag#v}" >> "$GITHUB_OUTPUT" + echo "Found draft release $tag." + exit 0 fi - echo "tag=$tag" >> "$GITHUB_OUTPUT" - echo "version=$version" >> "$GITHUB_OUTPUT" - echo "Found draft release $tag." - exit 0 + echo "Draft release $tag does not match Cargo.toml version $package_version; waiting..." + else + echo "No draft release yet (attempt $attempt/30); waiting 10s..." fi - echo "No draft release yet (attempt $attempt/30); waiting 10s..." sleep 10 done