Automate Binary Releases for Noname
Automating Binary Releases for Noname by getting the latest version tag of Noname from CHANGELOG.md and building the binary release. Resolves issue #81
Not quite sure of how this is going to work. Maybe a outline of the workflow is helpful :)
@katat
Key points
- The workflow only proceeds with the release process if CHANGELOG.md has been updated.
- The versioning is based on incrementing the patch number of the latest tag.
- The binary is built and uploaded only if a new release is necessary.
-
Trigger: The workflow is triggered by a push to the
mainbranch. -
Steps:
-
Checkout Code:
- Uses the
actions/checkout@v2to check out the latest code from themainbranch.
- Uses the
-
Set Up Rust:
- Uses the
dtolnay/rust-toolchain@stableto set up the Rust environment with the stable toolchain.
- Uses the
-
Check for Changelog Changes:
- Compares the
CHANGELOG.mdfile between the latest tagged commit and the current commit. - If changes are found in
CHANGELOG.md, it sets an outputneeds_releasetotrue.
- Compares the
-
Generate New Version Tag:
- If
needs_releaseistrue, it calculates the next patch version number based on the latest tag. - Sets the new version tag as an output.
- If
-
Build the Project:
- If
needs_releaseistrue, it runscargo build --releaseto compile the Rust project in release mode.
- If
-
Install GitHub CLI:
- Installs the GitHub CLI (
gh) if a release is needed.
- Installs the GitHub CLI (
-
Authenticate GitHub CLI:
- Authenticates the GitHub CLI using a GitHub token from the repository's secrets.
-
Create Release:
- Uses the GitHub CLI to create a new release with the generated version tag if a release is needed.
-
Upload Assets:
- Uploads the built binary (
noname) as an asset to the GitHub release.
- Uploads the built binary (
-
Ok, cool. I got a better idea of this works atm. I think we need to agree on the rule of triggering the release build.
From what @ronantakizawa described above, the rule seems to rely on
- whether the changelog is updated
- simply pick the latest git tag version to build
The potential problem of this approach is it might not be able to correctly pick up the right version corresponding to the changelog. For example,
- When there are multiple versions, but we only documented one of them to release in changelog, which is not necessary the latest version.
- Sometimes, there is a need to simply update some wordings in the changelog, but not necessary meant to build a release for each doc update.
Given the changelog format pattern as the following:
# Changelog
## [Unrelease]
...
## [0.7.0] - yyyy-mm-dd
...
## [0.6.0] - yyyy-mm-dd
....
Maybe the rule can be:
- always parse for the latest version from the pattern
[major.minor.fix]in the changelog - compare it with the latest built version, and only build it if the newly parsed version not yet exists in the releases repository.
This way can ensure it build and release the version corresponding to the update to changelog. cc @mimoo
what's the status here, can we merge this?
Will need to do some tests to check if it aligns with the updated changelog.