mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-02-04 12:53:10 +00:00
revert: revive back workflow
This commit is contained in:
parent
598dd8bd34
commit
2d3f15f0e5
32
.github/workflows/npm.yml
vendored
32
.github/workflows/npm.yml
vendored
@ -5,8 +5,6 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'package.json'
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
workflow_dispatch:
|
||||
@ -19,52 +17,26 @@ jobs:
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- name: Check if version has changed
|
||||
id: version_check
|
||||
run: |
|
||||
# 获取当前提交中的版本号
|
||||
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
||||
echo "Current version: $CURRENT_VERSION"
|
||||
|
||||
# 获取上一个提交中的版本号
|
||||
git fetch origin main --depth=1
|
||||
PREVIOUS_COMMIT=$(git rev-parse HEAD~1)
|
||||
PREVIOUS_VERSION=$(git show $PREVIOUS_COMMIT:package.json | node -p "require('/dev/stdin').version" 2>/dev/null || echo "")
|
||||
echo "Previous version: $PREVIOUS_VERSION"
|
||||
|
||||
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
|
||||
echo "Version has changed from $PREVIOUS_VERSION to $CURRENT_VERSION"
|
||||
echo "version_changed=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "Version has not changed"
|
||||
echo "version_changed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
# 发布到 NPM Registry
|
||||
- name: Setup Node.js for NPM
|
||||
if: steps.version_check.outputs.version_changed == 'true'
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 20
|
||||
registry-url: 'https://registry.npmjs.org/'
|
||||
- name: Install dependencies
|
||||
if: steps.version_check.outputs.version_changed == 'true'
|
||||
run: npm install
|
||||
- run: npm install
|
||||
- name: Publish to NPM
|
||||
if: steps.version_check.outputs.version_changed == 'true'
|
||||
run: npm publish --access public
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
# 发布到 GitHub Packages
|
||||
- name: Setup Node.js for GitHub Packages
|
||||
if: steps.version_check.outputs.version_changed == 'true'
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 20
|
||||
registry-url: 'https://npm.pkg.github.com'
|
||||
- name: Publish to GitHub Packages
|
||||
if: steps.version_check.outputs.version_changed == 'true'
|
||||
run: npm publish --access public
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ github.token }}
|
||||
NODE_AUTH_TOKEN: ${{ github.token }}
|
||||
Loading…
x
Reference in New Issue
Block a user