Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add bump and tag version workflow #11

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
52 changes: 52 additions & 0 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Bump version

on:
workflow_call:
inputs:
tag-prefix:
required: false
default: 'v'
type: string
outputs:
tag:
description: Newly created tag
value: ${{ jobs.bump-version.outputs.tag }}

jobs:
bump-version:
name: Bump Version on master
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action will have permission to merge to master.? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works on regular branch. But just tested, and it does not work on protected branch, it requires a Personal Access Token, instead of GITHUB_TOKEN

runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
tag: ${{ steps.save-tag.outputs.tag }}

steps:
- name: Checkout source code
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}

- name: cat package.json
run: cat ./package.json

- name: Automated Version Bump
id: version-bump
uses: phips28/gh-action-bump-version@master
with:
tag-prefix: ${{ inputs.tag-prefix }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one just open a PR. The point of this PR is to do everything all a once, at the same time.


- name: cat package.json
run: cat ./package.json

- name: Output Step
env:
NEW_TAG: ${{ steps.version-bump.outputs.newTag }}
run: echo "new tag $NEW_TAG"

- name: Save tag to workflow output
env:
NEW_TAG: ${{ steps.version-bump.outputs.newTag }}
id: save-tag
run: echo "tag=$NEW_TAG" >> "$GITHUB_OUTPUT"
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,29 @@ jobs:
secrets: inherit
```

### Bump the package.json version and create a tag

This workflow trigger a task to bump the package.json version, and creates a tag with the newly created version.
Commits message will be read to determine the version bump type.

#### Usage

Install it in your project by creating the file `.github/workflows/bump-version.yml`, with the following content

```yaml
name: Bump version

on:
push:
branches:
- 'main' # or master, depending on your repo

jobs:
bump-version:
uses: snapshot-labs/actions/.github/workflows/bump-version.yml@main
secrets: inherit
```

## Notes

- [Github docs about reused worflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows)
Expand Down