11name : Deploy GitHub Pages
22
3- # Builds the docs/ site, substitutes the latest release tag into the HTML,
4- # then deploys the result to GitHub Pages. Runs on:
5- # - any push to main that touches docs/, this workflow, or CMakeLists.txt
6- # - every published release (so a new tag refreshes the site)
7- # - manual dispatch from the Actions tab
83on :
94 push :
105 branches : [main]
1611 types : [published]
1712 workflow_dispatch :
1813
19- # Required permissions for the deploy-pages action.
2014permissions :
21- contents : read
22- pages : write
23- id-token : write
15+ contents : write # Changed: need write to push to gh-pages
16+ pages : read # No longer needed for deploy-pages
17+ id-token : none
2418
25- # Avoid concurrent deploys; let the latest one win.
2619concurrency :
2720 group : " pages"
2821 cancel-in-progress : false
2922
3023jobs :
31- build :
32- name : Build site
24+ deploy :
25+ name : Deploy to gh-pages
3326 runs-on : ubuntu-latest
3427 steps :
3528 - name : Checkout
36- uses : actions/checkout@v6.0.2
29+ uses : actions/checkout@v6
3730 with :
38- # Needed so the git-tag fallback can find release tags.
3931 fetch-depth : 0
4032 fetch-tags : true
4133
@@ -45,46 +37,28 @@ jobs:
4537 GH_TOKEN : ${{ github.token }}
4638 run : |
4739 set -euo pipefail
48- # Prefer the latest published GitHub release.
4940 tag="$(gh release view --repo ${{ github.repository }} --json tagName --jq .tagName 2>/dev/null || true)"
5041 if [ -z "${tag:-}" ]; then
51- # Fall back to the newest semver-looking git tag.
5242 tag="$(git tag --sort=-v:refname | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1 || true)"
5343 fi
5444 if [ -z "${tag:-}" ]; then
55- # Last-resort fallback: read version from CMakeLists.txt.
5645 tag="v$(grep -E 'project\(fast_float VERSION' CMakeLists.txt | sed -E 's/.*VERSION ([0-9.]+).*/\1/')"
5746 fi
58- # Strip a leading "v" — the template uses bare semver after "v".
5947 version="${tag#v}"
6048 echo "tag=${tag}" >> "$GITHUB_OUTPUT"
6149 echo "version=${version}" >> "$GITHUB_OUTPUT"
62- echo "Resolved version: ${version} (tag ${tag}) "
50+ echo "Resolved version: ${version}"
6351
6452 - name : Substitute version into HTML
6553 run : |
66- set -euo pipefail
6754 version='${{ steps.version.outputs.version }}'
68- # In-place replace every {{VERSION}} occurrence under docs/.
6955 find docs -type f \( -name '*.html' -o -name '*.md' -o -name '*.css' -o -name '*.js' \) \
7056 -exec sed -i "s/{{VERSION}}/${version}/g" {} +
7157
72- - name : Setup Pages
73- uses : actions/configure-pages@v5
74-
75- - name : Upload artifact
76- uses : actions/upload-pages-artifact@v3
58+ - name : Deploy to gh-pages branch
59+ uses : JamesIves/github-pages-deploy-action@v4
7760 with :
78- path : docs
79-
80- deploy :
81- name : Deploy to GitHub Pages
82- needs : build
83- runs-on : ubuntu-latest
84- environment :
85- name : github-pages
86- url : ${{ steps.deployment.outputs.page_url }}
87- steps :
88- - name : Deploy
89- id : deployment
90- uses : actions/deploy-pages@v4
61+ branch : gh-pages
62+ folder : docs
63+ clean : true
64+ commit-message : " Deploy docs for version ${{ steps.version.outputs.version }}"
0 commit comments