|
| 1 | +# |
| 2 | +# Licensed under the Apache License v2.0 with LLVM Exceptions. |
| 3 | +# See https://llvm.org/LICENSE.txt for license information. |
| 4 | +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 5 | +# |
| 6 | +# Copyright (c) 2026 Alan de Freitas (alandefreitas@gmail.com) |
| 7 | +# |
| 8 | +# Official repository: https://github.com/cppalliance/mrdocs |
| 9 | +# |
| 10 | +# Single-runner publishing step that runs only on push events to |
| 11 | +# develop, master, or tags. Renders the full multi-ref Antora site, |
| 12 | +# publishes the website to GitHub Pages and the dev-websites rsync |
| 13 | +# target, and creates one consolidated GitHub Release containing the |
| 14 | +# packages from all three platforms. |
| 15 | + |
| 16 | +name: Publish |
| 17 | + |
| 18 | +on: |
| 19 | + workflow_call: |
| 20 | + inputs: |
| 21 | + submatrix: |
| 22 | + description: 'JSON-encoded releases submatrix from cpp-matrix (for platform names)' |
| 23 | + type: string |
| 24 | + required: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + publish: |
| 28 | + name: Publish |
| 29 | + runs-on: ubuntu-24.04 |
| 30 | + permissions: |
| 31 | + contents: write |
| 32 | + steps: |
| 33 | + - name: Install packages |
| 34 | + uses: alandefreitas/cpp-actions/package-install@v1.9.4 |
| 35 | + with: |
| 36 | + apt-get: rsync git |
| 37 | + |
| 38 | + - name: Clone MrDocs |
| 39 | + uses: actions/checkout@v4 |
| 40 | + with: |
| 41 | + fetch-depth: 0 |
| 42 | + fetch-tags: true |
| 43 | + |
| 44 | + - name: Install Node.js |
| 45 | + uses: actions/setup-node@v4 |
| 46 | + with: |
| 47 | + node-version: '20' |
| 48 | + |
| 49 | + - name: Download all platform packages |
| 50 | + uses: actions/download-artifact@v4 |
| 51 | + with: |
| 52 | + pattern: release-packages-* |
| 53 | + path: packages |
| 54 | + merge-multiple: true |
| 55 | + |
| 56 | + - name: Download website (Linux) |
| 57 | + uses: actions/download-artifact@v4 |
| 58 | + with: |
| 59 | + name: Website Linux |
| 60 | + path: build/website |
| 61 | + |
| 62 | + - name: Download demos (Linux) |
| 63 | + uses: actions/download-artifact@v4 |
| 64 | + with: |
| 65 | + name: demos${{ (contains(fromJSON('["master", "develop"]'), github.ref_name) && format('-{0}', github.ref_name)) || '' }}-Linux |
| 66 | + path: . |
| 67 | + |
| 68 | + - name: Unpack demos |
| 69 | + run: | |
| 70 | + set -euo pipefail |
| 71 | + mkdir -p demos |
| 72 | + # generate-demos.sh writes a bzip2 archive despite the .gz suffix; |
| 73 | + # -xaf auto-detects compression so we don't have to depend on the |
| 74 | + # script keeping the same algorithm. |
| 75 | + tar -xaf demos.tar.gz -C demos |
| 76 | +
|
| 77 | + - name: Ensure all refs for Antora |
| 78 | + run: | |
| 79 | + set -euo pipefail |
| 80 | + # Make sure Antora sees every branch and tag from the upstream repo, |
| 81 | + # regardless of who triggered the workflow. |
| 82 | + git remote set-url origin https://github.com/cppalliance/mrdocs.git |
| 83 | + git fetch --prune --prune-tags origin \ |
| 84 | + '+refs/heads/*:refs/remotes/origin/*' \ |
| 85 | + '+refs/tags/*:refs/tags/*' |
| 86 | +
|
| 87 | + # Antora's playbook references `./ui/build/ui-bundle.zip` (relative to |
| 88 | + # docs/), so we need the gulp-built bundle in this runner. We could pass |
| 89 | + # it as an artifact from Documentation/Linux, but rebuilding here is |
| 90 | + # cheap and keeps Publish self-contained. |
| 91 | + - name: Generate Antora UI |
| 92 | + working-directory: docs/ui |
| 93 | + env: |
| 94 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + run: | |
| 96 | + npm ci |
| 97 | + npx gulp |
| 98 | +
|
| 99 | + - name: Generate Remote Documentation |
| 100 | + working-directory: docs |
| 101 | + run: | |
| 102 | + GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" |
| 103 | + export GH_TOKEN |
| 104 | + set -x |
| 105 | + npm ci |
| 106 | + npx antora --clean --fetch antora-playbook.yml --log-level=debug |
| 107 | + mkdir -p ../build/website/docs |
| 108 | + cp -vr build/site/* ../build/website/docs |
| 109 | +
|
| 110 | + - name: Download previous demos (tags only) |
| 111 | + if: startsWith(github.ref, 'refs/tags/') |
| 112 | + id: download-prev-demos |
| 113 | + uses: actions/download-artifact@v4 |
| 114 | + continue-on-error: true |
| 115 | + with: |
| 116 | + name: demos-develop-Linux |
| 117 | + path: demos-previous |
| 118 | + |
| 119 | + - name: Compare demos (tags only) |
| 120 | + if: startsWith(github.ref, 'refs/tags/') && steps.download-prev-demos.outputs.cache-hit == 'true' |
| 121 | + id: compare-demos |
| 122 | + run: .github/scripts/compare-demos.sh |
| 123 | + |
| 124 | + - name: Upload demo diff (tags only) |
| 125 | + if: startsWith(github.ref, 'refs/tags/') && steps.compare-demos.outputs.diff == 'true' |
| 126 | + uses: actions/upload-artifact@v4 |
| 127 | + with: |
| 128 | + name: demos-diff |
| 129 | + path: demos-diff |
| 130 | + retention-days: 30 |
| 131 | + |
| 132 | + - name: Publish website to GitHub Pages |
| 133 | + uses: peaceiris/actions-gh-pages@v3 |
| 134 | + with: |
| 135 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 136 | + publish_dir: build/website |
| 137 | + force_orphan: true |
| 138 | + |
| 139 | + - name: Publish website to dev-websites |
| 140 | + env: |
| 141 | + SSH_AUTH_SOCK: /tmp/ssh_agent.sock |
| 142 | + run: | |
| 143 | + set -euvx |
| 144 | + mkdir -p /home/runner/.ssh |
| 145 | + ssh-keyscan dev-websites.cpp.al >> /home/runner/.ssh/known_hosts |
| 146 | + chmod 600 /home/runner/.ssh/known_hosts |
| 147 | + echo "${{ secrets.DEV_WEBSITES_SSH_KEY }}" > /home/runner/.ssh/github_actions |
| 148 | + chmod 600 /home/runner/.ssh/github_actions |
| 149 | + ssh-agent -a $SSH_AUTH_SOCK > /dev/null |
| 150 | + ssh-add /home/runner/.ssh/github_actions |
| 151 | +
|
| 152 | + rsyncopts=(--recursive --delete --links --times --chmod=D0755,F0755 --compress --compress-choice=zstd --rsh="ssh -o StrictHostKeyChecking=no" --human-readable) |
| 153 | + website_dir="ubuntu@dev-websites.cpp.al:/var/www/mrdox.com" |
| 154 | + demo_dir="$website_dir/demos/${{ github.ref_name }}" |
| 155 | +
|
| 156 | + time rsync "${rsyncopts[@]}" --exclude=demos/ --exclude=roadmap/ $(pwd)/build/website/ "$website_dir"/ |
| 157 | + time rsync "${rsyncopts[@]}" $(pwd)/demos/ "$demo_dir"/ |
| 158 | +
|
| 159 | + - name: Create changelog |
| 160 | + uses: alandefreitas/cpp-actions/create-changelog@v1.9.4 |
| 161 | + with: |
| 162 | + output-path: CHANGELOG.md |
| 163 | + thank-non-regular: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 164 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 165 | + limit: 150 |
| 166 | + update-summary: true |
| 167 | + |
| 168 | + # For non-tag publishes (develop-release and master-release rolling |
| 169 | + # releases), strip the project version out of the package filenames |
| 170 | + # and insert the branch name instead. Subsequent pushes overwrite the |
| 171 | + # existing GitHub-release assets cleanly. Tag releases keep their |
| 172 | + # versioned filenames. |
| 173 | + - name: Rebrand branch packages |
| 174 | + if: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 175 | + run: | |
| 176 | + set -euxo pipefail |
| 177 | + cd packages |
| 178 | + for f in MrDocs-*.*.*-*.*; do |
| 179 | + [ -e "$f" ] || continue |
| 180 | + new=$(echo "$f" | sed -E 's|^MrDocs-[0-9]+\.[0-9]+\.[0-9]+-|MrDocs-${{ github.ref_name }}-|') |
| 181 | + mv -- "$f" "$new" |
| 182 | + done |
| 183 | +
|
| 184 | + - name: Create consolidated GitHub Release |
| 185 | + uses: softprops/action-gh-release@v2 |
| 186 | + with: |
| 187 | + files: packages/MrDocs-*-*.* |
| 188 | + fail_on_unmatched_files: true |
| 189 | + name: ${{ github.ref_name || github.ref }} |
| 190 | + tag_name: ${{ github.ref_name || github.ref }}${{ ((!startsWith(github.ref, 'refs/tags/')) && '-release') || '' }} |
| 191 | + body_path: CHANGELOG.md |
| 192 | + prerelease: false |
| 193 | + draft: false |
| 194 | + token: ${{ github.token }} |
0 commit comments