Skip to content

Commit

Permalink
devops: added version bumped
Browse files Browse the repository at this point in the history
  • Loading branch information
adolfokrah committed Jul 28, 2024
1 parent 3fd8e00 commit 015bd7b
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 7 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/bump-package-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Bump version on push to main

on:
push:
branches:
- main

jobs:
bump-version:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v3
with:
version: 20.5.1
cache: npm
registry-url: https://registry.npmjs.org

- name: Install dependencies
run: npm install

- name: Bump version
id: bump_version
run: |
current_version=$(jq -r '.version' package.json)
IFS='.' read -r -a version_parts <<< "$current_version"
major=${version_parts[0]}
minor=${version_parts[1]}
patch=${version_parts[2]}
new_patch=$((patch + 1))
new_version="$major.$minor.$new_patch"
jq ".version = \"$new_version\"" package.json > package.tmp.json
mv package.tmp.json package.json
echo "New version: $new_version"
echo "::set-output name=new_version::$new_version"
- name: Commit updated version
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git add package.json
git commit -m "Bump version to ${{ steps.bump_version.outputs.new_version }}"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Trigger Release components package workflow
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
event-type: version-bumped
15 changes: 8 additions & 7 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Create Release

on:
push:
branches:
- main
repository_dispatch:
types: [version-bumped]

jobs:
create_release:
Expand All @@ -13,10 +12,12 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install Node.js
uses: actions/setup-node@v3
with:
version: 20.5.1
cache: npm
registry-url: https://registry.npmjs.org

- name: Install jq
run: sudo apt-get install -y jq
Expand Down

0 comments on commit 015bd7b

Please sign in to comment.