Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 63 additions & 50 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,72 @@
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
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 "Draft release $tag does not match Cargo.toml version $package_version; waiting..."
else
echo "No draft release yet (attempt $attempt/30); waiting 10s..."
fi

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:
Expand All @@ -79,9 +85,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: ${{ needs.get-tag.outputs.tag }}
- name: Install Linux dependencies
if: runner.os == 'Linux'
uses: ./.github/actions/linux-deps
Expand All @@ -99,16 +108,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
Expand All @@ -117,9 +124,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
Expand All @@ -128,35 +136,39 @@ 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: ${{ needs.get-tag.outputs.tag }}
- uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Render formula
shell: bash
env:
VERSION: ${{ needs.validate.outputs.version }}
VERSION: ${{ needs.get-tag.outputs.version }}
run: |
set -euo pipefail

Expand All @@ -175,6 +187,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
Expand All @@ -198,6 +211,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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
16 changes: 16 additions & 0 deletions knope.toml
Original file line number Diff line number Diff line change
@@ -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"
Loading