Skip to content

Commit

Permalink
cargo-dist (#538)
Browse files Browse the repository at this point in the history
* cargo dist

* Testing a draft release.

* Don't automatically make releases non-draft.

* Update release procedure.

* Don't wrap lines in CHANGELOG. The newlines get used in GitHub's Release Notes display.

* Update release format to work with parse-changelog.
  • Loading branch information
torhovland authored Jun 30, 2023
1 parent 331c1b0 commit b4b3aa9
Show file tree
Hide file tree
Showing 4 changed files with 209 additions and 62 deletions.
126 changes: 126 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# CI that:
#
# * checks for a Git Tag that looks like a release
# * creates a Github Release™ and fills in its text
# * builds artifacts with cargo-dist (executable-zips, installers)
# * uploads those artifacts to the Github Release™
#
# Note that the Github Release™ will be created before the artifacts,
# so there will be a few minutes where the release has no artifacts
# and then they will slowly trickle in, possibly failing. To make
# this more pleasant we mark the release as a "draft" until all
# artifacts have been successfully uploaded. This allows you to
# choose what to do with partial successes and avoids spamming
# anyone with notifications before the release is actually ready.
name: Release

permissions:
contents: write

# This task will run whenever you push a git tag that looks like a version
# like "v1", "v1.2.0", "v0.1.0-prerelease01", "my-app-v1.0.0", etc.
# The version will be roughly parsed as ({PACKAGE_NAME}-)?v{VERSION}, where
# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION
# must be a Cargo-style SemVer Version.
#
# If PACKAGE_NAME is specified, then we will create a Github Release™ for that
# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
#
# If PACKAGE_NAME isn't specified, then we will create a Github Release™ for all
# (cargo-dist-able) packages in the workspace with that version (this is mode is
# intended for workspaces with only one dist-able package, or with all dist-able
# packages versioned/released in lockstep).
#
# If you push multiple tags at once, separate instances of this workflow will
# spin up, creating an independent Github Release™ for each one.
#
# If there's a prerelease-style suffix to the version then the Github Release™
# will be marked as a prerelease.
on:
push:
tags:
- '*-?v[0-9]+*'

jobs:
# Create the Github Release™ so the packages have something to be uploaded to
create-release:
runs-on: ubuntu-latest
outputs:
has-releases: ${{ steps.create-release.outputs.has-releases }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Install Rust
run: rustup update 1.67.1 --no-self-update && rustup default 1.67.1
- name: Install cargo-dist
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.sh | sh
- id: create-release
run: |
cargo dist plan --tag=${{ github.ref_name }} --output-format=json > dist-manifest.json
echo "dist plan ran successfully"
cat dist-manifest.json
# Create the Github Release™ based on what cargo-dist thinks it should be
ANNOUNCEMENT_TITLE=$(jq --raw-output ".announcement_title" dist-manifest.json)
IS_PRERELEASE=$(jq --raw-output ".announcement_is_prerelease" dist-manifest.json)
jq --raw-output ".announcement_github_body" dist-manifest.json > new_dist_announcement.md
gh release create ${{ github.ref_name }} --draft --prerelease="$IS_PRERELEASE" --title="$ANNOUNCEMENT_TITLE" --notes-file=new_dist_announcement.md
echo "created announcement!"
# Upload the manifest to the Github Release™
gh release upload ${{ github.ref_name }} dist-manifest.json
echo "uploaded manifest!"
# Disable all the upload-artifacts tasks if we have no actual releases
HAS_RELEASES=$(jq --raw-output ".releases != null" dist-manifest.json)
echo "has-releases=$HAS_RELEASES" >> "$GITHUB_OUTPUT"
# Build and packages all the things
upload-artifacts:
# Let the initial task tell us to not run (currently very blunt)
needs: create-release
if: ${{ needs.create-release.outputs.has-releases == 'true' }}
strategy:
matrix:
# For these target platforms
include:
- os: ubuntu-20.04
dist-args: --artifacts=global
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.sh | sh
- os: macos-11
dist-args: --artifacts=local --target=aarch64-apple-darwin --target=x86_64-apple-darwin
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.sh | sh
- os: ubuntu-20.04
dist-args: --artifacts=local --target=x86_64-unknown-linux-gnu
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.sh | sh
- os: windows-2019
dist-args: --artifacts=local --target=x86_64-pc-windows-msvc
install-dist: irm https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.ps1 | iex

runs-on: ${{ matrix.os }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Install Rust
run: rustup update 1.67.1 --no-self-update && rustup default 1.67.1
- name: Install cargo-dist
run: ${{ matrix.install-dist }}
- name: Run cargo-dist
# This logic is a bit janky because it's trying to be a polyglot between
# powershell and bash since this will run on windows, macos, and linux!
# The two platforms don't agree on how to talk about env vars but they
# do agree on 'cat' and '$()' so we use that to marshal values between commands.
run: |
# Actually do builds and make zips and whatnot
cargo dist build --tag=${{ github.ref_name }} --output-format=json ${{ matrix.dist-args }} > dist-manifest.json
echo "dist ran successfully"
cat dist-manifest.json
# Parse out what we just built and upload it to the Github Release™
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json > uploads.txt
echo "uploading..."
cat uploads.txt
gh release upload ${{ github.ref_name }} $(cat uploads.txt)
echo "uploaded!"
96 changes: 45 additions & 51 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
and [`cargo-dist`'s expected
format](https://opensource.axo.dev/cargo-dist/book/simple-guide.html#release-notes),
and this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0.html).

<!----------------------------------------------------------------------
The "Unreleased" section should be amended as major changes are merged
Expand Down Expand Up @@ -37,45 +40,39 @@ This name should be decided amongst the team before the release.
----------------------------------------------------------------------->

## [Unreleased]
[unreleased]: https://github.com/tweag/topiary/compare/v0.2.3...HEAD
* [#526](https://github.com/tweag/topiary/pull/526) Multi-line comments can be indented properly using the new predicate @multi_line_indent_all.
## Unreleased

[Full list of changes](https://github.com/tweag/topiary/compare/v0.2.3...HEAD)

### Added
* [#538](https://github.com/tweag/topiary/pull/538) Using `cargo-dist` to release Topiary binaries.
* [#528](https://github.com/tweag/topiary/pull/528) Added a sample app and convenience functions for using the built-in queries.
* [#533](https://github.com/tweag/topiary/pull/533) Update tree-sitter-ocaml to 0.20.3
* [#526](https://github.com/tweag/topiary/pull/526) Multi-line comments can be indented properly using the new predicate @multi_line_indent_all.

### Changed
* [#535](https://github.com/tweag/topiary/pull/535) Improved error message when idempotency fails due to invalid output in the first pass.
* [#533](https://github.com/tweag/topiary/pull/533) Update tree-sitter-ocaml to 0.20.3

## [0.2.3] - 2023-06-20
[0.2.2]: https://github.com/tweag/topiary/compare/v0.2.2...v0.2.3
## v0.2.3 - Cyclic Cypress - 2023-06-20

[Full list of changes](https://github.com/tweag/topiary/compare/v0.2.2...v0.2.3)

### Added
* [#513](https://github.com/tweag/topiary/pull/513) Added the `-t, --tolerate-
parsing-errors` flags to Topiary, `tolerate_parsing_errors` to the `Format`
operation of the library, and a "Tolerate parsing errors" checkmark to the
playground. These options make Topiary ignore errors in the parsed file, and
attempt to format it.
* [#506](https://github.com/tweag/topiary/pull/506) Allows the users to
configure Topiary through a user-defined configuration file. More information
can be found in the `README.md`.
* [#513](https://github.com/tweag/topiary/pull/513) Added the `-t, --tolerate-parsing-errors` flags to Topiary, `tolerate_parsing_errors` to the `Format` operation of the library, and a "Tolerate parsing errors" checkmark to the playground. These options make Topiary ignore errors in the parsed file, and attempt to format it.
* [#506](https://github.com/tweag/topiary/pull/506) Allows the users to configure Topiary through a user-defined configuration file. More information can be found in the `README.md`.

### Changed
* [#523](https://github.com/tweag/topiary/pull/523) Skips rebuilding the tree-
sitter `Query` when performing the idempotence check. This improves performance
when not skipping the idempotence check by about `35%` for OCaml formatting.
* [#523](https://github.com/tweag/topiary/pull/523) Skips rebuilding the tree-sitter `Query` when performing the idempotence check. This improves performance when not skipping the idempotence check by about `35%` for OCaml formatting.

### Removed
* [#508](https://github.com/tweag/topiary/pull/508) Simplified language
detection by treating `ocaml` and `ocaml_interface` as two distinct languages.
This ensures we only have one grammar per language. This
removed the `-l ocaml_implementation` flag from Topiary and the
`SupportedLanguage::OcamlImplementation` from the library.
* [#508](https://github.com/tweag/topiary/pull/508) Simplified language detection by treating `ocaml` and `ocaml_interface` as two distinct languages. This ensures we only have one grammar per language. This removed the `-l ocaml_implementation` flag from Topiary and the `SupportedLanguage::OcamlImplementation` from the library.

### Fixed
* [#522](https://github.com/tweag/topiary/pull/522) Reverted the bump to the
OCaml grammar and queries. This bump (for as of yet unknown reasons) had a
catastrophic impact on Topiary's performance.
* [#522](https://github.com/tweag/topiary/pull/522) Reverted the bump to the OCaml grammar and queries. This bump (for as of yet unknown reasons) had a catastrophic impact on Topiary's performance.

## v0.2.2 - Cyclic Cypress - 2023-06-12

## [0.2.2] - 2023-06-12
[0.2.1]: https://github.com/tweag/topiary/compare/v0.2.1...v0.2.2
[Full list of changes](https://github.com/tweag/topiary/compare/v0.2.1...v0.2.2)

### Added
* [#498](https://github.com/tweag/topiary/pull/498) Updated the playground to include a nicer editor.
Expand All @@ -85,27 +82,26 @@ This name should be decided amongst the team before the release.
* [#480](https://github.com/tweag/topiary/pull/480) Shows which languages are marked as experimental in the playground.

### Changed
* [#490](https://github.com/tweag/topiary/pull/490) Bumped the Nickel grammar.
* [#494](https://github.com/tweag/topiary/pull/494) Bumped the OCaml grammar, and fixed for the renamed `infix_operator` named node.
* [#490](https://github.com/tweag/topiary/pull/490) Bumped the Nickel grammar.

### Fixed
* [#493](https://github.com/tweag/topiary/pull/493) Fixed
[#492](https://github.com/tweag/topiary/issues/492) by only trimming newlines in prettyprinting.
* [#491](https://github.com/tweag/topiary/pull/493) Fixed
[#481](https://github.com/tweag/topiary/issues/492), a SIGSEGV in exhaustivity testing.
* [#493](https://github.com/tweag/topiary/pull/493) Fixed [#492](https://github.com/tweag/topiary/issues/492) by only trimming newlines in prettyprinting.
* [#491](https://github.com/tweag/topiary/pull/493) Fixed [#481](https://github.com/tweag/topiary/issues/492), a SIGSEGV in exhaustivity testing.

## [0.2.1] - 2023-05-23
[0.2.1]: https://github.com/tweag/topiary/compare/v0.2.0...v0.2.1
## v0.2.1 - Cyclic Cypress - 2023-05-23

[Full list of changes](https://github.com/tweag/topiary/compare/v0.2.0...v0.2.1)

### Fixed
* Correctly bumped version number in `Cargo.toml`.

## [0.2.0]: Cyclic Cypress - 2023-05-22
[0.2.0]: https://github.com/tweag/topiary/compare/v0.1.0...v0.2.0
## v0.2.0 - Cyclic Cypress - 2023-05-22

[Full list of changes](https://github.com/tweag/topiary/compare/v0.1.0...v0.2.0)

### Added
* Topiary [website](https://topiary.tweag.io), web-based
[playground](https://topiary.tweag.io/playground) and logos.
* Topiary [website](https://topiary.tweag.io), web-based [playground](https://topiary.tweag.io/playground) and logos.
* Full Nickel formatting support.
* Improved OCaml formatting support.
* `@append_antispace` and `@prepend_antispace` formatting capture names.
Expand All @@ -115,10 +111,8 @@ This name should be decided amongst the team before the release.
* Maintain a CHANGELOG and a documented release process.

### Changed
* Move to a build configuration file, rather than a mixture of
hardcoding and parsing query predicates at runtime.
* Conditional predicates, in the query language, to reduce the number of
formatting capture names.
* Move to a build configuration file, rather than a mixture of hardcoding and parsing query predicates at runtime.
* Conditional predicates, in the query language, to reduce the number of formatting capture names.
* Higher fidelity exit codes.
* Idempotency check in terminal-based playground.
* Reduced verbosity of failed integration test output.
Expand All @@ -132,8 +126,9 @@ This name should be decided amongst the team before the release.
* Don't process queries that match below leaf nodes.
* Skip over zero-byte matched nodes.

## [0.1.0]: Benevolent Beech - 2023-03-09
[0.1.0]: https://github.com/tweag/topiary/compare/v0.0.1-prototype...v0.1.0
## v0.1.0 - Benevolent Beech - 2023-03-09

[Full list of changes](https://github.com/tweag/topiary/compare/v0.0.1-prototype...v0.1.0)

This first public release focuses on the Topiary engine and providing
decent OCaml formatting support, with the formatting capture names
Expand Down Expand Up @@ -169,9 +164,8 @@ required to do so.
* Basic formatter authoring tools (terminal-based playground and tree visualisation)
* `pre-commit-hooks.nix` support

## [0.0.1-prototype]: Archetypal Aspen - 2022-06-14
[0.0.1-prototype]: https://github.com/tweag/topiary/releases/tag/v0.0.1-prototype
## v0.0.1-prototype - Archetypal Aspen - 2022-06-14

[Full list of changes](https://github.com/tweag/topiary/compare/03e1fc8...v0.0.1-prototype)

This prototype release was created exclusively to show the validity of
the idea of using Tree-sitter to build a formatter. It includes only a
prototype JSON formatter.
This prototype release was created exclusively to show the validity of the idea of using Tree-sitter to build a formatter. It includes only a prototype JSON formatter.
18 changes: 18 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ exclude = ["samples"]
lto = true
opt-level = 's'

# The profile that 'cargo dist' will build with
[profile.dist]
inherits = "release"
lto = "thin"

# Config for 'cargo dist'
[workspace.metadata.dist]
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
cargo-dist-version = "0.0.7"
# The preferred Rust toolchain to use in CI (rustup toolchain syntax)
rust-toolchain-version = "1.67.1"
# CI backends to support (see 'cargo dist generate-ci')
ci = ["github"]
# The installers to generate for each app
installers = ["shell", "powershell"]
# Target platforms to build apps for (Rust target-triple syntax)
targets = ["x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "aarch64-apple-darwin"]

[workspace.dependencies]
assert_cmd = "2.0"
cfg-if = "1.0.0"
Expand Down
31 changes: 20 additions & 11 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
* Retitle the "Unreleased" section to this release and create a fresh
"Unreleased" section (see comments in the [CHANGELOG] for details).

Do not wrap bullet points in multiple lines. GitHub will use those line
breaks in the Release Notes display.

:bulb: Point releases (i.e., not patch releases) should also be
given a name, taking the form `ADJECTIVE TREE`, incrementing
alphabetically. This name should be decided amongst the team before
Expand All @@ -21,16 +24,21 @@
* Commit and merge (squash, if necessary) on green CI and peer
approval.

* Tag the merged commit with the release version, prefixed with a `v`
(e.g., `v1.0.0`).
* Tag the merged commit with the release version, prefixed with a `v` (e.g.,
`v0.1.0`). The version number must match the one in `Cargo.toml`, otherwise
`cargo dist` will fail during CI.

```bash
git tag "v0.1.0"
git push
git push --tags
```

* [Draft a new release][draft-release] in GitHub.
* Set the tag to that created in the previous step, now on `main`.
* Set the release title to `Topiary v<RELEASE>`, or `Topiary
v<RELEASE>: <NAME>` for point releases.
* Copy-and-paste the [CHANGELOG] contents for this release
into the description.
* Publish.
* Let `cargo dist` create a new [draft release][releases].
* Verify the release.
* Publish the draft release.
* If all went well, consider if we should let [CI publish the draft
automatically][auto-publish].

* Publicise.

Expand Down Expand Up @@ -68,6 +76,7 @@ fetch, overriding the low default. As of writing, there's no way to set
this to "unlimited"; adjust as necessary.

<!-- Links -->
[changelog]: /changelog.md
[changelog]: /CHANGELOG.md
[changelog-refresh]: #generating-the-pr-list-for-the-changelog
[draft-release]: https://github.com/tweag/topiary/releases/new
[releases]: https://github.com/tweag/topiary/releases
[auto-publish]: https://github.com/tweag/topiary/pull/538/commits/230d7bc662a042188c79d586472c4e8632ffd6a9

0 comments on commit b4b3aa9

Please sign in to comment.