https://github.com/tj-actions/sync-release-version
:octocat: Github action to modify specific project files with an updated version of your project based on each release tag.
https://github.com/tj-actions/sync-release-version
actions auto-documentation ci github-actions release-automation semantic-versioning semver-release sync version
Last synced: about 1 month ago
JSON representation
:octocat: Github action to modify specific project files with an updated version of your project based on each release tag.
- Host: GitHub
- URL: https://github.com/tj-actions/sync-release-version
- Owner: tj-actions
- License: mit
- Created: 2020-06-18T22:12:25.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-01-15T18:41:50.000Z (4 months ago)
- Last Synced: 2025-02-15T14:29:09.509Z (3 months ago)
- Topics: actions, auto-documentation, ci, github-actions, release-automation, semantic-versioning, semver-release, sync, version
- Language: Shell
- Homepage:
- Size: 515 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[](https://app.codacy.com/gh/tj-actions/sync-release-version/dashboard?utm_source=gh\&utm_medium=referral\&utm_content=\&utm_campaign=Badge_grade)
[](https://github.com/tj-actions/sync-release-version/actions?query=workflow%3ACI)
[](https://github.com/tj-actions/sync-release-version/actions?query=workflow%3A%22Update+release+version.%22)
[](https://github.com/search?o=desc\&q=tj-actions+sync-release-version+path%3A.github%2Fworkflows+language%3AYAML\&s=\&type=Code)[](#contributors-)
## 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
* https://www.regextester.com/111539
* https://www.tutorialspoint.com/unix/unix-regular-expressions.htm## 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.```yaml
...
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@2a7ef0deb39b3ecce887ee99d2261c6cef989d84 # 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](https://github.com/peter-evans/create-pull-request)
```yaml
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@2a7ef0deb39b3ecce887ee99d2261c6cef989d84 # 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

Creating a new release `v6.8 -> v7` using the recommended configuration above.
#### BEFORE
`README.md`
```yaml
...
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sync release version.
uses: tj-actions/[email protected]
```#### AFTER
`README.md`
```yaml
...
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](#input_current_version) | string | false | | The current project version (Default: The last git tag). |
| [new\_version](#input_new_version) | string | false | | The next project version (Default: The new git tag). |
| [only\_major](#input_only_major) | string | false | `"false"` | Only update the major version
number. |
| [paths](#input_paths) | string | true | | A list of file names
to search and replace versions. |
| [pattern](#input_pattern) | string | false | | The pattern to match the
location that needs to be
updated. |
| [strip\_prefix](#input_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`. |
| [use\_tag\_commit\_hash](#input_use_tag_commit_hash) | string | false | `"false"` | When true, uses commit hash
in the replacement pattern. For
example, replaces `hash # v1` with `hash # v2`. |## Outputs
| OUTPUT | TYPE | DESCRIPTION |
|------------------------------------------------------------------------------------------|--------|----------------------------------------------|
| [is\_initial\_release](#output_is_initial_release) | string | Boolean indicating an initial release. |
| [major\_update](#output_major_update) | string | Boolean indicating a major version
bump |
| [new\_version](#output_new_version) | string | The current project version |
| [old\_version](#output_old_version) | string | The previous project version |* Free software: [MIT license](LICENSE)
If you feel generous and want to show some extra appreciation:
[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]
[buymeacoffee]: https://www.buymeacoffee.com/jackton1
[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png
## 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](https://github.com/cookiecutter/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.## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!