Skip to content

:octocat: Github action to modify specific project files with an updated version of your project based on each release tag.

License

Notifications You must be signed in to change notification settings

tj-actions/sync-release-version

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codacy Badge CI Update release version. Public workflows that use this action.

sync-release-version

Problem

With multiple files that need to be updated each time a new released is created.

sync-release-version makes this process less complex by using a regex pattern to match the lines in the specified files that needs to be updated.

Helpful Resources

Usage

Sync a project release version number.

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

Note

  • This example assumes a post release operation i.e changes are made to a README after a new version is releaased.
...
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0 # otherwise, you will fail to push refs to dest repo

      - name: Sync release version.
        uses: tj-actions/sync-release-version@v13
          id: sync-release-version
          with:
            pattern: 'version='
            current_version: '1.0.1'  # Omit this to use git tag.
            new_version: '1.0.2'  # Omit this to use git tag.
            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@v4
        with:
          fetch-depth: 0
 
      - name: Sync release version.
        uses: tj-actions/sync-release-version@v13
        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: "main"
          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@v4
        with:
          fetch-depth: 0
      - name: Sync release version.
        uses: tj-actions/sync-release-version@v6.8

AFTER

README.md

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

Inputs

INPUT TYPE REQUIRED DEFAULT DESCRIPTION
current_version string false The current project version (Default: The last git tag).
new_version string false The next project version (Default: The new git tag).
only_major string false "false" Only update the major version
number.
paths string 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.
strip_prefix string false Prefix to strip from the
tag. For example if strip_prefix
is set to v and
the tag is v1.0.0 the
output becomes 1.0.0.

Outputs

OUTPUT TYPE DESCRIPTION
is_initial_release string Boolean indicating an initial release.
major_update string Boolean indicating a major version
bump
new_version string The current project version
old_version string The previous project version

If you feel generous and want to show some extra appreciation:

Buy me a coffee

Features

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

Known Limitation

Important

  • 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.