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
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release

# uppt (https://github.com/danielroe/uppt) runs releases. Each push to main opens or updates a draft
# release PR from the conventional commits since the last tag, bumping npm/docov/package.json, and
# cargo-pr bumps Cargo.toml on it to match. Merging the PR tags it and dispatches this workflow on
# cargo-pr bumps the rest on it to match. Merging the PR tags it and dispatches this workflow on
# the tag, which builds the binaries, then stages the npm packages (tools/npm-approve.sh approves
# them) and publishes the crate alongside. Both registries use trusted publishing, so there are no
# tokens here. tools/bootstrap-publishing.sh sets that up.
Expand Down Expand Up @@ -63,7 +63,8 @@ jobs:
npm/docov
npm/platforms/*

# uppt/pr only bumps package.json, so this brings Cargo.toml along on the release PR
# uppt/pr only bumps package.json, so this brings Cargo.toml, the pre-commit hook and the
# README's $schema URL along on the release PR
cargo-pr:
needs: pr
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# docov as a pre-commit hook. `language: node` has pre-commit install the npm package, with its
# prebuilt binary, in an environment of its own (and Node too when there isn't one), so it works
# without docov installed and on pre-commit.ci. The version moves with Cargo.toml's (a test checks).
# without docov installed and on pre-commit.ci. The version moves with Cargo.toml's:
# tools/release-pr-cargo.sh bumps both, and a test checks.
- id: docov
name: docov
description: JSDoc coverage for JavaScript and TypeScript
Expand Down
31 changes: 16 additions & 15 deletions tools/release-pr-cargo.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
# Bumps Cargo.toml and Cargo.lock to npm/docov/package.json's version on each open release PR
# (release/v* in this repository) and pushes the commit. uppt/pr only bumps package.json, so
# release.yml runs this after it. A branch already at that version is left alone, and uppt keeps
# the extra commit when it updates the PR.
# Bumps Cargo.toml, Cargo.lock, .pre-commit-hooks.yaml and the README's $schema URL to
# npm/docov/package.json's version on each open release PR (release/v* in this repository) and
# pushes the commit. uppt/pr only bumps package.json, so release.yml runs this after it. A branch
# already at that version is left alone, and uppt keeps the extra commit when it updates the PR.
#
# Needs GH_TOKEN, allowed to push and to read pull requests.
set -euo pipefail
Expand All @@ -19,24 +19,25 @@ for branch in $branches; do
(
cd "$dir"
version=$(jq -r .version npm/docov/package.json)
cargo_version() {
cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version'
}
if [[ $(cargo_version) == "$version" ]]; then
echo "$branch: Cargo.toml is already at $version"
exit
fi
# [package]'s version is the first in the file.
perl -0777 -pi -e "s/^version = \".*?\"/version = \"$version\"/m" Cargo.toml
# The npm package the pre-commit hook installs (tests/cli.rs checks it matches), and the
# README's $schema URL, pinned to the release's tag.
perl -pi -e "s{\"\@docov/cli\@[^\"]*\"}{\"\@docov/cli\@$version\"}" .pre-commit-hooks.yaml
perl -pi -e "s{cutenode/docov/v[^/]+/docov\.schema\.json}{cutenode/docov/v$version/docov.schema.json}" README.md
if git diff --quiet; then
echo "$branch: already at $version"
exit
fi
cargo update --workspace
if [[ $(cargo_version) != "$version" ]]; then
if [[ $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') != "$version" ]]; then
echo "::error::couldn't set Cargo.toml's version to $version on $branch"
exit 1
fi
git -c user.name='github-actions[bot]' -c user.email='41898283+github-actions[bot]@users.noreply.github.com' \
commit -qam "chore(release): bump Cargo.toml to v$version"
git -c user.name='github-actions[bot]' -c user.email='41898282+github-actions[bot]@users.noreply.github.com' \
commit -qam "chore(release): bump Cargo.toml, the pre-commit hook and the README to v$version"
git push -q origin "HEAD:refs/heads/$branch"
echo "$branch: bumped Cargo.toml to $version"
echo "$branch: bumped Cargo.toml, the pre-commit hook and the README to $version"
)
git worktree remove --force "$dir"
done
Loading