Create release PR #87
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
| name: Create release PR | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump: | |
| type: choice | |
| description: The version bump type. Select 'auto' to determine from changelog entries. | |
| default: auto | |
| options: | |
| - auto | |
| - major | |
| - minor | |
| - patch | |
| prerelease: | |
| type: string | |
| description: Optional pre-release tag (e.g. alpha.1, beta.1, rc.1). Leave empty for stable. | |
| default: "" | |
| jobs: | |
| create-release-pr: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # actions/checkout@v4 | |
| - uses: ./.github/actions/setup-python | |
| - name: Compute next dir for bump | |
| id: changie-next | |
| uses: miniscruff/changie-action@6dcc2533cac0495148ed4046c438487e4dceaa23 | |
| with: | |
| version: latest | |
| args: next ${{ inputs.bump }} | |
| - name: Prepare batch args | |
| id: prepare-batch | |
| shell: bash | |
| env: | |
| PR: ${{ inputs.prerelease }} | |
| BUMP: ${{ inputs.bump }} | |
| NEXT_DIR: ${{ steps.changie-next.outputs.output }} | |
| run: | | |
| if [[ -n "$PR" ]]; then | |
| if [[ ! "$PR" =~ ^(alpha|beta|rc)\.[0-9]+$ ]]; then | |
| echo "Invalid prerelease format: $PR (expected alpha.N, beta.N, rc.N)" >&2 | |
| exit 1 | |
| fi | |
| echo "args=batch $BUMP --move-dir $NEXT_DIR --prerelease $PR" >> "$GITHUB_OUTPUT" | |
| else | |
| if [[ -d "$NEXT_DIR" ]]; then | |
| echo "args=batch $BUMP --include $NEXT_DIR --remove-prereleases" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "args=batch $BUMP" >> "$GITHUB_OUTPUT" | |
| fi | |
| fi | |
| - name: Batch changes | |
| uses: miniscruff/changie-action@6dcc2533cac0495148ed4046c438487e4dceaa23 | |
| with: | |
| version: latest | |
| args: ${{ steps.prepare-batch.outputs.args }} | |
| - name: Merge | |
| uses: miniscruff/changie-action@6dcc2533cac0495148ed4046c438487e4dceaa23 | |
| with: | |
| version: latest | |
| args: merge | |
| - name: Get the latest version | |
| id: changie-latest | |
| uses: miniscruff/changie-action@6dcc2533cac0495148ed4046c438487e4dceaa23 | |
| with: | |
| version: latest | |
| args: latest | |
| - name: Set latest package version | |
| id: package-version | |
| env: | |
| VERSION: ${{ steps.changie-latest.outputs.output }} | |
| run: | | |
| VERSION_NO_V=$(echo "$VERSION" | cut -c 2-) | |
| MESSAGE=$(cat ".changes/$VERSION.md") | |
| { | |
| echo "version=$VERSION_NO_V" | |
| echo "message<<EOF" | |
| echo "$MESSAGE" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e | |
| with: | |
| committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | |
| title: "version: ${{ steps.package-version.outputs.version }}" | |
| branch: release/${{ steps.package-version.outputs.version }} | |
| commit-message: | | |
| version: ${{ steps.package-version.outputs.version }} | |
| ${{ steps.package-version.outputs.message }} | |
| body: | | |
| ## version: ${{ steps.package-version.outputs.version }} | |
| ${{ steps.package-version.outputs.message }} |