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.
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 }}"
Recomended usage with peter-evans/create-pull-request@v3
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"
Creating a new release v6.8 -> v7
using the recommended configuration above.
README.md
...
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sync release version.
uses: tj-actions/sync-release-version@v6.8
README.md
...
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sync release version.
uses: tj-actions/sync-release-version@v7
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 . |
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 |
- Free software: MIT license
If you feel generous and want to show some extra appreciation:
- Modifies files with an up to date version of your project based on each release tag.
Important
- To ignore certain lines from getting updated ensure the version used doesn't match either the current or previous version.
This package was created with Cookiecutter.
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.