Skip to content

Conversation

@lirenjie95
Copy link
Collaborator

@lirenjie95 lirenjie95 commented Jul 27, 2025

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 in Cargo.toml files and synchronize dependencies across the workspace. The script supports both Go-style (v1.2.3) and Rust-style (1.2.3) version formats.

@lirenjie95 lirenjie95 marked this pull request as draft July 27, 2025 02:13
@lirenjie95 lirenjie95 requested a review from Copilot July 27, 2025 02:14

This comment was marked as outdated.

@lirenjie95 lirenjie95 requested a review from Copilot July 27, 2025 02:25

This comment was marked as outdated.

lirenjie95 added a commit that referenced this pull request Jul 27, 2025
- 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)
@lirenjie95 lirenjie95 requested a review from Copilot July 27, 2025 02:30

This comment was marked as outdated.

@lirenjie95 lirenjie95 requested a review from Copilot July 27, 2025 02:38

This comment was marked as outdated.

…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
@lirenjie95 lirenjie95 marked this pull request as ready for review July 27, 2025 03:42
@lirenjie95 lirenjie95 added the github_actions Pull requests that update GitHub Actions code label Jul 27, 2025
Copy link

Copilot AI left a 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"
Copy link

Copilot AI Jul 27, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +214 to +226
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
Copy link

Copilot AI Jul 27, 2025

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

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, '-')
Copy link

Copilot AI Jul 27, 2025

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').

Suggested change
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-')
if: startsWith(github.ref, 'refs/tags/v') && !matches(github.ref, '.*-(alpha|beta|rc)\\d*$')

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

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'
Copy link
Collaborator Author

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 }}
Copy link
Collaborator Author

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 }}
Copy link
Collaborator Author

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, '-')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tag releases

2 participants