Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(infra): introduce automated publishing #67

Merged
merged 16 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from 9 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
21 changes: 21 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,24 @@ jobs:
- uses: actions/checkout@v2
- name: Run cargo fmt
run: cargo fmt --all -- --check

publish:
runs-on: ubuntu-20.04
needs: [tests, clippy, cargo-fmt]
if: github.ref == 'refs/heads/master'

steps:
- uses: actions/checkout@v2
- name: Setup
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
cargo install --git https://github.com/miraclx/cargo-workspaces --branch grouping-versioning-and-exclusion cargo-workspaces
miraclx marked this conversation as resolved.
Show resolved Hide resolved
- name: Publish to crates.io and tag the commit responsible
run: |
cargo ws publish --all --yes --exact \
--skip-published --no-git-commit --allow-dirty \
--tag-existing --tag-prefix 'v' \
--tag-msg $'crates.io snapshot\n---%{\n- %n - https://crates.io/crates/%n/%v}' \
--no-individual-tags --no-git-push
- name: Push tags to GitHub (if any)
run: git push --tags
9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ members = [
"borsh-derive",
"borsh-derive-internal",
"borsh-schema-derive-internal",
"fuzz/fuzz-run",
"benchmarks",
]
exclude = [
"fuzz",
]

[workspace.metadata.workspaces]
# shared version of all public crates in the workspace
version = "0.9.2"
exclude = [ "fuzz/*", "benchmarks" ]
33 changes: 8 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,38 +78,21 @@ struct A {

## Releasing

Before you release, make sure CHANGELOG.md is up to date.
The versions of all public crates in this repository are collectively managed by a single version in the [workspace manifest](https://github.com/near/borsh-rs/blob/master/Cargo.toml).

Use [`cargo-workspaces`](https://github.com/pksunkara/cargo-workspaces) to save time.
So, to publish a new version of all the crates, you can do so by simply bumping that to the next "patch" version and submit a PR.

### Bump Versions
We have CI Infrastructure put in place to automate the process of publishing all crates once a version change has merged into master.

```sh
cargo workspaces version --force 'borsh*' --exact --no-individual-tags patch
```

This will bump all the versions to the next "patch" release (see `cargo workspaces version --help`
for more options), create a new commit, push `v0.x.x` tag, push to the master.

### Publish

To publish on crates.io the version that is currently in git:

```sh
cargo workspaces publish --from-git --skip-published
```

Alternatively, you may want to combine the version bumping with publishing:

```sh
cargo workspaces publish --force 'borsh*' --exact --no-individual-tags patch
```
However, before you release, make sure the [CHANGELOG](CHANGELOG.md) is up to date.

### Release on GitHub

After the checks pass and the release to crates.io has succeeded, a new tag will be created on GitHub to match the new version. You can use this tag to manually create a new release on GitHub.

1. Navigate to the [New Release](https://github.com/near/borsh-rs/releases/new) page
2. Enter the tag name, e.g. `v0.8.0`
3. Write down the release log (basically, copy-paste from the CHANGELOG)
2. Select the tag name, e.g. `v0.8.0`
3. Write down the release log (basically, copy-paste from the [CHANGELOG](CHANGELOG.md))
4. Publish the release
miraclx marked this conversation as resolved.
Show resolved Hide resolved

## License
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[package]
name = "benchmarks"
version = "0.1.0"
version = "0.0.0"
authors = ["Near Inc <hello@nearprotocol.com>"]
edition = "2018"
publish = false

# This is somehow needed for command line arguments to work: https://github.com/bheisler/criterion.rs/issues/193#issuecomment-415740713
[lib]
Expand Down
2 changes: 1 addition & 1 deletion borsh-derive-internal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "borsh-derive-internal"
version = "0.9.2"
version = "0.0.0"
authors = ["Near Inc <hello@nearprotocol.com>"]
edition = "2018"
license = "Apache-2.0"
Expand Down
6 changes: 3 additions & 3 deletions borsh-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "borsh-derive"
version = "0.9.2"
version = "0.0.0"
authors = ["Near Inc <hello@nearprotocol.com>"]
edition = "2018"
license = "Apache-2.0"
Expand All @@ -16,8 +16,8 @@ Binary Object Representation Serializer for Hashing
proc-macro = true

[dependencies]
borsh-derive-internal = { path = "../borsh-derive-internal", version="=0.9.2"}
borsh-schema-derive-internal = { path = "../borsh-schema-derive-internal", version="=0.9.2"}
borsh-derive-internal = { path = "../borsh-derive-internal" }
borsh-schema-derive-internal = { path = "../borsh-schema-derive-internal" }
syn = {version = "1", features = ["full", "fold"] }
proc-macro-crate = "0.1.5"
proc-macro2 = "1"
2 changes: 1 addition & 1 deletion borsh-schema-derive-internal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "borsh-schema-derive-internal"
version = "0.9.2"
version = "0.0.0"
authors = ["Near Inc <hello@nearprotocol.com>"]
edition = "2018"
license = "Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions borsh/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "borsh"
version = "0.9.2"
version = "0.0.0"
authors = ["Near Inc <hello@near.org>"]
edition = "2018"
license = "MIT OR Apache-2.0"
Expand All @@ -21,7 +21,7 @@ name = "generate_schema_schema"
path = "src/generate_schema_schema.rs"

[dependencies]
borsh-derive = { path = "../borsh-derive", version = "=0.9.2" }
borsh-derive = { path = "../borsh-derive" }
hashbrown = "0.11"

[features]
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz-run/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "borsh-fuzz"
version = "0.1.0"
version = "0.0.0"
authors = ["Near Inc <hello@nearprotocol.com>"]
edition = "2018"
publish = false
Expand Down