Skip to content

Add integration tests for various modules in Rust #35

Add integration tests for various modules in Rust

Add integration tests for various modules in Rust #35

name: Semantic Release
on:
push:
branches:
- main
# Add permissions to allow pushing to the repository and creating tags
permissions:
contents: write # Required for creating tags and releases
pull-requests: write
issues: write
id-token: write # Required for some authentication scenarios
jobs:
release:
runs-on: ubuntu-latest
concurrency: release
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install python-semantic-release
- name: Semantic Release
id: semantic
run: |
# Print the current version
echo "Current version in pyproject.toml:"
grep -m 1 "version" pyproject.toml
# Run semantic-release with verbose output
echo "Running semantic-release version --print..."
VERSION=$(semantic-release version --print)
echo "Next version would be: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
# Run semantic-release publish with verbose output
echo "Running semantic-release publish..."
semantic-release --verbose publish
# Verify the tag was created
echo "Checking for tag v$VERSION..."
git tag -l "v$VERSION"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Tag Manually if Needed
if: steps.semantic.outputs.VERSION != '0.0.0' && steps.semantic.outputs.VERSION != ''
run: |
# Configure git
git config --local user.email "github-actions@github.com"
git config --local user.name "GitHub Actions"
# Check if tag exists
VERSION="${{ steps.semantic.outputs.VERSION }}"
if ! git tag -l "v$VERSION" | grep -q "v$VERSION"; then
echo "Tag v$VERSION does not exist, creating it..."
# Get the current commit hash
COMMIT_HASH=$(git rev-parse HEAD)
# Create and push tag
git tag -a "v$VERSION" -m "Release v$VERSION" $COMMIT_HASH
git push origin "v$VERSION"
echo "Tag v$VERSION created and pushed"
else
echo "Tag v$VERSION already exists"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger Publish Workflow
if: steps.semantic.outputs.VERSION != '0.0.0' && steps.semantic.outputs.VERSION != ''
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
event-type: publish-pypi
client-payload: '{"version": "${{ steps.semantic.outputs.VERSION }}"}'
- name: Verify version consistency
if: steps.semantic.outputs.VERSION != '0.0.0' && steps.semantic.outputs.VERSION != ''
run: |
PYPROJECT_VERSION=$(grep -m 1 "version" pyproject.toml | sed -E 's/.*"([0-9]+\.[0-9]+\.[0-9]+)".*/\1/')
CARGO_VERSION=$(grep -m 1 "version" Cargo.toml | sed -E 's/.*"([0-9]+\.[0-9]+\.[0-9]+)".*/\1/')
INIT_VERSION=$(grep -m 1 "__version__" python/pyroid/__init__.py | sed -E 's/.*"([0-9]+\.[0-9]+\.[0-9]+)".*/\1/')
SETUP_VERSION=$(grep -m 1 "version" setup.py | sed -E 's/.*"([0-9]+\.[0-9]+\.[0-9]+)".*/\1/')
echo "Versions found:"
echo "pyproject.toml: $PYPROJECT_VERSION"
echo "Cargo.toml: $CARGO_VERSION"
echo "python/pyroid/__init__.py: $INIT_VERSION"
echo "setup.py: $SETUP_VERSION"
if [ "$PYPROJECT_VERSION" != "$CARGO_VERSION" ] || [ "$PYPROJECT_VERSION" != "$INIT_VERSION" ] || [ "$PYPROJECT_VERSION" != "$SETUP_VERSION" ]; then
echo "ERROR: Version numbers are inconsistent across files!"
# exit 1
fi
echo "All version numbers are consistent: $PYPROJECT_VERSION"
- name: Summary
run: |
echo "## Semantic Release Summary" >> $GITHUB_STEP_SUMMARY
echo "- Version: ${{ steps.semantic.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "- Tag: v${{ steps.semantic.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "- Publish Workflow Triggered: ${{ steps.semantic.outputs.VERSION != '0.0.0' && steps.semantic.outputs.VERSION != '' }}" >> $GITHUB_STEP_SUMMARY