Browse Source

Merge pull request #30 from dragooncjw/chore/site-deploy

chore: 添加 alpha 版本发包 & 提供 github actions 方式部署官网 & 更改标题
xiamidaxia 10 months ago
parent
commit
b3648733a3

+ 69 - 0
.github/workflows/deploy.yml

@@ -0,0 +1,69 @@
+name: Deploy With Actions
+on:
+  workflow_dispatch
+
+concurrency:
+  group: "gh-pages-branch-workflow" # 唯一标识符,确保只运行一个实例
+  cancel-in-progress: false     # 不取消正在运行的实例,后续触发需要等待当前实例完成
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      pages: write
+      id-token: write
+    steps:
+      - uses: actions/checkout@v3
+        with:
+          fetch-depth: 2
+      - name: Check if branch is main
+        run: |
+          if [ "$GITHUB_REF" != "refs/heads/gh-pages" ]; then
+            echo "Not on gh-pages branch, exiting workflow."
+            exit 1
+          fi
+          echo "On gh-pages branch, continuing workflow."
+      - name: Config Git User
+        run: |
+          git config --local user.name "dragooncjw"
+          git config --local user.email "289056872@qq.com"
+      - uses: actions/setup-node@v3
+        with:
+          node-version: 18
+          registry-url: 'https://registry.npmjs.org/'
+      - 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: Generate docs
+        run: |
+          cd apps/docs
+          npm run docs
+      - name: Copy auto-docs to en
+        run: cp -r apps/docs/src/zh/auto-docs apps/docs/src/en/auto-docs
+      - name: Build Doc site
+        run: |
+          cd apps/docs
+          npm run build
+      - name: Replace docs
+        run: |
+          rm -rf docs
+          mv apps/docs/doc_build docs
+      - name: Upload artifact
+        uses: actions/upload-pages-artifact@v3
+        with:
+          path: docs
+
+  deploy:
+    needs: build
+    runs-on: ubuntu-latest
+    environment:
+      name: github-pages
+      url: ${{ steps.deployment.outputs.page_url }}
+
+    steps:
+      - name: Deploy to GitHub Pages
+        id: deployment
+        uses: actions/deploy-pages@v2
+

+ 83 - 0
.github/workflows/publish-alpha.yml

@@ -0,0 +1,83 @@
+name: Publish
+on:
+  workflow_dispatch
+
+concurrency:
+  group: "main-branch-alpha-publish-workflow" # 唯一标识符,确保只运行一个实例
+  cancel-in-progress: false     # 不取消正在运行的实例,后续触发需要等待当前实例完成
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    permissions:
+      contents: write
+    steps:
+      - uses: actions/checkout@v3
+        with:
+          fetch-depth: 2
+      - name: Set up npm token
+        env:
+          NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
+        run: echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
+      - name: Debug Auth
+        env:
+          NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
+        run: |
+          npm whoami
+      - name: Config Git User
+        run: |
+          git config --local user.name "dragooncjw"
+          git config --local user.email "289056872@qq.com"
+      - name: Get alpha latest npm version
+        id: get_version
+        run: |
+          LATEST_VERSION=$(npm view @flowgram.ai/core version --tag=alpha latest 2>/dev/null)
+          if [ -n "$LATEST_VERSION" ]; then
+            echo "Using existing version: $LATEST_VERSION"
+          else
+            LATEST_VERSION="0.1.0-alpha.1"
+            echo "Version not found, using default: $LATEST_VERSION"
+          fi
+          echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
+      # https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
+      - name: Echo version
+        run: |
+          echo "The package version is : $LATEST_VERSION"
+          echo "The package output version is ${{ steps.get_version.outputs.version }}"
+      - uses: actions/setup-node@v3
+        with:
+          node-version: 18
+          registry-url: 'https://registry.npmjs.org/'
+      - name: Rush Install
+        run: node common/scripts/install-run-rush.js install
+      - name: Rush build
+        run: node common/scripts/install-run-rush.js build
+      # version bump 之前保证是远端最新的,这样无需 commit package.json version
+      - name: Sync versions
+        run: |
+          echo "[
+            {
+              \"policyName\": \"publishPolicy\",
+              \"definitionName\": \"lockStepVersion\",
+              \"version\": \"$LATEST_VERSION\",
+              \"nextBump\": \"prerelease\"
+            }
+          ]" > common/config/rush/version-policies.json
+      - name: Version Bump
+        run: node common/scripts/install-run-rush.js version --bump --version-policy publishPolicy
+      - name: Publish
+        env:
+          NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
+        run: node common/scripts/install-run-rush.js publish --include-all -p --tag alpha
+      - name: Get new Version
+        id: get_new_version
+        run: |
+          NEW_VERSION=$(npm view @flowgram.ai/core version --tag=alpha latest)
+          echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
+      - name: Create tag
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          git tag "v$NEW_VERSION"
+          git push origin "v$NEW_VERSION"
+

+ 1 - 1
apps/docs/src/en/index.md

@@ -3,7 +3,7 @@ pageType: home
 
 hero:
   name: FlowGram.AI
-  text: Programmatic Flow Building Engine
+  text: Build Flow Engine with Plugins
   tagline: High Performance, Scalable, Customizable
   actions:
     - theme: brand

+ 1 - 1
apps/docs/src/zh/index.md

@@ -3,7 +3,7 @@ pageType: home
 
 hero:
   name: FlowGram.AI
-  text: 程序化构建流程引擎
+  text: 插件化构建流程引擎
   tagline: 高性能,可扩展,可定制
   actions:
     - theme: brand