update version #4
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: | |
on: | |
push: | |
branches: | |
- 'main' | |
release: | |
types: [published] | |
jobs: | |
build-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | |
- name: Build and Push to Docker Hub | |
uses: docker/build-push-action@v5 | |
id: docker_build_client | |
with: | |
context: . | |
file: ./Dockerfile | |
builder: ${{steps.buildx.outputs.name}} | |
push: true | |
tags: dialoguebot/chatbox:latest\ | |
publish-package: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Authenticate to npm registry | |
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
- name: Install Dependencies | |
run: npm install | |
- name: Extract version from tag | |
if: startsWith(github.ref, 'refs/tags/') | |
id: extract_version | |
run: echo "::set-output name=VERSION::${GITHUB_REF#refs/tags/v}" | |
- name: Update package.json version | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
VERSION=$(echo "${{ steps.extract_version.outputs.VERSION }}" | sed 's/^v//') | |
npm version $VERSION --no-git-tag-version | |
- name: Commit version bump if tag | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
git config --global user.name 'hoanghuy' | |
git config --global user.email '[email protected]' | |
git add package.json | |
git commit -m "Bump version to ${{ steps.extract_version.outputs.VERSION }}" | |
git push origin HEAD:${GITHUB_REF#refs/heads/} | |
- name: Publish Package | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |