Skip to content

Commit

Permalink
feat(semantic-release): set up Semantic-Release for Auto Package Buil…
Browse files Browse the repository at this point in the history
…d & Release

- We setup the semantic-release package and configured our repo to use Conventional Commits using
Commitizen. We Configured semantic-release to release the build automatically to NPM and GitHub,
Generate Release Notes, Update Changelog file, and maintain the Git Tags / Semantic Versioning of
the Package.
- We also setup github Worlflow for the auto NPM release process for semantic-release

re #1
  • Loading branch information
arijitcodes committed Nov 7, 2023
1 parent 992dd45 commit b1d148a
Show file tree
Hide file tree
Showing 8 changed files with 14,580 additions and 2,122 deletions.
60 changes: 60 additions & 0 deletions .czrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"path": "./node_modules/cz-conventional-changelog",
"types": {
"feat": {
"description": "A new feature",
"title": "Features",
"emoji": "✨"
},
"fix": {
"description": "A bug fix",
"title": "Bug Fixes",
"emoji": "🐛"
},
"docs": {
"description": "Documentation only changes",
"title": "Documentation",
"emoji": "📚"
},
"style": {
"description": "Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",
"title": "Styles",
"emoji": "🎨"
},
"refactor": {
"description": "A code change that neither fixes a bug nor adds a feature",
"title": "Code Refactoring",
"emoji": "♻️"
},
"perf": {
"description": "A code change that improves performance",
"title": "Performance Improvements",
"emoji": "🚀"
},
"test": {
"description": "Adding missing tests or correcting existing tests",
"title": "Tests",
"emoji": "🚨"
},
"build": {
"description": "Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)",
"title": "Builds",
"emoji": "🛠"
},
"ci": {
"description": "Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)",
"title": "Continuous Integrations",
"emoji": "⚙️"
},
"chore": {
"description": "Other changes that don't modify src or test files",
"title": "Chores",
"emoji": "♻️"
},
"revert": {
"description": "Reverts a previous commit",
"title": "Reverts",
"emoji": "⏪️"
}
}
}
64 changes: 64 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: NodeJS CI

on:
push:
branches: [main]
pull_request:
branches: "*"

permissions:
contents: read # for checkout

jobs:
# quality:
# runs-on: ${{ matrix.os }}

# strategy:
# matrix:
# node-version: [10.x, 12.x, 14.x, 15.x]
# os: [ubuntu-latest, windows-latest]
# # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

# steps:
# - uses: actions/checkout@v2
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v2
# with:
# node-version: ${{ matrix.node-version }}
# - run: npm ci
# - run: npm test

release:
runs-on: ${{ matrix.os }}
if: ${{ github.ref == 'refs/heads/main' }}
# needs: [quality]

permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance

strategy:
matrix:
node-version: [18.x]
# os: [ubuntu-22.04, windows-latest]
os: [ubuntu-22.04]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use NodeJS ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Installing Dependencies
run: npm ci
- name: Release
run: npm run semantic-release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
configs/commit.hbs
Empty file added CHANGELOG.md
Empty file.
73 changes: 73 additions & 0 deletions configs/commit.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{#if scope}} **{{scope}}:**
{{~/if}} {{#if subject}}
{{~subject}}
{{~else}}
{{~header}}
{{~/if}}

{{~!-- commit link --}} {{#if @root.linkReferences~}}
([{{shortHash}}](
{{~#if @root.repository}}
{{~#if @root.host}}
{{~@root.host}}/
{{~/if}}
{{~#if @root.owner}}
{{~@root.owner}}/
{{~/if}}
{{~@root.repository}}
{{~else}}
{{~@root.repoUrl}}
{{~/if}}/
{{~@root.commit}}/{{hash}}))
{{~else}}
{{~shortHash}}
{{~/if}}

{{~!-- commit references --}}
{{~#if references~}}
, closes
{{~#each references}} {{#if @root.linkReferences~}}
[
{{~#if this.owner}}
{{~this.owner}}/
{{~/if}}
{{~this.repository}}#{{this.issue}}](
{{~#if @root.repository}}
{{~#if @root.host}}
{{~@root.host}}/
{{~/if}}
{{~#if this.repository}}
{{~#if this.owner}}
{{~this.owner}}/
{{~/if}}
{{~this.repository}}
{{~else}}
{{~#if @root.owner}}
{{~@root.owner}}/
{{~/if}}
{{~@root.repository}}
{{~/if}}
{{~else}}
{{~@root.repoUrl}}
{{~/if}}/
{{~@root.issue}}/{{this.issue}})
{{~else}}
{{~#if this.owner}}
{{~this.owner}}/
{{~/if}}
{{~this.repository}}#{{this.issue}}
{{~/if}}{{/each}}
{{~/if}}

{{~#if body}}
{{{{raw}}}}

{{{{/raw}}}}

{{body}} <br/><br/>

{{~/if}}

{{{{raw}}}}

{{{{/raw}}}}
Loading

0 comments on commit b1d148a

Please sign in to comment.