From 7c330ffa4ee8978282b8c12fc15652db819e24b7 Mon Sep 17 00:00:00 2001 From: zkz098 Date: Fri, 1 Nov 2024 20:55:42 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20dev=E6=B5=8B=E8=AF=95=E7=89=88=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E5=B7=A5=E4=BD=9C=E6=B5=81=20[publish=20dev]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev-version.yml | 31 +++++++++++++++++++++++++++++++ .github/workflows/npm-publish.yml | 3 +-- package.json | 4 ++-- toolbox/dev-version.mjs | 14 ++++++++++++++ 4 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/dev-version.yml create mode 100644 toolbox/dev-version.mjs diff --git a/.github/workflows/dev-version.yml b/.github/workflows/dev-version.yml new file mode 100644 index 0000000..8d91e77 --- /dev/null +++ b/.github/workflows/dev-version.yml @@ -0,0 +1,31 @@ +name: Nodejs Package on Dev Version + +on: + push: + branches: + - develop + +jobs: + publish: + if: "contains(github.event.head_commit.message, '[publish dev]')" + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + + - name: Install dependencies + run: npm install pnpm -g + + - name: Build TypeScript files + run: | + pnpm install + node ./toolbox/dev-version.js + pnpm run build + + - run: npm publish --tag dev + env: + NODE_AUTH_TOKEN: ${{ secrets.npm_token }} diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 31c5a0d..a2f6373 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -21,7 +21,6 @@ jobs: - name: Build TypeScript files run: | pnpm install - echo "NO_DEPS_HOIST=true" >> $GITHUB_ENV pnpm run build - run: npm publish @@ -29,7 +28,7 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.npm_token }} - - run: npm publish --tag dev + - run: npm publish --tag beta if: "github.event.release.prerelease" env: NODE_AUTH_TOKEN: ${{ secrets.npm_token }} diff --git a/package.json b/package.json index 53c50c2..c4e9bc2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-shokax", - "version": "0.4.16", + "version": "0.5.0", "description": "a hexo theme based on shoka", "main": "index.js", "repository": "https://github.com/theme-shoka-x/hexo-theme-shokaX", @@ -65,4 +65,4 @@ "object.values": "npm:@nolyfill/object.values@latest" } } -} +} \ No newline at end of file diff --git a/toolbox/dev-version.mjs b/toolbox/dev-version.mjs new file mode 100644 index 0000000..0ef0de3 --- /dev/null +++ b/toolbox/dev-version.mjs @@ -0,0 +1,14 @@ +import fs from 'node:fs'; +import { execSync } from 'child_process'; + +const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf-8')); +const currentVersion = packageJson.version; + +const shortHash = execSync('git rev-parse --short HEAD').toString().trim(); + +const newVersion = `${currentVersion}-dev-${shortHash}`; + +packageJson.version = newVersion; +fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 4)); + +console.log(`Updated package version to ${newVersion}`);