quick fix #2401
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
| # GitHub CI build pipeline | |
| name: All 4.x Doc JSON Files | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| on: | |
| push: | |
| branches: | |
| - "master" | |
| pull_request: | |
| branches: | |
| - "master" | |
| workflow_dispatch: | |
| inputs: | |
| skip_release: | |
| description: 'Skip uploading to GitHub Release (only upload artifacts)' | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| build: | |
| permissions: | |
| contents: write # Required to create/update releases | |
| strategy: | |
| matrix: | |
| platform: [flutter, ios, macos, electron, unity, rn] | |
| language: [en, cn] | |
| version: [default] | |
| include: | |
| # Add full version for framework platforms with English | |
| - platform: electron | |
| language: en | |
| version: full | |
| - platform: rn | |
| language: en | |
| version: full | |
| - platform: flutter | |
| language: en | |
| version: full | |
| - platform: unity | |
| language: en | |
| version: full | |
| runs-on: ubuntu-latest | |
| name: ${{matrix.platform}} (${{matrix.language}})${{matrix.version == 'full' && ' [full]' || ''}} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up python 3.8 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.8" | |
| - name: Set Language and Working Directory | |
| id: matrix_vars | |
| run: | | |
| # Set language and filename | |
| echo "language=${{matrix.language}}" >> $GITHUB_OUTPUT | |
| # Set filename with version suffix for full version | |
| if [[ "${{matrix.version}}" == "full" ]]; then | |
| echo "filename=${{matrix.platform}}_${{matrix.language}}_ng_full.json" >> $GITHUB_OUTPUT | |
| else | |
| echo "filename=${{matrix.platform}}_${{matrix.language}}_ng.json" >> $GITHUB_OUTPUT | |
| fi | |
| # Set working directory based on platform and language | |
| if [[ "${{matrix.platform}}" == "flutter" || "${{matrix.platform}}" == "electron" || "${{matrix.platform}}" == "unity" || "${{matrix.platform}}" == "rn" ]]; then | |
| # Framework platforms | |
| if [[ "${{matrix.language}}" == "en" ]]; then | |
| echo "working_dir=en-US/dita/RTC-AIDOC-FRAMEWORK" >> $GITHUB_OUTPUT | |
| else | |
| echo "working_dir=dita/RTC-AIDOC-FRAMEWORK" >> $GITHUB_OUTPUT | |
| fi | |
| elif [[ "${{matrix.platform}}" == "ios" || "${{matrix.platform}}" == "macos" ]]; then | |
| # Native platforms | |
| if [[ "${{matrix.language}}" == "en" ]]; then | |
| echo "working_dir=en-US/dita/RTC-AIDOC" >> $GITHUB_OUTPUT | |
| else | |
| echo "working_dir=dita/RTC-AIDOC" >> $GITHUB_OUTPUT | |
| fi | |
| fi | |
| # Set name_groups_file path for framework platforms with English | |
| if [[ "${{matrix.platform}}" == "flutter" || "${{matrix.platform}}" == "electron" || "${{matrix.platform}}" == "unity" || "${{matrix.platform}}" == "rn" ]]; then | |
| if [[ "${{matrix.language}}" == "en" ]]; then | |
| if [[ "${{matrix.version}}" == "full" ]]; then | |
| echo "name_groups_file=config/name_groups_framework_full.json" >> $GITHUB_OUTPUT | |
| else | |
| echo "name_groups_file=config/name_groups_framework.json" >> $GITHUB_OUTPUT | |
| fi | |
| else | |
| echo "name_groups_file=" >> $GITHUB_OUTPUT | |
| fi | |
| else | |
| echo "name_groups_file=" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Get branch name | |
| id: branch-name | |
| uses: tj-actions/branch-names@v7 | |
| - name: Install dependencies | |
| run: | | |
| cd xml2json | |
| python -m pip install --upgrade pip | |
| if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
| - name: Run ${{steps.matrix_vars.outputs.language}} JSON creation | |
| run: | | |
| cd xml2json | |
| if [[ -n "${{steps.matrix_vars.outputs.name_groups_file}}" ]]; then | |
| python xml2json.py --working_dir ../${{steps.matrix_vars.outputs.working_dir}} --platform_tag ${{matrix.platform}}\ | |
| --json_file ${{steps.matrix_vars.outputs.filename}}\ | |
| --language ${{steps.matrix_vars.outputs.language}}\ | |
| --name_groups_file ${{steps.matrix_vars.outputs.name_groups_file}} | |
| else | |
| python xml2json.py --working_dir ../${{steps.matrix_vars.outputs.working_dir}} --platform_tag ${{matrix.platform}}\ | |
| --json_file ${{steps.matrix_vars.outputs.filename}}\ | |
| --language ${{steps.matrix_vars.outputs.language}} | |
| fi | |
| - name: Validate and Order JSON File | |
| run: | | |
| cd xml2json | |
| jq 'sort_by(.'id')' "${{steps.matrix_vars.outputs.filename}}" > "${{steps.matrix_vars.outputs.filename}}.tmp" && mv "${{steps.matrix_vars.outputs.filename}}.tmp" "${{steps.matrix_vars.outputs.filename}}" | |
| - name: Upload ${{matrix.platform}} ${{steps.matrix_vars.outputs.language}} Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{matrix.platform}}_ng_json_template_${{steps.matrix_vars.outputs.language}}${{matrix.version == 'full' && '_full' || ''}}.json | |
| path: xml2json/${{steps.matrix_vars.outputs.filename}} | |
| - name: Upload ${{matrix.platform}} NG ${{steps.matrix_vars.outputs.language}} JSON to release | |
| if: github.ref_name == github.event.repository.default_branch && (github.event_name != 'workflow_dispatch' || github.event.inputs.skip_release != 'true') | |
| uses: svenstaro/upload-release-action@2.6.0 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: xml2json/${{steps.matrix_vars.outputs.filename}} | |
| asset_name: ${{matrix.platform}}_ng_json_template_${{steps.matrix_vars.outputs.language}}${{matrix.version == 'full' && '_full' || ''}}.json | |
| tag: ${{steps.branch-name.outputs.current_branch}}-build | |
| release_name: Release ${{steps.branch-name.outputs.current_branch}}-build | |
| overwrite: true | |
| body: "Template file for automatic comment population." | |
| check_changed_files: | |
| name: Check xml2json updated | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| updated_xml: ${{steps.xml2json-changed.outputs.updated_xml}} | |
| steps: | |
| - name: Get changed files | |
| id: changed-files | |
| uses: tj-actions/changed-files@v37 | |
| - name: Output Bool | |
| id: xml2json-changed | |
| run: echo "updated_xml=${{contains(steps.changed-files.outputs.all_changed_files, 'xml2json/xml2json.py')}}" >> $GITHUB_OUTPUT | |
| # compare: | |
| # name: Compare JSON Files | |
| # needs: [check_changed_files, build] | |
| # if: needs.check_changed_files.outputs.updated_xml | |
| # permissions: | |
| # pull-requests: read | |
| # runs-on: ubuntu-latest | |
| # strategy: | |
| # matrix: | |
| # platform: [flutter, ios, macos, electron, unity, rn] | |
| # language: [en, cn] | |
| # steps: | |
| # - name: Set up python 3.9 | |
| # uses: actions/setup-python@v4 | |
| # with: | |
| # python-version: "3.9" | |
| # - name: Download DocC Archive ⬇️ | |
| # uses: actions/download-artifact@v4 | |
| # with: | |
| # name: ${{matrix.platform}}_ng_json_template_${{matrix.language}}.json | |
| # path: artifacts | |
| # - name: Download current release | |
| # uses: robinraju/release-downloader@v1.8 | |
| # with: | |
| # tag: "master-build" | |
| # fileName: ${{matrix.platform}}_ng_json_template_${{matrix.language}}.json | |
| # - name: Check Sort by ID | |
| # run: | | |
| # # Sorting and moving newly generated JSON | |
| # jq 'sort_by(.'id')' "artifacts/${{matrix.platform}}_${{matrix.language}}_ng.json" > ${{matrix.platform}}_${{matrix.language}}_new.json | |
| # # mv artifacts/${{matrix.platform}}_${{matrix.language}}_ng.json ${{matrix.platform}}_${{matrix.language}}_new.json | |
| # # Sorting and moving latest release JSON | |
| # jq 'sort_by(.'id')' "${{matrix.platform}}_ng_json_template_${{matrix.language}}.json" > ${{matrix.platform}}_${{matrix.language}}_old.json | |
| # - name: Make Diff Compare File | |
| # run: | | |
| # set -e; diff -u ${{matrix.platform}}_${{matrix.language}}_old.json ${{matrix.platform}}_${{matrix.language}}_new.json -U 3 | tee comparison.txt > /dev/null | |
| # - name: Output Diff | |
| # run: | | |
| # if [[ ! -s comparison.txt ]]; then | |
| # echo "No differences found." | |
| # else | |
| # echo """ | |
| # \`\`\`diff | |
| # $(cat comparison.txt) | |
| # \`\`\` | |
| # """ >> $GITHUB_STEP_SUMMARY | |
| # fi |