Changes #70
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will increase package.json version, create tags and release | |
name: Release | |
on: | |
pull_request: | |
branches: | |
- main | |
types: | |
- closed | |
paths-ignore: | |
- '../../test/*' | |
- '../ISSUE_TEMPLATE/*' | |
- '../workflows/*' | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
# This job will check if the Pull request was merged into main branch | |
check_valid_merge: | |
name: Merge 'Pull request' to 'main' 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. | |
# This will start build of the project | |
check_valid_build: | |
name: Check build validity | |
runs-on: ubuntu-latest | |
needs: [check_valid_merge, check_valid_release] | |
steps: | |
- uses: actions/checkout@v4 | |
- run: npm install | |
- run: npm run build | |
# Steps for creation of the tags | |
create_tags: | |
name: Generate and push tags | |
runs-on: ubuntu-latest | |
needs: check_valid_build | |
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 | |
# This create_changelog_partial will create the CHANGELOG only for the latest tag and create the RELEASE | |
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 | |
# This create_changelog_full will create the CHANGELOG.md | |
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: main | |
token: ${{ secrets.GITHUB_TOKEN }} | |
title: CHANGELOG.md updated | |
body: CHANGELOG.md updated with latest conventional commits. | |
labels: norelease | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# This will push the latest build of the project to npm | |
publish-npm: | |
name: Publish to npm public | |
needs: [create_changelog_full, create_changelog_partial] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# Setup .npmrc file to publish to npm | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
registry-url: 'https://registry.npmjs.org' | |
- run: npm ci | |
- run: npm run build | |
- run: npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.npm_token}} | |
publish-npm-github: | |
name: Publish to github npm - internal | |
needs: [create_changelog_full, create_changelog_partial] | |
env: | |
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
- run: npm ci | |
- run: npm run build | |
- run: | | |
echo @dxfrontier:registry=https://npm.pkg.github.com/ > ~/.npmrc | |
echo "//npm.pkg.github.com/:_authToken=${NPM_TOKEN}" >> ~/.npmrc | |
- run: npm publish |