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
86 changes: 70 additions & 16 deletions .github/workflows/diffr-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Diffr Release
on:
push:
tags:
- "diffr-*"
- "diffr/[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:

permissions:
Expand Down Expand Up @@ -49,21 +49,15 @@ jobs:
RELEASE_TAG: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
run: |
version=$(cargo metadata --no-deps --format-version 1 | "$PYTHON" -c 'import json, sys; print(next(p["version"] for p in json.load(sys.stdin)["packages"] if p["name"] == "diffr-cli"), end="")')
if [ -n "$RELEASE_TAG" ] && [ "$RELEASE_TAG" != "diffr-$version" ]; then
if [ -n "$RELEASE_TAG" ] && [ "$RELEASE_TAG" != "diffr/$version" ]; then
echo "Tag $RELEASE_TAG does not match Cargo version $version" >&2
exit 1
fi
echo "VERSION=$version" >> "$GITHUB_ENV"
cargo xtask install --root "$RUNNER_TEMP/install"
"$PYTHON" scripts/release.py pack --version "$version" --target "$TARGET" --install "$RUNNER_TEMP/install" --output dist
- name: Verify extracted archives without Bun or checkout assets
- name: Verify CLI archive without Bun or checkout assets
run: |
# The TUI smoke test drives a Unix PTY.
if [ "$RUNNER_OS" != Windows ]; then
mkdir -p "$RUNNER_TEMP/extracted/bin"
tar -xzf "dist/diffr-$VERSION-$TARGET.tar.gz" -C "$RUNNER_TEMP/extracted/bin"
"$PYTHON" xtask/tests/smoke_install.py "$RUNNER_TEMP/extracted"
fi
"$PYTHON" scripts/smoke_cli_archive.py "dist/diffr-cli-$VERSION-$TARGET.tar.gz" "$VERSION"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
Expand Down Expand Up @@ -140,7 +134,6 @@ jobs:
PYTHON
brew upgrade devdotfast/tap/diffr
brew test devdotfast/tap/diffr
python3 xtask/tests/smoke_install.py "$(brew --prefix devdotfast/tap/diffr)"
brew uninstall devdotfast/tap/diffr

packaging:
Expand All @@ -156,9 +149,59 @@ jobs:
HOMEBREW: ${{ needs.homebrew.result }}
run: test "$BUILD" = success && test "$PREPARE" = success && test "$HOMEBREW" = success

publish:
approve:
name: Approve diffr release
if: github.event_name == 'push' && github.ref_type == 'tag'
needs: packaging
environment: review-release-approval
runs-on: ubuntu-latest
permissions: {}
steps:
- run: echo "Diffr release approved"

crates:
name: Verify and publish Cargo packages
needs: [packaging, approve]
# Manual runs validate packages without entering the publishing approval gate.
if: >-
always() && needs.packaging.result == 'success' &&
(needs.approve.result == 'success' ||
(github.event_name == 'workflow_dispatch' && needs.approve.result == 'skipped'))
runs-on: ubuntu-22.04
timeout-minutes: 45
defaults:
run:
shell: bash
working-directory: diffr
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@1.99.0
- name: Verify crates without publishing
run: cargo publish --locked --dry-run -p diffr-grammars -p diffr-core -p diffr-cli
- name: Publish crates in dependency order
if: github.event_name == 'push' && github.ref_type == 'tag'
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
RELEASE_TAG: ${{ github.ref_name }}
run: |
test -n "$CARGO_REGISTRY_TOKEN" || { echo 'CARGO_REGISTRY_TOKEN secret is missing.' >&2; exit 1; }
version="${RELEASE_TAG#diffr/}"
for crate in diffr-grammars diffr-core diffr-cli; do
# A rerun can resume after one of the dependencies was published.
status=$(curl --silent --show-error --retry 3 --max-time 60 \
--user-agent 'diffr-release (https://github.com/devdotfast/whiteboard)' \
--output /dev/null --write-out '%{http_code}' \
"https://crates.io/api/v1/crates/$crate/$version")
case "$status" in
200) echo "$crate@$version is already published" ;;
404) cargo publish --locked -p "$crate" ;;
*) echo "Could not check $crate@$version: HTTP $status" >&2; exit 1 ;;
esac
done

