mirror of
https://github.com/fastfloat/fast_float.git
synced 2026-06-15 00:16:11 +08:00
gh pages
This commit is contained in:
parent
ee866c2b92
commit
7790aa6231
52
.github/workflows/pages.yml
vendored
52
.github/workflows/pages.yml
vendored
@ -1,10 +1,5 @@
|
|||||||
name: Deploy GitHub Pages
|
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:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
@ -16,26 +11,23 @@ on:
|
|||||||
types: [published]
|
types: [published]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
# Required permissions for the deploy-pages action.
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: write # Changed: need write to push to gh-pages
|
||||||
pages: write
|
pages: read # No longer needed for deploy-pages
|
||||||
id-token: write
|
id-token: none
|
||||||
|
|
||||||
# Avoid concurrent deploys; let the latest one win.
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: "pages"
|
group: "pages"
|
||||||
cancel-in-progress: false
|
cancel-in-progress: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
deploy:
|
||||||
name: Build site
|
name: Deploy to gh-pages
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6.0.2
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
# Needed so the git-tag fallback can find release tags.
|
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
fetch-tags: true
|
fetch-tags: true
|
||||||
|
|
||||||
@ -45,46 +37,28 @@ jobs:
|
|||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
# Prefer the latest published GitHub release.
|
|
||||||
tag="$(gh release view --repo ${{ github.repository }} --json tagName --jq .tagName 2>/dev/null || true)"
|
tag="$(gh release view --repo ${{ github.repository }} --json tagName --jq .tagName 2>/dev/null || true)"
|
||||||
if [ -z "${tag:-}" ]; then
|
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)"
|
tag="$(git tag --sort=-v:refname | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1 || true)"
|
||||||
fi
|
fi
|
||||||
if [ -z "${tag:-}" ]; then
|
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/')"
|
tag="v$(grep -E 'project\(fast_float VERSION' CMakeLists.txt | sed -E 's/.*VERSION ([0-9.]+).*/\1/')"
|
||||||
fi
|
fi
|
||||||
# Strip a leading "v" — the template uses bare semver after "v".
|
|
||||||
version="${tag#v}"
|
version="${tag#v}"
|
||||||
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
|
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
|
||||||
echo "version=${version}" >> "$GITHUB_OUTPUT"
|
echo "version=${version}" >> "$GITHUB_OUTPUT"
|
||||||
echo "Resolved version: ${version} (tag ${tag})"
|
echo "Resolved version: ${version}"
|
||||||
|
|
||||||
- name: Substitute version into HTML
|
- name: Substitute version into HTML
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
|
||||||
version='${{ steps.version.outputs.version }}'
|
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' \) \
|
find docs -type f \( -name '*.html' -o -name '*.md' -o -name '*.css' -o -name '*.js' \) \
|
||||||
-exec sed -i "s/{{VERSION}}/${version}/g" {} +
|
-exec sed -i "s/{{VERSION}}/${version}/g" {} +
|
||||||
|
|
||||||
- name: Setup Pages
|
- name: Deploy to gh-pages branch
|
||||||
uses: actions/configure-pages@v5
|
uses: JamesIves/github-pages-deploy-action@v4
|
||||||
|
|
||||||
- name: Upload artifact
|
|
||||||
uses: actions/upload-pages-artifact@v3
|
|
||||||
with:
|
with:
|
||||||
path: docs
|
branch: gh-pages
|
||||||
|
folder: docs
|
||||||
deploy:
|
clean: true
|
||||||
name: Deploy to GitHub Pages
|
commit-message: "Deploy docs for version ${{ steps.version.outputs.version }}"
|
||||||
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
|
|
||||||
Loading…
x
Reference in New Issue
Block a user