Skip to content

Commit

Permalink
Setup CI/CD pipeline (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamikhambardzumyan authored Aug 21, 2024
1 parent 19542f5 commit 8cafdf3
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file is define code owners of the repository, more details about the GitHub feature here https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners

- @hamikhambardzumyan
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish to NPM
on:
pull_request:
types:
- closed
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: 📥 Install dependencies
run: npm install
- name: 🔧 Build
run: npm run build
- name: 📦 Publish package on NPM
run: cd dist && npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTOMATION_ACCESS_TOKEN }}
- name: 🚀 Run bump up commit
run: |
git config --global user.name "Hamik Hambardzumyan"
git config --global user.email "hamik.hambardzumyan@softconstruct.com"
npm run bump-up-commit
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"create-icon": "babel-node --config-file ./configs/.babelrc ./scripts/createIcon.js",
"remove-icon": "babel-node --config-file ./configs/.babelrc ./scripts/removeIcon.js",
"update-icon": "",
"mark-as-deprecated": ""
"mark-as-deprecated": "",
"bump-up-commit": "babel-node --config-file ./configs/.babelrc ./scripts/postPublish.js"
},
"files": [
"dist/*"
Expand Down
12 changes: 12 additions & 0 deletions scripts/postPublish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { execCommand } from './utils';
import pgk from '../package.json';

const filesToCommit = 'package.json package-lock.json'; // TODO: add CHANGELOG.md file
const commitMessage = `Bump up library version to ${pgk.version}`;
const tagName = `v${pgk.version}`;
const defaultBranch = 'main';

execCommand(
`git add ${filesToCommit} && git commit -m '${commitMessage}' && git push origin ${defaultBranch}`
);
execCommand(`git tag ${tagName} && git push origin ${tagName}`);

0 comments on commit 8cafdf3

Please sign in to comment.