4 releases
| 0.5.1 | Jun 27, 2024 |
|---|---|
| 0.5.0 | Feb 9, 2024 |
| 0.4.1 | Jan 21, 2024 |
| 0.4.0 | Jan 21, 2024 |
#29 in #workflow-automation
277 downloads per month
56KB
1K
SLoC
auto-release
This package provides an executable that can be run from Github Actions to release code to crates.io and pushing a git tag.
All code changes needed for a release are made by a developer in a
regular git commit. The commit includes bumping the version in
Cargo.toml, and any updates to Cargo.lock, changelog files, etc. The
commit is reviewed and merged through the normal pull request
process. Once merged, a Github Actions job runs auto-release to
actually push the release.
Releasing this way has a couple advantages over local release flows:
- It greatly reduces the opportunity for mistakes, such as forgetting to sync the local branch or forgetting to push git tags.
- Cargo credentials can be stored securely on Github, no need for a local copy.
Usage
Create a Github Actions workflow, e.g. .github/workflows/release.yaml:
on:
push:
branches:
- main
name: Release
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cargo install auto-release
- run: auto-release -p <package>
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
The auto-release crate has minimal compile-time dependencies, so it
compiles very quickly. It does rely on various programs being available,
all of which are already installed and configured on Github's Ubuntu
runners:
cargocurlghgitjq
Cargo registry token
Generate the cargo registry token in your crates.io Account
Settings. The token scopes must include publish-update. If the crate
has never been published before, publish-new is also required.
To make the token available to the Github Actions workflow:
- Go to your repository's settings
- Click to
Secrets and variablesin the sidebar, then clickActions - Under
Repository secrets, clickNew repository secret.
Options
-p/--packagecan be specified multiple times to release multiple packages. Note that order may be significant if packages depend on each other.--condition bodyadds a condition that the commit message body must start with "release:", otherwise the commit will be ignored.--condition subjectadds a condition that the commit message subject must start with "release:", otherwise the commit will be ignored.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Contributing
See the code of conduct and contributing.md.
Disclaimer
This project is not an official Google project. It is not supported by Google and Google specifically disclaims all warranties as to its quality, merchantability, or fitness for a particular purpose.