@underdog-protocol/ui setup #7
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
name: Node.js Package CI/CD | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
release: | |
types: [created] | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install dependencies | |
run: yarn install | |
- name: Bump package version | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
run: | | |
yarn version --patch --no-git-tag-version | |
echo "NEW_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV | |
- name: Create and push git tag for new version | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
run: | | |
git config --global user.name 'github-actions' | |
git config --global user.email 'github-actions@github.com' | |
git commit -am "chore: bump version to ${{ env.NEW_VERSION }}" | |
git tag "v${{ env.NEW_VERSION }}" | |
git push https://${{ secrets.ORG_GITHUB_PAT }}@github.com/UnderdogProtocol/ui.git "v${{ env.NEW_VERSION }}" --force | |
git push https://${{ secrets.ORG_GITHUB_PAT }}@github.com/UnderdogProtocol/ui.git --force | |
env: | |
ORG_GITHUB_PAT: ${{ secrets.ORG_GITHUB_PAT }} | |
- name: Build | |
run: yarn build | |
- name: Publish to npm | |
run: yarn publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |