From 7790aa6231b8f81bef1f31e48b5ff06f65a14403 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Wed, 27 May 2026 13:11:22 -0400 Subject: [PATCH] gh pages --- .github/workflows/pages.yml | 52 ++++++++++--------------------------- 1 file changed, 13 insertions(+), 39 deletions(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index f23f429..2bbc472 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -1,10 +1,5 @@ name: Deploy GitHub Pages -# Builds the docs/ site, substitutes the latest release tag into the HTML, -# then deploys the result to GitHub Pages. Runs on: -# - any push to main that touches docs/, this workflow, or CMakeLists.txt -# - every published release (so a new tag refreshes the site) -# - manual dispatch from the Actions tab on: push: branches: [main] @@ -16,26 +11,23 @@ on: types: [published] workflow_dispatch: -# Required permissions for the deploy-pages action. permissions: - contents: read - pages: write - id-token: write + contents: write # Changed: need write to push to gh-pages + pages: read # No longer needed for deploy-pages + id-token: none -# Avoid concurrent deploys; let the latest one win. concurrency: group: "pages" cancel-in-progress: false jobs: - build: - name: Build site + deploy: + name: Deploy to gh-pages runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v6.0.2 + uses: actions/checkout@v6 with: - # Needed so the git-tag fallback can find release tags. fetch-depth: 0 fetch-tags: true @@ -45,46 +37,28 @@ jobs: GH_TOKEN: ${{ github.token }} run: | set -euo pipefail - # Prefer the latest published GitHub release. tag="$(gh release view --repo ${{ github.repository }} --json tagName --jq .tagName 2>/dev/null || true)" if [ -z "${tag:-}" ]; then - # Fall back to the newest semver-looking git tag. tag="$(git tag --sort=-v:refname | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1 || true)" fi if [ -z "${tag:-}" ]; then - # Last-resort fallback: read version from CMakeLists.txt. tag="v$(grep -E 'project\(fast_float VERSION' CMakeLists.txt | sed -E 's/.*VERSION ([0-9.]+).*/\1/')" fi - # Strip a leading "v" — the template uses bare semver after "v". version="${tag#v}" echo "tag=${tag}" >> "$GITHUB_OUTPUT" echo "version=${version}" >> "$GITHUB_OUTPUT" - echo "Resolved version: ${version} (tag ${tag})" + echo "Resolved version: ${version}" - name: Substitute version into HTML run: | - set -euo pipefail version='${{ steps.version.outputs.version }}' - # In-place replace every {{VERSION}} occurrence under docs/. find docs -type f \( -name '*.html' -o -name '*.md' -o -name '*.css' -o -name '*.js' \) \ -exec sed -i "s/{{VERSION}}/${version}/g" {} + - - name: Setup Pages - uses: actions/configure-pages@v5 - - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + - name: Deploy to gh-pages branch + uses: JamesIves/github-pages-deploy-action@v4 with: - path: docs - - deploy: - name: Deploy to GitHub Pages - needs: build - runs-on: ubuntu-latest - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - steps: - - name: Deploy - id: deployment - uses: actions/deploy-pages@v4 + branch: gh-pages + folder: docs + clean: true + commit-message: "Deploy docs for version ${{ steps.version.outputs.version }}" \ No newline at end of file