GitHub Action
Sync release version.
With multiple files that need to be updated each time a new version of your software is released.
sync-release-version
makes this process less complex by using sed's 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@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 }}"
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@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: "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@v2
with:
fetch-depth: 0
- name: Sync release version.
uses: tj-actions/[email protected]
README.md
...
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Sync release version.
uses: tj-actions/sync-release-version@v7
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 | type | example | description |
---|---|---|---|
new_version |
string |
1.2.1 |
The current project version |
old_version |
string |
1.2.0 |
The previous project version |
- Free software: MIT license
- Modifies files with an up to date version of your project based on each release tag.
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.