Bump MAD-NG release #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow updates the MAD-NG version across the repository | |
| # It updates the version in workflows, test inputs, changelog, and package version | |
| name: Bump MAD-NG release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| new_version: | |
| description: 'New MAD-NG version (e.g., 1.1.7)' | |
| required: true | |
| type: string | |
| major_minor: | |
| description: 'Major.minor version for URL path (e.g., 1.1)' | |
| required: true | |
| type: string | |
| package_version: | |
| description: 'New package version for pymadng (e.g., 0.8.2)' | |
| required: true | |
| type: string | |
| changelog_entry: | |
| description: 'Changelog entry for this update (optional)' | |
| required: false | |
| type: string | |
| default: '' | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| bump-version: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Validate inputs | |
| run: | | |
| # Validate new_version format (semver: x.y.z) | |
| if ! echo "${{ inputs.new_version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then | |
| echo "Error: new_version must be in semver format (e.g., 1.1.7)" | |
| exit 1 | |
| fi | |
| # Validate major_minor format (x.y) | |
| if ! echo "${{ inputs.major_minor }}" | grep -qE '^[0-9]+\.[0-9]+$'; then | |
| echo "Error: major_minor must be in x.y format (e.g., 1.1)" | |
| exit 1 | |
| fi | |
| # Validate package_version format (semver: x.y.z) | |
| if ! echo "${{ inputs.package_version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then | |
| echo "Error: package_version must be in semver format (e.g., 0.8.2)" | |
| exit 1 | |
| fi | |
| echo "Inputs validated successfully" | |
| - name: Get current version | |
| id: current | |
| run: | | |
| # Extract current version from test-pymadng.yml | |
| CURRENT_VERSION=$(grep -oP 'mad-linux-\K[0-9]+\.[0-9]+\.[0-9]+' .github/workflows/test-pymadng.yml | head -1) | |
| CURRENT_MAJOR_MINOR=$(grep -oP 'releases/madng/\K[0-9]+\.[0-9]+' .github/workflows/test-pymadng.yml | head -1) | |
| # Validate extracted versions | |
| if [ -z "$CURRENT_VERSION" ] || [ -z "$CURRENT_MAJOR_MINOR" ]; then | |
| echo "Error: Could not extract current version from test-pymadng.yml" | |
| exit 1 | |
| fi | |
| echo "version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT" | |
| echo "major_minor=$CURRENT_MAJOR_MINOR" >> "$GITHUB_OUTPUT" | |
| echo "Current MAD-NG version: $CURRENT_VERSION" | |
| echo "Current major.minor: $CURRENT_MAJOR_MINOR" | |
| - name: Update workflow files | |
| run: | | |
| # Update both workflow files with the new MAD-NG version | |
| for workflow in test-pymadng.yml python-publish.yml; do | |
| sed -i "s|releases/madng/${{ steps.current.outputs.major_minor }}/mad-linux-${{ steps.current.outputs.version }}|releases/madng/${{ inputs.major_minor }}/mad-linux-${{ inputs.new_version }}|g" ".github/workflows/$workflow" | |
| sed -i "s|releases/madng/${{ steps.current.outputs.major_minor }}/mad-macos-${{ steps.current.outputs.version }}|releases/madng/${{ inputs.major_minor }}/mad-macos-${{ inputs.new_version }}|g" ".github/workflows/$workflow" | |
| echo "Updated $workflow" | |
| done | |
| - name: Update example.log | |
| run: | | |
| sed -i "s/\[${{ steps.current.outputs.version }}\]/[${{ inputs.new_version }}]/g" tests/inputs/example.log | |
| echo "Updated example.log" | |
| - name: Update package version | |
| run: | | |
| # Update __version__ in src/pymadng/__init__.py | |
| sed -i -E "s/__version__ = \"[0-9]+\.[0-9]+\.[0-9]+\"/__version__ = \"${{ inputs.package_version }}\"/" src/pymadng/__init__.py | |
| echo "Updated package version to ${{ inputs.package_version }}" | |
| - name: Update CHANGELOG.md | |
| run: | | |
| CHANGELOG_ENTRY="${{ inputs.changelog_entry }}" | |
| if [ -z "$CHANGELOG_ENTRY" ]; then | |
| CHANGELOG_ENTRY="Update to MAD-NG ${{ inputs.new_version }}" | |
| fi | |
| # Get current date in YYYY/MM/DD format | |
| CURRENT_DATE=$(date +%Y/%m/%d) | |
| # Prepend new version entry to CHANGELOG.md with proper format | |
| # Format: version (date) \ | |
| # changelog entry | |
| TEMP_FILE=$(mktemp) | |
| echo "${{ inputs.package_version }} ($CURRENT_DATE) \\" > "$TEMP_FILE" | |
| echo "$CHANGELOG_ENTRY" >> "$TEMP_FILE" | |
| echo "" >> "$TEMP_FILE" | |
| cat CHANGELOG.md >> "$TEMP_FILE" | |
| mv "$TEMP_FILE" CHANGELOG.md | |
| echo "Updated CHANGELOG.md" | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
| commit-message: "Bump MAD-NG to ${{ inputs.new_version }} and package to ${{ inputs.package_version }}" | |
| title: "Bump MAD-NG to ${{ inputs.new_version }} and pymadng to ${{ inputs.package_version }}" | |
| body: | | |
| This PR updates the MAD-NG version from ${{ steps.current.outputs.version }} to ${{ inputs.new_version }} and bumps the package version to ${{ inputs.package_version }}. | |
| ## Changes | |
| - Updated `.github/workflows/test-pymadng.yml` | |
| - Updated `.github/workflows/python-publish.yml` | |
| - Updated `tests/inputs/example.log` | |
| - Updated `src/pymadng/__init__.py` (package version) | |
| - Updated `CHANGELOG.md` | |
| ## MAD-NG Release | |
| New MAD-NG version: ${{ inputs.new_version }} | |
| Major.minor: ${{ inputs.major_minor }} | |
| ## Package Release | |
| New package version: ${{ inputs.package_version }} | |
| After merging this PR, create a release with tag `v${{ inputs.package_version }}` to publish to PyPI. | |
| branch: bump-madng-${{ inputs.new_version }} | |
| base: main |