From 7f08b1e7d358697d195f090cfaf22bd8516cff81 Mon Sep 17 00:00:00 2001 From: Kyle Date: Thu, 6 Aug 2026 03:50:31 +0800 Subject: [PATCH 1/2] Add versioned DocC publishing --- .github/workflows/build-docs.yaml | 93 ++++++++++++++++++------------- .gitignore | 3 +- .vdc.json | 34 +++++++++++ README.md | 2 +- 4 files changed, 90 insertions(+), 42 deletions(-) create mode 100644 .vdc.json diff --git a/.github/workflows/build-docs.yaml b/.github/workflows/build-docs.yaml index 7042ae2ca..ec322e7a2 100644 --- a/.github/workflows/build-docs.yaml +++ b/.github/workflows/build-docs.yaml @@ -1,59 +1,72 @@ -name: Generate Documentations +name: Generate Documentation on: push: - branches: ["main"] + branches: [main] + tags: ['[0-9]*.[0-9]*.[0-9]*'] + workflow_dispatch: permissions: contents: read pages: write id-token: write -jobs: - publish-docs: - env: # Environment Variables - SCHEME_NAME: MarkdownView - HOSTING_BASE_PATH: MarkdownView - environment: # Github Page environments - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: macos-latest +concurrency: + group: pages + cancel-in-progress: false +jobs: + build: + name: Build DocC site + runs-on: macos-26 steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Xcode + - uses: actions/checkout@v7 + with: + ref: main + fetch-depth: 0 + + - name: Restore versioned documentation cache + uses: actions/cache@v6 + with: + path: .docs/cache/versioned-docc + key: versioned-docc-${{ runner.os }}-${{ hashFiles('.vdc.json', 'Package.resolved') }}-${{ github.ref_type }}-${{ github.sha }} + restore-keys: | + versioned-docc-${{ runner.os }}-${{ hashFiles('.vdc.json', 'Package.resolved') }}- + versioned-docc-${{ runner.os }}- + + - name: Select Xcode uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: latest + xcode-version: '26.3' - - name: Build DocC archive - id: build-docs - run: | - xcodebuild \ - docbuild \ - -scheme $SCHEME_NAME \ - -destination "platform=macOS" \ - -derivedDataPath build-docs - ARCHIVE=$(find build-docs/Build/Products -name "$SCHEME_NAME.doccarchive" -type d | head -n1) - echo "archive=$ARCHIVE" >> $GITHUB_OUTPUT - - - name: Process DocC archive + - name: Prepare Xcode run: | - xcrun docc process-archive \ - transform-for-static-hosting "${{ steps.build-docs.outputs.archive }}" \ - --output-path docs \ - --hosting-base-path $HOSTING_BASE_PATH + sudo xcode-select -s /Applications/Xcode_26.3.app/Contents/Developer + swift --version + shell: bash - - name: Configure GitHub Pages - uses: actions/configure-pages@v4 + - name: Build versioned DocC site + uses: DocCLab/VersionedDocC@0.0.13 + with: + config: .vdc.json - - name: Upload Pages artifacts - uses: actions/upload-pages-artifact@v3 + - name: Upload Pages artifact + uses: actions/upload-pages-artifact@v5 with: - path: docs + path: .docs/build/versioned-site/MarkdownView - - id: deployment - name: Deploy to GitHub Pages - uses: actions/deploy-pages@v4 + deploy: + name: Deploy DocC site + needs: build + runs-on: ubuntu-latest + permissions: + contents: read + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v5 diff --git a/.gitignore b/.gitignore index 3fd927b9b..3e358e31d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,10 @@ .DS_Store /.build +/.docs/ /Packages /*.xcodeproj xcuserdata/ DerivedData/ .swiftpm/config/registries.json .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata -.netrc \ No newline at end of file +.netrc diff --git a/.vdc.json b/.vdc.json new file mode 100644 index 000000000..4b5ad688e --- /dev/null +++ b/.vdc.json @@ -0,0 +1,34 @@ +{ + "$schema": "https://raw.githubusercontent.com/DocCLab/VersionedDocC/0.0.13/Schema/VersionedDocC.schema.json", + "schemaVersion": 1, + "projectName": "MarkdownView", + "moduleName": "MarkdownView", + "modulePath": "markdownview", + "targetName": "MarkdownView", + "catalogPath": "Sources/MarkdownView/Documentation.docc", + "hostingBasePath": "/MarkdownView", + "defaultVersion": "main", + "releasePolicy": { + "latest": 2, + "development": { + "name": "main", + "ref": "HEAD" + } + }, + "sourceRepository": "https://github.com/LiYanan2004/MarkdownView", + "buildArguments": [ + "--disable-index-store", + "--disable-dependency-cache", + "--disable-prefetching" + ], + "allowedModules": [ + "MarkdownView" + ], + "symbolGraph": { + "minimumAccessLevel": "public", + "skipProtocolImplementations": true + }, + "apiChanges": { + "pageSize": 10 + } +} diff --git a/README.md b/README.md index e4cf80e98..de20e4755 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Powered by [swift-markdown](https://github.com/swiftlang/swift-markdown), fully You can view documentation on: - [main @ Swift Package Index](https://swiftpackageindex.com/LiYanan2004/MarkdownView/main/documentation/MarkdownView) -- [main @ GitHub Pages](https://liyanan2004.github.io/MarkdownView/documentation/markdownview/) +- [main @ GitHub Pages](https://liyanan2004.github.io/MarkdownView/main/documentation/markdownview/) ## Getting Started From 5b4b73cca7de57a899f6c15cf7250a68d7f6a712 Mon Sep 17 00:00:00 2001 From: Kyle Date: Fri, 7 Aug 2026 17:16:41 +0800 Subject: [PATCH 2/2] Restore upstream documentation workflow settings --- .github/workflows/build-docs.yaml | 51 ++++++++++++------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build-docs.yaml b/.github/workflows/build-docs.yaml index ec322e7a2..271605da5 100644 --- a/.github/workflows/build-docs.yaml +++ b/.github/workflows/build-docs.yaml @@ -1,8 +1,8 @@ -name: Generate Documentation +name: Generate Documentations on: push: - branches: [main] + branches: ["main"] tags: ['[0-9]*.[0-9]*.[0-9]*'] workflow_dispatch: @@ -16,11 +16,15 @@ concurrency: cancel-in-progress: false jobs: - build: - name: Build DocC site - runs-on: macos-26 + publish-docs: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: macos-latest + steps: - - uses: actions/checkout@v7 + - name: Checkout repository + uses: actions/checkout@v4 with: ref: main fetch-depth: 0 @@ -34,39 +38,24 @@ jobs: versioned-docc-${{ runner.os }}-${{ hashFiles('.vdc.json', 'Package.resolved') }}- versioned-docc-${{ runner.os }}- - - name: Select Xcode + - name: Set up Xcode uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: '26.3' - - - name: Prepare Xcode - run: | - sudo xcode-select -s /Applications/Xcode_26.3.app/Contents/Developer - swift --version - shell: bash + xcode-version: latest - name: Build versioned DocC site uses: DocCLab/VersionedDocC@0.0.13 with: config: .vdc.json - - name: Upload Pages artifact - uses: actions/upload-pages-artifact@v5 + - name: Configure GitHub Pages + uses: actions/configure-pages@v4 + + - name: Upload Pages artifacts + uses: actions/upload-pages-artifact@v3 with: path: .docs/build/versioned-site/MarkdownView - deploy: - name: Deploy DocC site - needs: build - runs-on: ubuntu-latest - permissions: - contents: read - pages: write - id-token: write - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v5 + - id: deployment + name: Deploy to GitHub Pages + uses: actions/deploy-pages@v4