Skip to content

Commit 32e04f8

Browse files
authored
Merge pull request #563 from aryasadeghi1/docs-version-from-release
docs: derive site version from the latest GitHub release
2 parents 2a99d6d + f4042b9 commit 32e04f8

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

.github/workflows/python-publish.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ jobs:
169169
name: Release
170170
runs-on: ubuntu-latest
171171
needs: [checks]
172+
permissions:
173+
contents: write
174+
pages: write
172175
if: startsWith(github.ref, 'refs/tags/')
173176
steps:
174177
- uses: actions/checkout@v1
@@ -207,3 +210,13 @@ jobs:
207210
prerelease: ${{ contains(env.TAG, 'rc') }}
208211
files: |
209212
dist/*
213+
214+
# The docs header reads the version from the latest release, but Pages only
215+
# rebuilds on a push to its branch, and the release lands after that push.
216+
# Ask for a rebuild here so the site picks up the tag we just published.
217+
# Has to live in this job: a release made with GITHUB_TOKEN doesn't fire the
218+
# release event, so a workflow keyed on it would never run.
219+
- name: Rebuild docs site
220+
env:
221+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
222+
run: gh api --method POST repos/${{ github.repository }}/pages/builds

docs/_config.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ url: "https://azure.github.io" # the base hostname & protocol for your site, e.g
3333
github:
3434
repo: https://github.com/Azure/aaz-dev-tools
3535

36-
pypi: https://pypi.org/project/aaz-dev/
36+
# Used by jekyll-github-metadata to resolve site.github.* when building outside
37+
# of GitHub Pages. Pages infers it, local builds wont.
38+
repository: Azure/aaz-dev-tools
3739

38-
# TODO: get version number from github
39-
version: v4.6.1
40+
pypi: https://pypi.org/project/aaz-dev/
4041

4142
# Build settings
4243
theme: minima

docs/_includes/header.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,19 @@
2727
></path></svg
2828
><span class="h4 text-semibold ml-2">GitHub Repo</span></a
2929
>
30+
{% comment %}
31+
Populated from the latest GitHub release. Empty on local builds without
32+
a JEKYLL_GITHUB_TOKEN, so hide the whole block rather than show a blank.
33+
{% endcomment %}
34+
{% assign latest_version = site.github.latest_release.tag_name %}
35+
{% if latest_version %}
3036
<div class="hide-sm border-left">
3137
<div class="pl-2 pr-2">
3238
<span class="color-fg-muted text-normal">Version: </span>
33-
<span>{{ site.version }}</span>
39+
<span>{{ latest_version }}</span>
3440
</div>
3541
</div>
42+
{% endif %}
3643
</div>
3744
</div>
3845
</header>

0 commit comments

Comments
 (0)