|
| 1 | +<div align="center"> |
| 2 | + <h1>☝ update-version</h1> |
| 3 | + <p>Update your files version field on new releases</p> |
| 4 | +</div> |
| 5 | + |
| 6 | +## 🧠 Why |
| 7 | + |
| 8 | +- Most actions related to version upgrade do it backwards: |
| 9 | +when you push a commit with version change in a specific branch a release is created. |
| 10 | + |
| 11 | +- This action does the opposite: when you create a release the |
| 12 | +specified files will get updated with the new version, so you don't forget to update them. |
| 13 | + |
| 14 | +This comes in handy when working with git workflows such as [trunk-base-development](https://trunkbaseddevelopment.com/) or [master-only](https://www.youtube.com/watch?v=MWz-9uyHP4s). |
| 15 | + |
| 16 | +## 🚀 Usage |
| 17 | + |
| 18 | +With the following example after creating a new release with tag `v2.0.1` on branch `release`, |
| 19 | +a new commit will appear in that same branch with both `package.json` and `app.yaml` updated |
| 20 | +with the version field to `2.0.1`. |
| 21 | + |
| 22 | +```yaml |
| 23 | +name: Upgrade Version |
| 24 | +on: |
| 25 | + release: |
| 26 | + types: [published] |
| 27 | + |
| 28 | +jobs: |
| 29 | + upgrade-version: |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v2 |
| 33 | + - uses: pocket-studios/action-update-version@v1 |
| 34 | + with: |
| 35 | + files: 'package.json, app.yaml' |
| 36 | + version-regexp: '\d+.\d+.\d+' |
| 37 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 38 | +``` |
| 39 | +
|
| 40 | +The action will fail if: |
| 41 | +- Both `repo-token` and `branch-name` are not supplied |
| 42 | +- The tag cannot be found by `octokit` |
| 43 | +- The regular expression cannot match the release tag |
| 44 | +- You specify a file with unsupported extension |
| 45 | + |
| 46 | + |
| 47 | +## ⚙ Inputs |
| 48 | + |
| 49 | +By supplying the `repo-token` the commit will use the release information: author and branch. |
| 50 | + |
| 51 | +You can change the branch commit target and the commit author if you want. |
| 52 | + |
| 53 | +**Name**|**Description**|**Default** |
| 54 | +-----|-----|----- |
| 55 | +files|Comma separated list of files to update its version field|package.json |
| 56 | +version-regexp|Regular expression to match release tag name|\d+.\d+.\d+ |
| 57 | +repo-token|GitHub token to get the release information in order to push to branch|`null` |
| 58 | +commit-message|Commit message for files update. The %version% will get substituted|ci: update version to v%version% |
| 59 | +spacing-level|Number of spaces for formatted files|`2` |
| 60 | +branch-name|Default branch name to push changes if not repo-token is provided|*Release target branch* |
| 61 | +author-name|Commit author name|*Release author name* |
| 62 | +author-email|Commit author email|*Release author email* |
| 63 | + |
| 64 | +## 👋 Support |
| 65 | + |
| 66 | +- Supported file extensions: `json`, `yaml` and `yml`. To add one simply submit a PR with a new parser on the `main.ts` file. |
0 commit comments