Skip to content

Added explicit env variables handling in parseEnv(). #13

Added explicit env variables handling in parseEnv().

Added explicit env variables handling in parseEnv(). #13

name: CI/CD Pipeline -> Versioning
on:
pull_request:
types: [closed]
branches:
- main
jobs:
increment-version:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Configure Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Increment version
id: version
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
NEW_VERSION=$(node -p "const [major, minor, patch] = '${CURRENT_VERSION}'.split('.'); [major, minor, parseInt(patch) + 1].join('.')")
npm version ${NEW_VERSION} --no-git-tag-version
echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT
git add package.json package-lock.json
git commit -m "chore: bump version to ${NEW_VERSION} [skip ci]"
git push
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: v.${{ steps.version.outputs.new_version }}
name: Release v.${{ steps.version.outputs.new_version }}
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}