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}`);