Skip to content

Refactoring

Refactoring #88

Workflow file for this run

# This will increase package.json version, create tags and release
name: Release
on:
pull_request:
branches:
- dev
types:
- closed
permissions:
contents: write
pull-requests: write
jobs:
# This job will check if the Pull request was merged into dev branch
check_valid_merge:
name: Merge 'Pull request' to 'dev' branch
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- run: |
echo The PR was merged.
# This will validate to see if the labels contains 'none' which means that if 'none' was found the release will not happen
check_valid_release:
name: Validate release conditions
needs: check_valid_merge
if: ${{ !contains(github.event.pull_request.labels.*.name, 'norelease') }}
runs-on: ubuntu-latest
steps:
- run: |
echo The PR can continue to tags release creation.
# Steps for creation of the tags
create_tags:
name: Generate and push tags
runs-on: ubuntu-latest
needs: [check_valid_merge, check_valid_release]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1
# Create the tags
- name: Push tags
uses: anothrNick/github-tag-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
CUSTOM_TAG: ${{ steps.package-version.outputs.current-version}}
BRANCH_HISTORY: full
# Create of the changelog file and commit the file to the dev branch
create_changelog_partial:
name: Generate changelog, create PR for CHANGELOG.md
needs: create_tags
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Generate the changelog file based on the cliff.toml file
- name: Generate CHANGELOG.md
uses: orhun/git-cliff-action@v3
id: git-cliff
with:
config: cliff.toml
args: -vv --latest --strip header
env:
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: ${{ steps.git-cliff.outputs.content }}
tag_name: ${{ steps.git-cliff.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
draft: false
make_latest: true
create_changelog_full:
name: Generate changelog, create PR for CHANGELOG.md
needs: create_tags
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Generate the changelog file based on the cliff.toml file
- name: Generate CHANGELOG.md
uses: orhun/git-cliff-action@v3
id: git-cliff
with:
config: cliff.toml
args: --verbose
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
- name: Move CHANGELOG.md generated file to root folder
run: |
cp ./git-cliff/CHANGELOG.md ./
rm ./git-cliff/CHANGELOG.md
rmdir ./git-cliff/
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
base: dev
token: ${{ secrets.GITHUB_TOKEN }}
title: CHANGELOG.md updated
body: CHANGELOG.md updated with latest conventional commits.
labels: norelease, deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}