-
Notifications
You must be signed in to change notification settings - Fork 31
feat: github release bot #100
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
base: master
Are you sure you want to change the base?
Conversation
6119420 to
a8fd545
Compare
- Improve cargo publish error handling with proper logging - Fix sed path separator consistency in update-version.sh - Add reusable check_and_copy function for file operations - Keep [email protected] (verified as latest version)
d6df2f7 to
02a490c
Compare
02a490c to
e69d6a8
Compare
…ggestion - Use Go-style versioning (v1.2.3) as primary format for Git tags - Automatically convert between Go format (v1.2.3) and Rust format (1.2.3) - Update release workflow to handle both version formats correctly - Enhanced release notes with installation instructions for both ecosystems - Update version script to accept both formats with automatic detection - Improve documentation with unified version management strategy This enables: - Go users: go get github.com/ihciah/[email protected] - Rust users: cargo add [email protected] - Consistent versioning across both ecosystems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces an automated release system for the Rust2Go project, supporting both Go and Rust ecosystems with unified version management using Go-style versioning (v1.2.3) as the primary format.
- Adds GitHub Actions workflow for automated releases triggered by version tags or manual dispatch
- Provides comprehensive documentation for the release process including setup and workflow instructions
- Implements a shell script for updating version numbers across the workspace with support for both Go and Rust version formats
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
.github/workflows/release.yml |
GitHub Actions workflow for automated releases with multi-platform builds, changelog generation, and publishing to crates.io |
RELEASE.md |
Comprehensive documentation covering release processes, version management, and troubleshooting |
scripts/update-version.sh |
Shell script for updating version numbers in Cargo.toml files and synchronizing workspace dependencies |
Comments suppressed due to low confidence (1)
| # Use simpler approach with variables to improve readability | ||
| pattern_basic="^$dep = { version = \"[^\"]*\", path = \"\\.\\.\\/$dep\" }" | ||
| replacement_basic="$dep = { version = \"$NEW_VERSION\", path = \"\\.\\.\\/$dep\" }" | ||
| sed -i.bak "s/$pattern_basic/$replacement_basic/" "$toml_file" |
Copilot
AI
Jul 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sed patterns use complex regex with escaped characters that could be fragile. The pattern matching and replacement logic could fail if the Cargo.toml format varies slightly from the expected format. Consider using a more robust TOML parsing approach or adding validation to check if the replacement was successful.
| cargo publish -p rust2go-common | ||
| sleep 10 | ||
| cargo publish -p rust2go-convert | ||
| sleep 10 | ||
| cargo publish -p rust2go-macro | ||
| sleep 10 | ||
| cargo publish -p rust2go-mem-ffi | ||
| sleep 10 | ||
| cargo publish -p mem-ring | ||
| sleep 10 | ||
| cargo publish -p rust2go-cli | ||
| sleep 10 | ||
| cargo publish -p rust2go No newline at end of file |
Copilot
AI
Jul 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded sleep intervals (10 seconds) between crate publishes may not be sufficient if crates.io is slow to process. Consider implementing a more robust retry mechanism or checking publication status before proceeding to the next crate.
| cargo publish -p rust2go-common | |
| sleep 10 | |
| cargo publish -p rust2go-convert | |
| sleep 10 | |
| cargo publish -p rust2go-macro | |
| sleep 10 | |
| cargo publish -p rust2go-mem-ffi | |
| sleep 10 | |
| cargo publish -p mem-ring | |
| sleep 10 | |
| cargo publish -p rust2go-cli | |
| sleep 10 | |
| cargo publish -p rust2go | |
| function wait_for_publish() { | |
| local crate=$1 | |
| local attempts=0 | |
| local max_attempts=30 | |
| local delay=10 | |
| while [ $attempts -lt $max_attempts ]; do | |
| if cargo search "$crate" --limit 1 | grep -q "$crate"; then | |
| echo "$crate is published on crates.io" | |
| return 0 | |
| fi | |
| echo "Waiting for $crate to be published..." | |
| sleep $delay | |
| attempts=$((attempts + 1)) | |
| done | |
| echo "Failed to verify publication of $crate after $((attempts * delay)) seconds" | |
| exit 1 | |
| } | |
| cargo publish -p rust2go-common | |
| wait_for_publish rust2go-common | |
| cargo publish -p rust2go-convert | |
| wait_for_publish rust2go-convert | |
| cargo publish -p rust2go-macro | |
| wait_for_publish rust2go-macro | |
| cargo publish -p rust2go-mem-ffi | |
| wait_for_publish rust2go-mem-ffi | |
| cargo publish -p mem-ring | |
| wait_for_publish mem-ring | |
| cargo publish -p rust2go-cli | |
| wait_for_publish rust2go-cli | |
| cargo publish -p rust2go | |
| wait_for_publish rust2go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We prefer reducing defensive programming and letting errors fail fast.
| name: Publish to crates.io | ||
| runs-on: ubuntu-latest | ||
| needs: create-release | ||
| if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') |
Copilot
AI
Jul 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition for publishing to crates.io only checks for the absence of '-' in the tag, but this could incorrectly exclude valid stable versions that happen to contain a dash in the repository name or other parts of the ref. Consider using a more specific regex pattern to match prerelease versions (e.g., checking for patterns like '-alpha', '-beta', '-rc').
| if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') | |
| if: startsWith(github.ref, 'refs/tags/v') && !matches(github.ref, '.*-(alpha|beta|rc)\\d*$') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reasonable.
| - name: Setup Go | ||
| uses: actions/setup-go@v4 | ||
| with: | ||
| go-version: '1.22' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For compatibility, the go version here should be 1.18.
| id: create_release | ||
| uses: softprops/action-gh-release@v1 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GITHUB_TOKEN needs to be configured in repo Secrets. @ihciah
|
|
||
| - name: Publish to crates.io | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CARGO_REGISTRY_TOKEN needs to be configured in repo Secrets. @ihciah
| name: Publish to crates.io | ||
| runs-on: ubuntu-latest | ||
| needs: create-release | ||
| if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reasonable.
Fixes #98
Automated Release Workflow:
.github/workflows/release.yml: Added a GitHub Actions workflow to handle automated releases triggered by version tags or manual dispatch. The workflow includes steps for building multi-platform artifacts, generating changelogs, publishing to crates.io, and uploading release assets.Documentation Updates:
RELEASE.md: Added a comprehensive guide detailing the release process, including setup instructions, versioning conventions, and step-by-step workflows for automated and manual releases.Version Management:
scripts/update-version.sh: Added a script to update version numbers inCargo.tomlfiles and synchronize dependencies across the workspace. The script supports both Go-style (v1.2.3) and Rust-style (1.2.3) version formats.