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
2 changes: 0 additions & 2 deletions .github/release-plz.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[workspace]
changelog_update = true
git_only = true
publish = false
git_tag_enable = true
git_release_enable = true
git_release_type = "auto"
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 20
# crates.io trusts this workflow and environment; release-plz exchanges
# the job's OIDC token for a short-lived publish token.
environment: crates-io
permissions:
contents: read
id-token: write
steps:
- name: harden runner
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
Expand Down
66 changes: 61 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Release builds once release-plz has published a GitHub release: a wheel and
# a binary archive per platform, the archives attached to the release and the
# wheels sent to PyPI. release-plz owns the version, the tag and crates.io
# (docs/reference/release.md). One machine per platform, because these are the
# only jobs that must run on macOS and Windows (ADR 0017). A pull request that
# changes the release build runs the builds without publishing anything.
# a binary archive per platform, the archives attached to the release, the
# wheels sent to PyPI and the Homebrew formula rewritten. release-plz owns the
# version, the tag and crates.io (docs/reference/release.md). One machine per
# platform, because these are the only jobs that must run on macOS and Windows
# (ADR 0017). A pull request that changes the release build runs the builds
# without publishing anything.
name: release

on:
Expand Down Expand Up @@ -184,3 +185,58 @@ jobs:
enable-cache: false
- name: publish
run: uv publish --trusted-publishing always dist/*

# Rewrites Formula/dataseek.rb in lmarkmann/homebrew-tap from the checksums
# just attached, with a release App token scoped to that one repository.
homebrew:
if: github.event_name == 'release' && !github.event.release.prerelease
needs: assets
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- name: harden runner
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
with:
egress-policy: audit
- name: token
id: app
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ vars.RELEASE_APP_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
owner: lmarkmann
repositories: homebrew-tap
permission-contents: write
- name: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: checkout tap
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: lmarkmann/homebrew-tap
token: ${{ steps.app.outputs.token }}
path: tap
persist-credentials: false
- name: formula
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
TAG: ${{ github.event.release.tag_name }}
run: |
gh release download "$TAG" --repo "$REPO" -p '*.tar.gz.sha256' -D sums
scripts/homebrew-formula.sh "$TAG" sums > tap/Formula/dataseek.rb
- name: push
working-directory: tap
env:
TOKEN: ${{ steps.app.outputs.token }}
TAG: ${{ github.event.release.tag_name }}
run: |
git config user.name "lmarkmann-release[bot]"
git config user.email "333785277+lmarkmann-release[bot]@users.noreply.github.com"
git add Formula/dataseek.rb
git diff --cached --quiet && exit 0
git commit -m "dataseek $TAG"
git push "https://x-access-token:$TOKEN@github.com/lmarkmann/homebrew-tap.git" HEAD:main
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ Most sources need no key and nothing to set up. Results come back in the termina
## Install

```sh
cargo install --locked dataseek # builds dataseek and dsk from source
cargo binstall dataseek # a prebuilt binary when the release has one, else builds
uv tool install dataseek # installs dataseek and dsk with uv
brew install lmarkmann/tap/dataseek # dataseek and dsk, with completions and the man page
cargo binstall dataseek # the prebuilt binaries from the release
cargo install --locked dataseek # builds them from source
uv tool install dataseek # the binaries in a wheel
```

To run it once without installing:
Expand All @@ -25,7 +26,7 @@ crgx --allow-build dataseek search sea surface temperature
uvx dataseek search sea surface temperature
```

To upgrade, run the install command again, or `uv tool upgrade dataseek` for uv. Building from source needs a recent stable Rust toolchain; from a clone, `cargo install --locked --path .` does the same.
To upgrade, run the install command again, or `brew upgrade dataseek` and `uv tool upgrade dataseek`. Building from source needs a recent stable Rust toolchain; from a clone, `cargo install --locked --path .` does the same.

## Usage

Expand Down
10 changes: 2 additions & 8 deletions docs/reference/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Nothing earlier than v0.3.0 exists: release-plz diffs against the newest `v*` ta

`.github/release-plz.toml`, passed through the action's `config` input in both jobs and `--config` locally:

- `git_only = true`, `publish = false`: the previous version comes from git tags, not crates.io, and release-plz publishes nothing. Both go once the first crates.io release exists (below).
- `git_release_enable = true`, `git_release_type = "auto"`, `git_release_body = "{{ changelog }}"`: every tag gets a GitHub release carrying that version's section.
- `release_commits`: release-plz decides whether to release from changed files, not from changelog groups, so without it a `ci:` merge alone opens a release with an empty section. That is how v0.3.1 happened.
- `features_always_increment_minor = true`: see ADR 0003.
Expand Down Expand Up @@ -59,16 +58,11 @@ No release-plz subcommand has a dry-run flag, so the recipe runs the real `relea

`cargo install dataseek` installs `dataseek` and `dsk`. The package holds only what building needs (`cargo package --list`); the `internals` feature is for the benches and unstable.

crates.io trusts a publisher only for a crate that exists, so the first release goes up by hand:

1. Merge the release PR; release-plz tags `vX.Y.Z`.
2. `git switch --detach vX.Y.Z && cargo publish --locked`, with a new-crate token in `CARGO_REGISTRY_TOKEN`.
3. Add the trusted publisher on crates.io (`lmarkmann/dataseek`, workflow `release-plz.yml`, environment `crates-io`), then revoke the token.
4. Drop `git_only` and `publish = false` from `.github/release-plz.toml`, and give the `release` job `environment: crates-io` and `id-token: write`.
The `release` job publishes through crates.io trusted publishing (`lmarkmann/dataseek`, workflow `release-plz.yml`, environment `crates-io`); no registry token is stored.

## Publishing to PyPI

`uvx dataseek` runs a wheel holding both binaries, built by maturin with the version from `Cargo.toml`. `release.yml` builds the wheels on each GitHub release and uploads them with `uv publish` through trusted publishing ([ADR 0017](../adr/0017-release-builds-on-a-platform-matrix.md)). The same jobs attach `dataseek-<target>.tar.gz` (`.zip` on Windows) with a `.sha256` to the release, which `cargo binstall dataseek` downloads.
`uvx dataseek` runs a wheel holding both binaries, built by maturin with the version from `Cargo.toml`. `release.yml` builds the wheels on each GitHub release and uploads them with `uv publish` through trusted publishing ([ADR 0017](../adr/0017-release-builds-on-a-platform-matrix.md)). The same jobs attach `dataseek-<target>.tar.gz` (`.zip` on Windows) with a `.sha256` to the release, which `cargo binstall dataseek` downloads, and its `homebrew` job rewrites `Formula/dataseek.rb` in [lmarkmann/homebrew-tap](https://github.com/lmarkmann/homebrew-tap) from them with `scripts/homebrew-formula.sh`, through a release App token scoped to the tap.

Before the first release, add a pending publisher at <https://pypi.org/manage/account/publishing/>: project `dataseek`, `lmarkmann/dataseek`, workflow `release.yml`, environment `pypi`.

Expand Down
60 changes: 60 additions & 0 deletions scripts/homebrew-formula.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/sh
# Prints the Homebrew formula for one release, from the .sha256 files the
# release workflow attaches next to each archive:
#
# scripts/homebrew-formula.sh v0.8.0 <dir holding the .tar.gz.sha256 files>
#
# The release workflow writes the output to Formula/dataseek.rb in
# lmarkmann/homebrew-tap (docs/reference/release.md).
set -eu

tag=$1
sums=$2
releases="https://github.com/lmarkmann/dataseek/releases/download/$tag"

sha() {
cut -d' ' -f1 "$sums/dataseek-$1.tar.gz.sha256"
}

cat <<EOF
class Dataseek < Formula
desc "Search for datasets from the terminal"
homepage "https://github.com/lmarkmann/dataseek"
version "${tag#v}"
license any_of: ["MIT", "Apache-2.0"]

on_macos do
on_arm do
url "$releases/dataseek-aarch64-apple-darwin.tar.gz"
sha256 "$(sha aarch64-apple-darwin)"
end
on_intel do
url "$releases/dataseek-x86_64-apple-darwin.tar.gz"
sha256 "$(sha x86_64-apple-darwin)"
end
end

on_linux do
on_arm do
url "$releases/dataseek-aarch64-unknown-linux-gnu.tar.gz"
sha256 "$(sha aarch64-unknown-linux-gnu)"
end
on_intel do
url "$releases/dataseek-x86_64-unknown-linux-gnu.tar.gz"
sha256 "$(sha x86_64-unknown-linux-gnu)"
end
end

def install
bin.install "dataseek", "dsk"
generate_completions_from_executable(bin/"dataseek", "completion")
generate_completions_from_executable(bin/"dsk", "completion")
(man1/"dataseek.1").write Utils.safe_popen_read(bin/"dataseek", "man")
man1.install_symlink "dataseek.1" => "dsk.1"
end

test do
assert_match version.to_s, shell_output("#{bin}/dsk --version")
end
end
EOF
Loading