Skip to content

Custom Pull request title with tag version #303

Open

Description

@AdisonCavani

I'd like to get a customized Pull request title / commit message like this: release: v0.0.1.

I know there is ability to customize the title:

      - name: Changesets PR or publish
        uses: changesets/action@v1
        with:
          title: My Custom PR title

But I want to also get a tag name, so the naming in more specific.
Is this possible?

Activity

  1. denizdogan commented on Aug 28, 2023

    @denizdogan

    Did you figure this out? I'm looking for the same thing.

  2. lakardion commented on Sep 16, 2023

    @lakardion

    I would love to know as well how I can add the version to the PR title

  3. r115 commented on Nov 8, 2023

    @r115

    I have a customized hack for it. There is a PR somewhere here for adding a --dry-run flag which should solve this. Anyway, here's my hack;

    Context

    • monorepo using pnpm
    • custom helper file at the root project
    • only creating a pull request. no package is published
    • single changeset per action

    Steps

    Create helper file at project root

    release-helper.js

    const config = require('./release.json');
    const {unlink} = require('fs')
    
    const commit_message = `v${config.releases[0].newVersion} of ${config.releases[0].name}`
    unlink('./release.json', () => {})
    
    console.log(commit_message)

    Add a step to generate changeset

    steps:
      ...
      - name: Prep commit message
         id: prep_commit_message
         run: |
           MESSAGE=$(pnpm changeset status --output=./release.json && node release-helper.js | tail -n 1)
           echo "message=${MESSAGE}" >> $GITHUB_OUTPUT

    profit

    steps:
      ...
      - name: Create Release Pull Request
         uses: changesets/action@v1
         with:
           title: ${{ steps.prep_commit_message.outputs.message }}
           commit: "release version ${{ steps.prep_commit_message.outputs.message }}"
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    This stuff can possibly be knocked out with a one liner using jq. Just didn't want to jump through the hoops until the solution works over some time.

  4. hollandjake commented on Jan 12, 2024

    @hollandjake

    Incase you are ever interested in the jq version - @r115

    It creates a release.json file temporarily extracts the version using jq and then removes the file (this is due to an outstanding feature request changesets/changesets#1020)

    steps:
      ...
      - name: Prep commit message
        run: |
          echo "NEW_VERSION=$(pnpm changeset status --output=release.json && jq -r '.releases[0].newVersion' release.json && rm release.json)" >> "$GITHUB_ENV"
      - name: Create Release Pull Request or Publish
        id: changesets
        uses: changesets/action@v1
        with:
          title: "Release v${{env.NEW_VERSION}}"
          commit: "Release v${{env.NEW_VERSION}}"
          publish: pnpm run release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
  5. dcroote commented on Feb 21, 2024

    @dcroote

    @hollandjake this is excellent, thanks

  6. jpconnol commented on Nov 11, 2024

    @jpconnol

    Leaving here in case it helps anyone else, @hollandjake's script above is incredible and saved me a ton of time but was also capturing the output of the pnpm changeset status --output=release.json which was something like:

    > @your-repo changeset /Users/path
    > changeset "status" "--output=release.json"
    

    To reconcile, I had to adjust it ever so slightly to ensure that we only captured the new version number itself:

    - name: Capture New Release Version
      run: |
        pnpm changeset status --output=release.json
        echo "NEW_VERSION=$(jq -r '.releases[0].newVersion' release.json)" >> "$GITHUB_ENV"
        rm release.json
    
    - name: Create Release Pull Request or Publish
      id: changesets
      uses: changesets/action@v1
      with:
        title: "Release v${{env.NEW_VERSION}}"
        commit: "Release v${{env.NEW_VERSION}}"
        publish: pnpm run release
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
  7. andreww2012 commented on Nov 30, 2025

    @andreww2012

    The cleanest way I've found to capture the new release version to use in PR title (unfortunately solutions suggested above tricky to set up properly and they do not always work - maybe due to me being in the prerelease mode):

    pnpm changeset version
    echo "NEW_VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV
    git restore .
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions