|
| 1 | +--- |
| 2 | +name: Prepare Release PR |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + version: |
| 9 | + description: Override the autogenerated version. |
| 10 | + required: false |
| 11 | + default: '' |
| 12 | + type: string |
| 13 | + |
| 14 | +jobs: |
| 15 | + update-release: |
| 16 | + name: Render changelog and create/update PR |
| 17 | + runs-on: ubuntu-24.04 |
| 18 | + if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) |
| 19 | + permissions: |
| 20 | + contents: write |
| 21 | + pull-requests: write |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 26 | + |
| 27 | + - name: Set up Python 3.10 |
| 28 | + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 |
| 29 | + with: |
| 30 | + python-version: '3.10' |
| 31 | + |
| 32 | + - name: Install project |
| 33 | + run: | |
| 34 | + python -m pip install --upgrade pip |
| 35 | + python -m pip install '.[changelog]' pre-commit |
| 36 | +
|
| 37 | + - name: Get next version |
| 38 | + if: github.event_name == 'push' || inputs.version == '' |
| 39 | + id: next-version |
| 40 | + run: echo "version=$(python tools/version.py next)" >> "$GITHUB_OUTPUT" |
| 41 | + |
| 42 | + - name: Update CHANGELOG.md |
| 43 | + env: |
| 44 | + NEXT_VERSION: ${{ (github.event_name == 'workflow_dispatch' && inputs.version != '') && inputs.version || steps.next-version.outputs.version }} |
| 45 | + run: towncrier build --yes --version "${NEXT_VERSION}" |
| 46 | + |
| 47 | + - name: Run pre-commit once to remove trailing whitespace |
| 48 | + run: | |
| 49 | + python -m pre_commit run --files=CHANGELOG.md || true |
| 50 | +
|
| 51 | + - name: Create/update release PR |
| 52 | + uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5 |
| 53 | + with: |
| 54 | + commit-message: Release v${{ (github.event_name == 'workflow_dispatch' && inputs.version != '') && inputs.version || steps.next-version.outputs.version }} |
| 55 | + branch: release/auto |
| 56 | + sign-commits: true |
| 57 | + title: Release v${{ (github.event_name == 'workflow_dispatch' && inputs.version != '') && inputs.version || steps.next-version.outputs.version }} |
| 58 | + body: | |
| 59 | + This automated PR builds the latest changelog. When merged, a new release is published automatically. |
| 60 | +
|
| 61 | + Before merging, please ensure it's based on the most recent default branch HEAD. |
| 62 | +
|
| 63 | + If you want to rebuild this PR with a custom version or the current date, you can also trigger the corresponding workflow manually in `Actions` > `Prepare Release PR` > `Run workflow`. |
| 64 | +
|
| 65 | + You can still follow the manual release procedure outlined in: https://salt-extensions.github.io/salt-extension-copier/topics/publishing.html |
0 commit comments