Skip to content

Commit

Permalink
Package Versioning [THC-444] (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
VeiveHata authored Oct 1, 2024
1 parent d26e6e4 commit d678ba7
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 34 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/pr-close
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'PR Close'
on:
pull_request:
branches:
- main
types:
- closed
jobs:
merge_pr:
name: 'PR Merged'
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.ACCOUNT_WITH_FORCE_PUSH_PERMISSION_TOKEN }}
- uses: actions/setup-node@v4
with:
cache: 'npm'
- name: Git config
run: |
git config --global user.email "${{ secrets.ACCOUNT_WITH_FORCE_PUSH_PERMISSION_EMAIL }}"
git config --global user.name "${{ secrets.ACCOUNT_WITH_FORCE_PUSH_PERMISSION_NAME }}"
- name: Apply version bump (major)
if: contains(github.event.pull_request.labels.*.name, 'major')
run: npm version major
- name: Apply version bump (minor)
if: contains(github.event.pull_request.labels.*.name, 'minor')
run: npm version minor
- name: Apply version bump (patch)
if: contains(github.event.pull_request.labels.*.name, 'patch')
run: npm version patch
- name: Git push version bump
run: git push origin main --follow-tags --force
- id: set-version
name: Output version change
run: npm pkg get version
20 changes: 20 additions & 0 deletions .github/workflows/pr-label
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Label Check'
on:
pull_request:
branches:
- main
types: [labeled, unlabeled, synchronize]
jobs:
check_labels:
name: 'Check PR Labels'
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: mheap/github-action-required-labels@v5
with:
mode: exactly
count: 1
labels: 'major, minor, patch'
add_comment: true
message: "For merging ***one*** versioning label is required: ```major```, ```minor``` or ```patch```."
34 changes: 34 additions & 0 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'PR Open'
on:
pull_request:
branches:
- main
types:
- opened
jobs:
check_labels:
name: 'Check PR Labels'
runs-on: ubuntu-latest
permissions:
pull-requests: write
outputs:
status: ${{ steps.labels.outputs.status }}
steps:
- id: labels
uses: mheap/github-action-required-labels@v5
with:
mode: exactly
count: 1
labels: 'major, minor, patch'
exit_type: success

add_label:
name: 'Add Default Label'
needs: check_labels
runs-on: ubuntu-latest
if: needs.check_labels.outputs.status == 'failure'
steps:
- name: Add Default Label
uses: actions-ecosystem/action-add-labels@v1
with:
labels: 'minor'
21 changes: 0 additions & 21 deletions .github/workflows/push.yml

This file was deleted.

16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,9 @@ Once you installed depedencies you are good to start development, no other actio

## Version update

Package version update is done automatically according to commit message. Check it here: [Bump package version](https://github.com/marketplace/actions/bump-package-version).

- there is no default version bump, be sure to provide correct commit message in case you want to update the version
- check different options for providing commit message for different [merge strategies](https://github.com/marketplace/actions/bump-package-version#-pull-requests)


For automatic version bump start you commit message with:

**MAJOR** - `M:`,` MAJOR:`, `major:`

**MINOR** - `m:`, `minor:`

**PATCH** - `fix:`, `patch:`
- Open PR
- Set the **label** with the version update, you need to apply: ```major```, ```minor``` or ```patch```.
- After merging the PR to the main, the version should be updated automatically according to the label.


## Publication
Expand Down

0 comments on commit d678ba7

Please sign in to comment.