Skip to content

Merge pull request #29 from DogeLakeDev/cursor/bc-517df327-46d6-4292-… #13

Merge pull request #29 from DogeLakeDev/cursor/bc-517df327-46d6-4292-…

Merge pull request #29 from DogeLakeDev/cursor/bc-517df327-46d6-4292-… #13

Workflow file for this run

name: npm-publish
# 按包 tag 触发 npm 发布,与 release.yml(SEA / v*)互不干扰。
# 示例: git tag @sfmc-bds/sdk@v0.1.0 && git push origin @sfmc-bds/sdk@v0.1.0
# 可发包清单唯一来源: tools/lib/npm-publish-packages.mjs
on:
# GitHub tag glob 对含 / 与 @ 的 scoped tag 极不稳定;用 ** 接住全部 tag,
# 再在 job 级 if 收窄到 @sfmc-bds/(避免误跑 SEA 的 v*)。
push:
tags:
- "**"
workflow_dispatch:
inputs:
tag:
description: "要发布的 tag(如 @sfmc-bds/sdk@v0.1.0)"
# 勿 required:true:改本 workflow 的 branch push 会被 GHA 误评估,
# 缺 inputs 时出现空 jobs + "workflow file issue" failure(见 run 29922880511)。
required: false
type: string
jobs:
publish:
# dispatch 放行;push 仅真实 tag 且 @sfmc-bds/ 前缀才跑。
# ref_type==tag 防御误触的 branch push(skipped 绿,而非空 jobs 红)。
if: >-
github.event_name == 'workflow_dispatch' ||
(github.ref_type == 'tag' && startsWith(github.ref_name, '@sfmc-bds/'))
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
# 与 ootb.yml 对齐: npm-run-all2 等要求 ≥22.22; db-server 需 ≥22.13
node-version: "22.22"
cache: npm
registry-url: https://registry.npmjs.org
- name: parse tag + verify package version
id: meta
env:
# push tag 时用 GITHUB_REF_NAME;手动触发时用 inputs.tag
PUBLISH_TAG: ${{ github.event.inputs.tag || github.ref_name }}
run: node tools/resolve-npm-publish-tag.mjs
- name: skip if already published
if: steps.meta.outputs.already_published == 'true'
run: echo "Already on npm — skip"
- run: npm ci --no-audit --no-fund
if: steps.meta.outputs.already_published != 'true'
- name: build SDK (dependency)
if: steps.meta.outputs.already_published != 'true' && steps.meta.outputs.workspace != '@sfmc-bds/sdk'
run: npm run build --workspace @sfmc-bds/sdk
# --if-present:纯脚本包(如 @sfmc-bds/tools)无编译步骤,勿强制 build(OCP)
- name: build target workspace
if: steps.meta.outputs.already_published != 'true'
run: npm run build --workspace "${{ steps.meta.outputs.workspace }}" --if-present
- name: publish to npm
if: steps.meta.outputs.already_published != 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --workspace "${{ steps.meta.outputs.workspace }}" --access public --provenance