publish:
if: github.event_name == 'push' && github.ref_type == 'tag'
needs: [packaging, crates]
permissions:
contents: write
runs-on: ubuntu-22.04
Expand All @@ -177,7 +220,10 @@ jobs:
gh release edit "$RELEASE_TAG" --draft=false --latest=false

npm:
needs: publish
needs: [packaging, crates, publish]
if: >-
always() && needs.packaging.result == 'success' && needs.crates.result == 'success' &&
(needs.publish.result == 'success' || github.event_name == 'workflow_dispatch')
defaults:
run:
working-directory: diffr
Expand All @@ -199,25 +245,33 @@ jobs:
with:
name: release
path: diffr/dist
- name: Stage and verify npm packages
run: |
VERSION=$(node -p "require('./diffr-ts/package.json').version")
python3 scripts/release.py npm --version "$VERSION" --dist dist --output npm
for package in npm/*/ diffr-ts/; do
npm pack "./$package" --dry-run
done
- name: Publish platform packages, then @dev.fast/diffr
if: github.event_name == 'push' && github.ref_type == 'tag'
env:
VERSION: ${{ github.ref_name }}
# Unset once npm trusted publishing is configured for every package.
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
VERSION="${VERSION#diffr-}"
python3 scripts/release.py npm --version "$VERSION" --dist dist --output npm
VERSION="${VERSION#diffr/}"
for package in npm/*/ diffr-ts/; do
name=$(node -p "require('./${package}package.json').name")
if npm view "$name@$VERSION" version >/dev/null 2>&1; then
echo "$name@$VERSION is already published"
else
npm publish "$package" --provenance --access public
npm publish "./$package" --provenance --access public
fi
done

npm-smoke:
needs: npm
if: github.event_name == 'push' && github.ref_type == 'tag'
strategy:
fail-fast: false
matrix:
Expand All @@ -234,7 +288,7 @@ jobs:
env:
VERSION: ${{ github.ref_name }}
run: |
VERSION="${VERSION#diffr-}"
VERSION="${VERSION#diffr/}"
cd "$RUNNER_TEMP"
npm init -y >/dev/null
for _ in 1 2 3 4 5 6; do
Expand Down
6 changes: 3 additions & 3 deletions diffr/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions diffr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "Structural diffs with a streaming API and interactive terminal fr
repository = "https://github.com/devdotfast/whiteboard"
homepage = "https://github.com/devdotfast/whiteboard/tree/main/diffr"
license = "MIT"
version = "0.1.16"
version = "0.1.17"
authors = ["dev.fast"]
keywords = ["diff", "syntax"]
categories = ["development-tools", "command-line-utilities", "parser-implementations"]
Expand All @@ -26,7 +26,7 @@ include = [
]

[dependencies]
diffr-core = { path = "crates/diffr-core", version = "0.1.16" }
diffr-core = { path = "crates/diffr-core", version = "0.1.17" }
gix = { version = "0.88", default-features = false, features = ["parallel", "revision", "status", "blob-diff", "attributes", "sha1"] }
clap = { version = "4.0.0", features = ["cargo", "derive", "env", "wrap_help", "string"] }
typed-arena = "2.0.2"
Expand Down Expand Up @@ -80,8 +80,8 @@ name = "diffr"
path = "src/main.rs"

[package.metadata.binstall]
# Tags have no "v" prefix; binaries sit at the archive root.
pkg-url = "{ repo }/releases/download/{ version }/diffr-{ version }-{ target }{ archive-suffix }"
# Encode the slash in diffr/X.Y.Z tags; binaries sit at the archive root.
pkg-url = "{ repo }/releases/download/diffr%2F{ version }/diffr-{ version }-{ target }{ archive-suffix }"
pkg-fmt = "tgz"
bin-dir = "{ bin }{ binary-ext }"

