diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index 7853dfc..c711bbf 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -1,4 +1,5 @@ -# Placeholder draft-release workflow +# Drafts new mailtrap-ruby release: bumps the version, regenerates the changelog from +# merged PRs, and opens a release PR against main. # name: Draft ruby Release on: @@ -14,14 +15,91 @@ on: - major default: patch +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + +permissions: + contents: write + pull-requests: write + jobs: draft-release: - name: Draft ruby Release (placeholder) + name: Draft mailtrap-ruby Release runs-on: ubuntu-latest steps: - - name: Echo inputs + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: main + + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.3" + + - name: Read current version + id: read + run: | + version=$(ruby -r "./lib/mailtrap/version.rb" -e "puts Mailtrap::VERSION") + echo "version=$version" >> "$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 version file + if: steps.notes.outputs.release_notes != '' env: - BUMP_TYPE: ${{ inputs.bump_type }} + NEXT: ${{ steps.bump.outputs.next }} + run: | + cat > "./lib/mailtrap/version.rb" <