breaking(TSwitch): 独立加载状态并收敛示例 #1132
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PREVIEW_BUILD | |
| on: | |
| pull_request: | |
| branches: [develop, main] | |
| types: [opened, synchronize, reopened] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| tdesign-flutter-site: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| persist-credentials: false | |
| - name: Prepare preview metadata | |
| id: version | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| VERSION=$(awk '$1 == "version:" { print $2; exit }' tdesign-component/pubspec.yaml) | |
| { | |
| echo "PR_NUMBER=${{ github.event.pull_request.number }}" | |
| echo "VERSION=$VERSION" | |
| echo "BUILD_NUMBER=${{ github.run_number }}" | |
| } > build-env.txt | |
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then | |
| echo "::error::Invalid package version: $VERSION" | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Upload preview metadata | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-env | |
| path: build-env.txt | |
| if-no-files-found: error | |
| retention-days: 5 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v6 | |
| with: | |
| package_json_file: tdesign-site/package.json | |
| - name: Set Node version | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "22" | |
| cache: "pnpm" | |
| cache-dependency-path: "tdesign-site/pnpm-lock.yaml" | |
| - name: Set up Flutter | |
| uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2.23.0 | |
| with: | |
| flutter-version: 3.32.0 | |
| channel: stable | |
| cache: true | |
| - name: Get component dependencies | |
| working-directory: ./tdesign-component | |
| run: flutter pub get | |
| - name: Check Flutter component contracts | |
| working-directory: . | |
| run: node scripts/check-flutter-component-contracts.mjs | |
| - name: Update assets files | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| echo "$VERSION" > "$GITHUB_WORKSPACE/tdesign-component/example/assets/version" | |
| date +%s%3N > "$GITHUB_WORKSPACE/tdesign-component/example/assets/publish_time" | |
| - name: Build site | |
| working-directory: ./tdesign-site | |
| run: | | |
| pnpm ci | |
| pnpm run site | |
| - name: Build and merge Web Demo | |
| working-directory: ./tdesign-component/example | |
| run: | | |
| set -euo pipefail | |
| flutter build web --base-href /flutter/example/ | |
| cd "$GITHUB_WORKSPACE" | |
| mkdir -p tdesign-flutter-web/flutter/example/ | |
| cp -a tdesign-site/_site/. tdesign-flutter-web/ | |
| rm -rf tdesign-flutter-web/assets | |
| INDEX_FILE="$GITHUB_WORKSPACE/tdesign-flutter-web/index.html" | |
| if ! grep -q '<base href="/">' "$INDEX_FILE"; then | |
| sed -i 's|<meta http-equiv="X-UA-Compatible" content="ie=edge">|<meta http-equiv="X-UA-Compatible" content="ie=edge">\n <base href="/">|' "$INDEX_FILE" | |
| fi | |
| sed -i "s|src=\"/flutter/|src=\"flutter/|g; s|href=\"/flutter/|href=\"flutter/|g; s|src='/flutter/|src='flutter/|g; s|href='/flutter/|href='flutter/|g" "$INDEX_FILE" | |
| cp tdesign-site/_site/index.html tdesign-flutter-web/404.html | |
| cp tdesign-site/_site/index.html tdesign-flutter-web/200.html | |
| cp -a tdesign-site/_site/assets tdesign-flutter-web/flutter/assets | |
| cp -a tdesign-component/example/build/web/. tdesign-flutter-web/flutter/example/ | |
| test -f tdesign-flutter-web/index.html | |
| test -f tdesign-flutter-web/flutter/example/index.html | |
| - name: Upload Web artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tdesign-flutter-web | |
| path: ${{ github.workspace }}/tdesign-flutter-web | |
| if-no-files-found: error | |
| retention-days: 5 | |
| - name: Build Flutter APK | |
| working-directory: ./tdesign-component/example | |
| run: flutter build apk -t ./lib/main.dart --release | |
| - name: rename apk | |
| working-directory: ./tdesign-component/example | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| set -euo pipefail | |
| APK_OUTPUT_DIR="$PWD/build/app/outputs/flutter-apk" | |
| APK_PATH="$APK_OUTPUT_DIR/tdesign-flutter-${VERSION}-${GITHUB_RUN_NUMBER}.apk" | |
| mv "$APK_OUTPUT_DIR/app-release.apk" "$APK_PATH" | |
| - name: Upload APK artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tdesign-flutter-apk | |
| path: ${{ github.workspace }}/tdesign-component/example/build/app/outputs/flutter-apk/tdesign-flutter-*.apk | |
| if-no-files-found: error | |
| compression-level: 0 | |
| retention-days: 5 |