Skip to content

Commit e476f49

Browse files
committed
update npm&github auth26
1 parent 93875b5 commit e476f49

File tree

1 file changed

+16
-82
lines changed

1 file changed

+16
-82
lines changed

.github/workflows/release.yml

Lines changed: 16 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -33,88 +33,6 @@ jobs:
3333
echo "🔖 Detected stable release, using npm tag: latest"
3434
echo "npm_tag=latest" >> $GITHUB_OUTPUT
3535
fi
36-
publish_spec_only:
37-
runs-on: ubuntu-latest
38-
permissions:
39-
id-token: write
40-
contents: read
41-
steps:
42-
- name: Checkout
43-
uses: actions/checkout@v4
44-
45-
# 1. 先打印原始 env(可选调试)
46-
- name: Show raw env
47-
run: |
48-
echo "== RAW env NODE_AUTH_TOKEN =="
49-
echo "NODE_AUTH_TOKEN=${NODE_AUTH_TOKEN:-<empty>}"
50-
echo "NPM_TOKEN=${NPM_TOKEN:-<empty>}"
51-
echo "NPM_CONFIG_USERCONFIG=${NPM_CONFIG_USERCONFIG:-<empty>}"
52-
env | grep -i npm || echo "no npm-related env vars"
53-
54-
# 2. 设置 Node(可能会注入 token)
55-
- name: Setup Node
56-
uses: actions/setup-node@v4
57-
with:
58-
node-version: 20
59-
registry-url: https://registry.npmjs.org/
60-
always-auth: true
61-
- name: Upgrade npm
62-
run: |
63-
npm install -g npm@latest
64-
echo "npm after upgrade:"
65-
npm -v
66-
67-
68-
# 3. 再清理 token(关键:在 setup-node 之后、任何 npm 操作之前)
69-
- name: Disable npm token & clear npmrc
70-
# 这里不要用 `env:`,只写 run
71-
run: |
72-
echo "== Before cleanup =="
73-
echo "NODE_AUTH_TOKEN=${NODE_AUTH_TOKEN:-<empty>}"
74-
echo "NPM_TOKEN=${NPM_TOKEN:-<empty>}"
75-
echo "NPM_CONFIG_USERCONFIG=${NPM_CONFIG_USERCONFIG:-<empty>}"
76-
77-
# 清空环境变量
78-
unset NODE_AUTH_TOKEN
79-
unset NPM_TOKEN
80-
81-
# 覆盖当前 userconfig .npmrc,防止里面有 _authToken
82-
if [ -n "${NPM_CONFIG_USERCONFIG:-}" ]; then
83-
echo "# cleaned by CI, no auth token" > "$NPM_CONFIG_USERCONFIG"
84-
fi
85-
86-
echo "== After cleanup =="
87-
echo "NODE_AUTH_TOKEN=${NODE_AUTH_TOKEN:-<empty>}"
88-
echo "NPM_TOKEN=${NPM_TOKEN:-<empty>}"
89-
echo "NPM_CONFIG_USERCONFIG=${NPM_CONFIG_USERCONFIG:-<empty>}"
90-
91-
# 4. 再确认一次(debug)
92-
- name: Debug env
93-
run: |
94-
echo "== Token related env =="
95-
echo "NPM_TOKEN=${NPM_TOKEN:-<empty>}"
96-
echo "NODE_AUTH_TOKEN=${NODE_AUTH_TOKEN:-<empty>}"
97-
echo "NPM_CONFIG_USERCONFIG=${NPM_CONFIG_USERCONFIG:-<empty>}"
98-
env | grep -i npm || echo "no npm-related env vars"
99-
100-
- name: Show Node & npm version
101-
run: |
102-
node -v
103-
npm -v
104-
105-
- name: Install deps & build
106-
working-directory: specification
107-
run: |
108-
npm install
109-
npm run build --if-present
110-
111-
- name: Set version and publish
112-
working-directory: specification
113-
run: |
114-
VERSION=$(node -p "require('./package.json').version")
115-
echo "Version in package.json: $VERSION"
116-
npm publish --access public --loglevel verbose
117-
11836
11937
# 2. 发布 specification
12038
publish_spec:
@@ -130,6 +48,14 @@ jobs:
13048
with:
13149
node-version: 18
13250
registry-url: https://registry.npmjs.org/
51+
52+
- name: Upgrade npm
53+
run: |
54+
npm install -g npm@latest
55+
echo "npm after upgrade:"
56+
npm -v
57+
echo "node after upgrade:"
58+
node -v
13359
13460
- name: Publish specification
13561
working-directory: specification
@@ -214,6 +140,14 @@ jobs:
214140
with:
215141
node-version: 18
216142
registry-url: https://registry.npmjs.org/
143+
144+
- name: Upgrade npm
145+
run: |
146+
npm install -g npm@latest
147+
echo "npm after upgrade:"
148+
npm -v
149+
echo "node after upgrade:"
150+
node -v
217151
218152
- name: Check and Publish
219153
working-directory: parser-Java-Js

0 commit comments

Comments
 (0)