Skip to content

fix(github-actions): fixed actions after were refactored #94

fix(github-actions): fixed actions after were refactored

fix(github-actions): fixed actions after were refactored #94

Workflow file for this run

# This will increase package.json version, create tags and release
name: Release
on:
pull_request:
branches:
- main
types:
- closed
permissions:
contents: write
pull-requests: write
jobs:
release:
name: Release New Version
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
# Check if PR contains version bump labels
- name: Check labels to proceed versioning
id: proceed-versioning
if: >
contains(github.event.pull_request.labels.*.name, 'patch') ||
contains(github.event.pull_request.labels.*.name, 'minor') ||
contains(github.event.pull_request.labels.*.name, 'major')
run: echo "Proceed versioning"
# Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# Set up Node.js
- name: Set Up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
# Install package.json dependencies
- name: Install dependencies
run: npm install
# Determine version bump type
- name: Determine version bump type
env:
IS_PATCH_FOUND: "${{ contains(github.event.pull_request.labels.*.name, 'patch') }}"
IS_MINOR_FOUND: "${{ contains(github.event.pull_request.labels.*.name, 'minor') }}"
IS_MAJOR_FOUND: "${{ contains(github.event.pull_request.labels.*.name, 'major') }}"
run: |
if [ "${IS_PATCH_FOUND}" == "true" ]; then
echo "VERSION_BUMP=patch" >> $GITHUB_ENV
echo "Version: patch"
elif [ "${IS_MINOR_FOUND}" == "true" ]; then
echo "VERSION_BUMP=minor" >> $GITHUB_ENV
echo "Version: minor"
elif [ "${IS_MAJOR_FOUND}" == "true" ]; then
echo "VERSION_BUMP=major" >> $GITHUB_ENV
echo "Version: major"
else
exit 0
fi
# Update package version
- name: Update Package Version
run: npm version ${{ env.VERSION_BUMP }} --no-git-tag-version
# Push git created tag
- name: Push git tag
id: tag
uses: anothrNick/github-tag-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
CUSTOM_TAG: ${{ env.VERSION_BUMP }}
BRANCH_HISTORY: full
# Generate the changelog file using the configuration from cliff.toml.
- name: Generate CHANGELOG.md partial
id: git-cliff-partial
uses: orhun/git-cliff-action@v3
with:
config: cliff.toml
args: -vv --latest --strip header
env:
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
# Create a GitHub release using the generated changelog content.
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: ${{ steps.git-cliff-partial.outputs.content }}
tag_name: ${{ steps.git-cliff-partial.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
draft: false
make_latest: true
# Generate the changelog file based on the cliff.toml file
- name: Generate CHANGELOG.md
uses: orhun/git-cliff-action@v3
with:
config: cliff.toml
args: --verbose
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
# Move the generated changelog to the root folder and clean up.
- name: Move CHANGELOG.md to root directory
run: |
cp ./git-cliff/CHANGELOG.md ./
rm ./git-cliff/CHANGELOG.md
rmdir ./git-cliff/
- name: Create pull request
uses: peter-evans/create-pull-request@v5
with:
branch: feature-version-bump
title: 'chore: update version and changelog'
body: 'This PR updates the version and changelog.'
base: dev
labels: deploy