Skip to content

Commit 06c300e

Browse files
Merge pull request #959 from phip1611/publishing
doc: update PUBLISHING.md
2 parents c87772f + 85ae817 commit 06c300e

File tree

1 file changed

+61
-39
lines changed

1 file changed

+61
-39
lines changed

Diff for: PUBLISHING.md

+61-39
Original file line numberDiff line numberDiff line change
@@ -5,65 +5,87 @@ repository to [crates.io](https://crates.io/).
55

66
**It is mostly intended for maintainers of the uefi-rs project.**
77

8-
## Overview
8+
## Goal: What We Want
9+
- We want precise entries in the [`CHANGELOG.md`] for every release that
10+
**follow our existing format**. Changes are supposed to be added before a
11+
release is performed.
12+
- We want git tags like `uefi-raw-v0.4.0` or `uefi-v0.25.0` for every release.
13+
- We want our crate dependencies published in the right order (if necessary):
14+
- `uefi-services` depends on `uefi`
15+
- `uefi` depends on `uefi-macros` and `uefi-raw`
16+
17+
## How: Ways to Publish
18+
19+
There are two major ways for releasing/publishing.
20+
21+
### GitHub CI Workflow (**recommended**)
922

1023
1. Create a branch that updates the versions of all packages you want to
1124
release. This branch should include all related changes such as updating the
1225
versions in dependent crates and updating the changelog.
1326
2. Create a PR of that branch. The subject of the PR must start with `release:`,
14-
the rest of the message is arbitrary.
15-
3. Once the PR is approved and merged, a Github Actions workflow will take care
27+
the rest of the message is arbitrary. [Example](https://github.com/rust-osdev/uefi-rs/pull/1001)
28+
3. Once the PR is approved and merged, a GitHub Actions workflow will take care
1629
of creating git tags and publishing to crates.io.
1730

18-
## Details of the release pull request
31+
#### Crates.io secret token
1932

20-
For ensuring compatibility within the crates ecosystem,
21-
Cargo [recommends][cargo-semver] maintainers to follow the [semantic versioning][semver] guidelines.
22-
23-
This means that before publishing the changes, we need to decide
24-
which crates were modified and how should their version numbers be incremented.
33+
The `release.yml` workflow expects a repository secret named
34+
`CARGO_REGISTRY_TOKEN`. This is set in the [repository settings][secret]. The
35+
value must be a crates.io [API token]. The scope of the token should be
36+
restricted to `publish-update`.
2537

26-
Incrementing the version number of a crate is as simple as editing
27-
the corresponding `Cargo.toml` file and updating the `version = ...` line,
28-
then committing the change.
38+
[secret]: https://github.com/rust-osdev/uefi-rs/settings/secrets/actions
39+
[API token]: https://crates.io/settings/tokens
2940

30-
### Crate dependencies
41+
### Manual
3142

32-
The dependency graph of the published crates in this repo is:
43+
To simplify things, you can use the [`cargo-release`](https://crates.io/crates/cargo-release)
44+
utility, which automatically bumps crate versions in `Cargo.toml`, creates
45+
git tags as we want them, and creates a release commit. If you prefer a more
46+
manual process, create the tags manually so that it matches the existing git tag
47+
scheme.
3348

34-
- `uefi-services` depends on `uefi`
35-
- `uefi` depends on `uefi-macros` and `uefi-raw`
49+
*The following guide assumes that you are using `cargo-release`.*
3650

37-
### Updating the dependent crates
51+
1. Make sure that the `main` branch passes CI. Also verify that locally by
52+
running `cargo xtask test && cargo xtask run`.
53+
2. Create an issue similar to <https://github.com/rust-osdev/uefi-rs/issues/955>
54+
for noting what you want to release.
55+
3. Make sure that the [`CHANGELOG.md`] is up-to-date and matches the format.
56+
4. Perform a dry run: `cargo release -p uefi-raw 0.4.0`
57+
Hint: `cargo-release` will automatically increase the version number for you,
58+
if it is still lower.
59+
5. Release: `cargo release -p uefi-raw 0.4.0 --execute`
60+
6. Update the lock file: `cargo xtask build`
61+
7. If necessary: Bump the dependency in the dependent crates, commit this, and
62+
if applicable release them. Go back to `4.` for that.
63+
8. Search the repository for outdated versions, such as in
64+
`template/Cargo.toml`. Run `cargo xtask build` again and update + commit the
65+
lock file, if there are changes.
66+
9. Submit a PR. Make sure to push all tags using `git push --tags`.
67+
10. Update this document, in case something is inconvenient or unclear.
3868

39-
Remember that if a new major version of a crate gets released, when bumping the version
40-
of it's dependents you will have to also change the dependency line for it.
69+
## General Guidelines and Tips
4170

42-
For example, if `uefi-macros` gets bumped from `0.5.0` to `0.6.0`,
43-
you will also have to update the corresponding `Cargo.toml` of `uefi` to be:
71+
### Publishing Principals for crates.io
4472

45-
```toml
46-
uefi-macros = "0.6.0"
47-
```
73+
Make sure to be familiar with the [general publishing principals][cargo-publishing-reference]
74+
for [crates.io](https://crates.io).
4875

49-
The dependencies in `template/Cargo.toml` should also be updated to the new version.
76+
[cargo-publishing-reference]: https://doc.rust-lang.org/cargo/reference/publishing.html
5077

51-
[cargo-semver]: https://doc.rust-lang.org/cargo/reference/semver.html
52-
[semver]: https://semver.org/
78+
### Details of the release pull request
5379

54-
### Updating the changelog
80+
For ensuring compatibility within the crates ecosystem,
81+
Cargo [recommends][cargo-semver] maintainers to follow the [semantic versioning][semver] guidelines.
5582

56-
Update the [`CHANGELOG.md`](CHANGELOG.md) file in order to move all the
57-
unpublished changes to their respective version, and prepare it for tracking
58-
further changes. The date of the release should be included next to the section
59-
title as done for the other releases.
83+
This means that before publishing the changes, we need to decide
84+
which crates were modified and how should their version numbers be incremented.
6085

61-
## Crates.io secret token
86+
***Note** that `0.x` -> `0.(x+1)` is allowed to be a breaking change by Cargo.*
6287

63-
The release.yml workflow expects a repository secret named
64-
`CARGO_REGISTRY_TOKEN`. This is set in the [repository settings][secret]. The
65-
value must be a crates.io [API token]. The scope of the token should be
66-
restricted to `publish-update`.
88+
[cargo-semver]: https://doc.rust-lang.org/cargo/reference/semver.html
89+
[semver]: https://semver.org/
6790

68-
[secret]: https://github.com/rust-osdev/uefi-rs/settings/secrets/actions
69-
[API token]: https://crates.io/settings/tokens
91+
[`CHANGELOG.md`]: CHANGELOG.md

0 commit comments

Comments
 (0)