Expand Down
4 changes: 2 additions & 2 deletions diffr/crates/diffr-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "The diffr engine: parsing, structural diffing, configuration and
repository = "https://github.com/devdotfast/whiteboard"
homepage = "https://github.com/devdotfast/whiteboard/tree/main/diffr"
license = "MIT"
version = "0.1.16"
version = "0.1.17"
authors = ["dev.fast"]
keywords = ["diff", "syntax"]
categories = ["development-tools", "parser-implementations"]
Expand All @@ -29,7 +29,7 @@ include = [
]

[dependencies]
diffr-grammars = { path = "../diffr-grammars", version = "0.1.16" }
diffr-grammars = { path = "../diffr-grammars", version = "0.1.17" }
regex = "1.10.4"
typed-arena = "2.0.2"
rustc-hash = "2.0.0"
Expand Down
2 changes: 1 addition & 1 deletion diffr/crates/diffr-grammars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "Tree-sitter grammars for diffr, with their largest parse tables s
repository = "https://github.com/devdotfast/whiteboard"
homepage = "https://github.com/devdotfast/whiteboard/tree/main/diffr"
license = "MIT"
version = "0.1.16"
version = "0.1.17"
authors = ["dev.fast"]
edition = "2021"
rust-version = "1.99.0"
Expand Down
2 changes: 1 addition & 1 deletion diffr/diffr-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dev.fast/diffr",
"version": "0.1.16",
"version": "0.1.17",
"description": "diffr's NDJSON wire contract, validators, and the diffr binary for this platform",
"repository": {
"type": "git",
Expand Down
19 changes: 0 additions & 19 deletions diffr/diffr-ts/src/version.test.ts

This file was deleted.

9 changes: 5 additions & 4 deletions diffr/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ default:
release:
#!/bin/bash

set -ex
set -euo pipefail

VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages | .[] | select(.name == "difftastic") | .version')
git tag $VERSION
git push origin $VERSION
test -z "$(git status --porcelain)" || { echo "Commit changes before releasing." >&2; exit 1; }
VERSION=$(cargo metadata --locked --format-version=1 --no-deps | jq -er '.packages | .[] | select(.name == "diffr-cli") | .version')
git tag "diffr/$VERSION"
git push origin "refs/tags/diffr/$VERSION"

# Run perf stat on baseline test files and save results.
perf:
Expand Down
2 changes: 1 addition & 1 deletion diffr/scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def formula(version, output):
(output / "SHA256SUMS").write_text("".join(
f"{checksum} {name}\n" for name, checksum in checksums.items()
))
url = f"https://github.com/devdotfast/whiteboard/releases/download/diffr-{version}/diffr-{version}"
url = f"https://github.com/devdotfast/whiteboard/releases/download/diffr%2F{version}/diffr-{version}"
(output / "diffr.rb").write_text(f'''class Diffr < Formula
desc "Structural diffs with an interactive terminal frontend"
homepage "https://github.com/devdotfast/whiteboard/tree/main/diffr"
Expand Down
3 changes: 0 additions & 3 deletions diffr/scripts/smoke_cli_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ def check(archive_path, version):
with tempfile.TemporaryDirectory(prefix="diffr-cli-smoke-") as directory:
root = Path(directory)
with tarfile.open(archive_path) as archive:
assert set(archive.getnames()) == {
f"diffr{exe}", "LICENSE", "NOTICE", "tui/LICENSE", "tui/themes/LICENSE",
}
archive.extractall(root, filter="data")
env = {"PATH": "", "HOME": str(root), "XDG_CONFIG_HOME": str(root / "config")}
if os.name == "nt":
Expand Down
86 changes: 0 additions & 86 deletions diffr/xtask/tests/smoke_install.py

This file was deleted.

Loading