diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index f2e90fc..146fc6c 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -1,6 +1,7 @@ -# Placeholder draft-release workflow +# Drafts new mailtrap-python release: bumps the version, regenerates the changelog from +# merged PRs, and opens a release PR against main. # -name: Draft python Release +name: Draft Python Release on: workflow_dispatch: inputs: @@ -14,14 +15,72 @@ on: - major default: patch +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + +permissions: + contents: write + pull-requests: write + jobs: draft-release: - name: Draft python Release (placeholder) + name: Draft mailtrap-python Release runs-on: ubuntu-latest steps: - - name: Echo inputs - env: - BUMP_TYPE: ${{ inputs.bump_type }} - run: | - echo "Placeholder draft-release workflow" - echo "bump_type=$BUMP_TYPE" + - uses: actions/checkout@v4 + with: + ref: main + + - name: Install uv + uses: astral-sh/setup-uv@v6 + + - name: Read current version + id: read + run: echo "version=$(uv version --short)" >> "$GITHUB_OUTPUT" + + - name: Compute next version + id: bump + uses: railsware/github-actions/compute-next-semver@master + with: + current: ${{ steps.read.outputs.version }} + bump-type: ${{ inputs.bump_type }} + + - name: Abort if tag already exists + uses: railsware/github-actions/abort-if-tag-exists@master + with: + tag: ${{ steps.bump.outputs.tag }} + + - name: Generate release notes + id: notes + uses: railsware/github-actions/generate-release-notes@master + with: + tag: ${{ steps.bump.outputs.tag }} + + - name: Update version in pyproject.toml + if: steps.notes.outputs.release_notes != '' + run: uv version --no-sync "${{ steps.bump.outputs.next }}" + + - name: Prepend new section to CHANGELOG.md + if: steps.notes.outputs.release_notes != '' + uses: railsware/github-actions/prepend-changelog@master + with: + version: ${{ steps.bump.outputs.next }} + release-notes: ${{ steps.notes.outputs.release_notes }} + + - name: Commit, push, open PR + if: steps.notes.outputs.release_notes != '' + uses: railsware/github-actions/open-sdk-release-pr@master + with: + tag: ${{ steps.bump.outputs.tag }} + current: ${{ steps.read.outputs.version }} + next: ${{ steps.bump.outputs.next }} + bump-type: ${{ inputs.bump_type }} + release-notes: ${{ steps.notes.outputs.release_notes }} + + - name: Create draft GitHub release + if: steps.notes.outputs.release_notes != '' + uses: railsware/github-actions/create-draft-github-release@master + with: + tag: ${{ steps.bump.outputs.tag }} + release-notes: ${{ steps.notes.outputs.release_notes }}