Files
bytedance--flowgram.ai/.github/workflows/publish.yml
T
wehub-resource-sync 0232b4e2bb
CI / build (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:09:51 +08:00

197 lines
6.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Publish
on:
workflow_dispatch:
inputs:
publish-type:
description: "发布类型"
required: true
type: choice
options:
- sdk-patch
- sdk-minor
- sdk-alpha
- sdk-to-version
- app-patch
- app-to-version
sdk-version:
description: "指定版本号(仅 sdk-to-version / app-to-version 时需要,e.g. 1.0.0"
required: false
default: ""
concurrency:
group: "publish-workflow"
cancel-in-progress: false
permissions:
id-token: write
contents: read
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Config Git User
run: |
git config --local user.name "dragooncjw"
git config --local user.email "289056872@qq.com"
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Upgrade npm for OIDC support
run: |
npm install -g npm@latest
npm --version
- name: Determine version and publish parameters
id: params
run: |
PUBLISH_TYPE="${{ github.event.inputs.publish-type }}"
INPUT_VERSION="${{ github.event.inputs.sdk-version }}"
case "$PUBLISH_TYPE" in
sdk-patch)
LATEST_VERSION=$(npm view @flowgram.ai/core version --tag=latest latest)
POLICY_NAME="publishPolicy"
NEXT_BUMP="patch"
NPM_TAG="latest"
USE_OVERRIDE="false"
;;
sdk-minor)
LATEST_VERSION=$(npm view @flowgram.ai/core version --tag=latest latest)
POLICY_NAME="publishPolicy"
NEXT_BUMP="minor"
NPM_TAG="latest"
USE_OVERRIDE="false"
;;
sdk-alpha)
LATEST_VERSION=$(npm view @flowgram.ai/core version --tag=alpha latest 2>/dev/null || true)
if [ -z "$LATEST_VERSION" ]; then
LATEST_VERSION="0.1.0-alpha.1"
echo "Version not found, using default: $LATEST_VERSION"
fi
POLICY_NAME="publishPolicy"
NEXT_BUMP="prerelease"
NPM_TAG="alpha"
USE_OVERRIDE="true"
;;
sdk-to-version)
if [ -z "$INPUT_VERSION" ]; then
echo "::error::sdk-version is required for sdk-to-version"
exit 1
fi
LATEST_VERSION="$INPUT_VERSION"
POLICY_NAME="publishPolicy"
NEXT_BUMP=""
NPM_TAG="latest"
USE_OVERRIDE="true"
;;
app-patch)
LATEST_VERSION=$(npm view @flowgram.ai/demo-fixed-layout version --tag=latest latest)
POLICY_NAME="appPolicy"
NEXT_BUMP="patch"
NPM_TAG="latest"
USE_OVERRIDE="false"
;;
app-to-version)
if [ -z "$INPUT_VERSION" ]; then
echo "::error::sdk-version is required for app-to-version"
exit 1
fi
LATEST_VERSION="$INPUT_VERSION"
POLICY_NAME="appPolicy"
NEXT_BUMP=""
NPM_TAG="latest"
USE_OVERRIDE="true"
;;
esac
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
echo "POLICY_NAME=$POLICY_NAME" >> $GITHUB_ENV
echo "NEXT_BUMP=$NEXT_BUMP" >> $GITHUB_ENV
echo "NPM_TAG=$NPM_TAG" >> $GITHUB_ENV
echo "USE_OVERRIDE=$USE_OVERRIDE" >> $GITHUB_ENV
echo "PUBLISH_TYPE=$PUBLISH_TYPE" >> $GITHUB_ENV
- name: Echo version
run: |
echo "Publish type: $PUBLISH_TYPE"
echo "The package version is: $LATEST_VERSION"
echo "Policy: $POLICY_NAME, Next bump: $NEXT_BUMP, Tag: $NPM_TAG"
- name: Rush Install
run: node common/scripts/install-run-rush.js install
- name: Rush build
run: node common/scripts/install-run-rush.js build
- name: Sync versions
run: |
if [ -n "$NEXT_BUMP" ]; then
echo "[
{
\"policyName\": \"$POLICY_NAME\",
\"definitionName\": \"lockStepVersion\",
\"version\": \"$LATEST_VERSION\",
\"nextBump\": \"$NEXT_BUMP\"
}
]" > common/config/rush/version-policies.json
else
echo "[
{
\"policyName\": \"$POLICY_NAME\",
\"definitionName\": \"lockStepVersion\",
\"version\": \"$LATEST_VERSION\"
}
]" > common/config/rush/version-policies.json
fi
- name: Version Bump (override)
if: env.USE_OVERRIDE == 'true'
run: node common/scripts/install-run-rush.js version --ensure-version-policy --override-version=$LATEST_VERSION --version-policy=$POLICY_NAME
- name: Version Bump
if: env.USE_OVERRIDE == 'false'
run: node common/scripts/install-run-rush.js version --bump --version-policy $POLICY_NAME
# For alpha, we need both override and bump
- name: Version Bump (alpha additional bump)
if: env.PUBLISH_TYPE == 'sdk-alpha'
run: node common/scripts/install-run-rush.js version --bump --version-policy $POLICY_NAME
- name: Publish
run: node common/scripts/install-run-rush.js publish --include-all -p --tag $NPM_TAG
- name: Print npm debug logs on failure
if: failure()
run: |
echo "=== npm debug logs ==="
find "$GITHUB_WORKSPACE/common/temp/publish-home/.npm/_logs" -name '*.log' -exec echo "--- {} ---" \; -exec cat {} \; 2>/dev/null || echo "No npm debug logs found"
- name: Get new Version
id: get_new_version
if: env.PUBLISH_TYPE != 'app-patch'
run: |
if [ "$NPM_TAG" = "alpha" ]; then
NEW_VERSION=$(npm view @flowgram.ai/core version --tag=alpha latest)
else
NEW_VERSION=$(npm view @flowgram.ai/core version --tag=latest latest)
fi
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Create tag
if: env.PUBLISH_TYPE != 'app-patch'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag "v$NEW_VERSION"
git push origin "v$NEW_VERSION"