Skip to content

Commit

Permalink
Check version format before publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrGlad committed Jan 19, 2025
1 parent 2c801ba commit ae7acb4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ jobs:
- name: Publish and tag
run: |
echo "Current git commit is $(git rev-list -n 1 HEAD)."
VERSION="$(yq '.package.version' Cargo.toml)"
echo "Project version from Cargo.toml is $VERSION"
VERSION_TAG="v$VERSION"
if ! (echo "$VERSION" | grep --quiet "^[0-9]\{1,2\}\.[0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\?$"); then
echo "The version format does not look like a release version, not publishing the crate."
exit 1
fi
VERSION_TAG="v$VERSION"
if git tag | grep --quiet "^$VERSION_TAG$"; then
echo "Tag $VERSION_TAG already exists at $(git rev-list -n 1 $VERSION_TAG), not publishing the crate."
exit 1
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ For example spelling/grammar or fixing up a PR by someone else.
## Release Procedure

The project is built automatically by a GitHub action when a new revision is pushed to the master branch.
The crate is published by triggering `.github/workflows/manual.yml` GitHub action.
After the crate is successfully published a new git tag is created in the repository.
The crate is published by triggering `.github/workflows/publish.yml` GitHub action.
After the crate is successfully published a new version's git tag is created in the repository.

So to publish a new version
1. Update `project.version` field in `Cargo.toml`.
2. Push the changes to the `master` branch.
3. Wait until GitHub build job completes successfully.
4. [On the Actions page](https://github.com/RustAudio/rodio/actions) start `.github/workflows/manual.yml`.
4. [On the Actions page](https://github.com/RustAudio/rodio/actions) start `.github/workflows/publish.yml`.

0 comments on commit ae7acb4

Please sign in to comment.