Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
arrow-up

GitHub Action

Sync release version.

v8.3

Sync release version.

arrow-up

Sync release version.

Update files that reference a project version with a new release number

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Sync release version.

uses: tj-actions/[email protected]

Learn more about this action in tj-actions/sync-release-version

Choose a version

CI Update release version.

sync-release-version

Usage

Sync a project release version number.

Update files that reference a project version with a new release number.

...
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
      - name: Sync release version.
        uses: tj-actions/[email protected]
          id: sync-release-version
          with:
            current_version: '1.0.1'  # Omit to use git tag.
            new_version: '1.0.2'  # Omit when running on a release action.
            paths: |
              README.md
              test/subdir/README.md
      - run: |
        echo "Upgraded from ${{ steps.sync-release-version.outputs.old_version }} -> ${{ steps.sync-release-version.outputs.new_version }}" 
name: Update release version.
on:
  release:
    types: [published]


jobs:
  update-version:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Sync release version.
        uses: tj-actions/[email protected]
        id: sync-release-version
        with:
          pattern: 'tj-actions/sync-release-version@'
          paths: |
            README.md
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v3
        with:
          base: "master"
          title: "Upgraded to ${{ steps.sync-release-version.outputs.new_version }}"
          branch: "upgrade-to-${{ steps.sync-release-version.outputs.new_version }}"
          commit-message: "Upgraded from ${{ steps.sync-release-version.outputs.old_version }} -> ${{ steps.sync-release-version.outputs.new_version }}"
          body: "View [CHANGES](https://github.com/${{ github.repository }}/compare/${{ steps.sync-release-version.outputs.old_version }}...${{ steps.sync-release-version.outputs.new_version }})"
          reviewers: "jackton1"

Example

Sample

Creating a new release v6.8 -> v7 using the recommended configuration above.

BEFORE

README.md

...
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Sync release version.
        uses: tj-actions/[email protected]

AFTER

README.md

...
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Sync release version.
        uses: tj-actions/sync-release-version@v7

Inputs

Input type required default description
token string true ${{ github.token }} GITHUB_TOKEN
or a repo scoped
Personal Access Token
current_version string false The current project version
(Defualts to: The last git tag)
new_version string false The next project version
(Defaults to: The new git tag)
paths array true A list of file names to search
and replace versions.
pattern string false '' The pattern to match the location
that needs to be updated

Output

Output type example description
new_version string 1.2.1 The current project version
old_version string 1.2.0 The previous project version

Features

  • Modifies files with an up to date version of your project based on each release tag.

Known Issues

To ignore certain lines from getting updated ensure the version used doesn't match either the current or previous version.

Credits

This package was created with Cookiecutter.

Report Bugs

Report bugs at https://github.com/tj-actions/sync-release-version/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your workflow that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.