From 0997a5ddc564c69021ebcd0b2483c9ce2f936cab Mon Sep 17 00:00:00 2001 From: hopgoldy Date: Mon, 13 Nov 2023 22:25:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20github=20actions=20=E6=89=93=E5=8C=85?= =?UTF-8?q?=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/npm-publish.yml | 31 ---------------------- .github/workflows/release.yml | 43 +++++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 44 insertions(+), 32 deletions(-) delete mode 100644 .github/workflows/npm-publish.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml deleted file mode 100644 index 1c4f48d..0000000 --- a/.github/workflows/npm-publish.yml +++ /dev/null @@ -1,31 +0,0 @@ -# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created -# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages - -name: build-and-publish - -on: - push: - tags: - - '*' -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 20 - - run: npm build - - publish-npm: - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 20 - registry-url: https://registry.npmjs.org/ - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..cd4cbcf --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +name: release + +on: + push: + tags: + - '*' + +jobs: + build-publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + - run: yarn install + - run: yarn run build + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} + + build-publish-docker: + needs: build-publish-npm + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Get Version + uses: rexdefuror/read-package-json@v1.0.5 + + - name: Check docker version + run: docker -v + + - name: Build the Docker image + run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/cube-diary:${{ env.PACKAGE_VERSION }} . + + - name: Log in to Docker Hub + run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Push the Docker image + run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/cube-diary:${{ env.PACKAGE_VERSION }} diff --git a/package.json b/package.json index 20c7832..1ee1770 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cube-diary", - "version": "1.0.2", + "version": "1.0.3", "main": "index.js", "repository": "git@github.com:HoPGoldy/cube-diary.git", "author": "HoPGoldy ",