|
1 | 1 | name: Build docs |
2 | 2 | on: |
| 3 | + workflow_dispatch: |
3 | 4 | release: |
4 | 5 | types: |
5 | 6 | - published |
@@ -29,11 +30,38 @@ jobs: |
29 | 30 | with: |
30 | 31 | name: notebooks |
31 | 32 | path: docs/notebooks |
32 | | - - name: Extract version from release |
| 33 | + - name: Find the latest existing release tag |
| 34 | + id: get_release |
| 35 | + run: | |
| 36 | + if [ "${{ github.event_name }}" == "release" ]; then |
| 37 | + LATEST_TAG="${{ github.event.release.tag_name }}" |
| 38 | + else |
| 39 | + echo "::notice::Running manually via workflow_dispatch. Fetching latest release tag..." |
| 40 | +
|
| 41 | + gh auth status || echo "GitHub CLI is not authenticated, relying on GITHUB_TOKEN." |
| 42 | +
|
| 43 | + # We use tr -d '\n' to remove the trailing newline for a clean tag string |
| 44 | + LATEST_TAG=$(gh release view --json tagName -q .tagName 2>/dev/null) |
| 45 | +
|
| 46 | + if [ -z "$LATEST_TAG" ]; then |
| 47 | + echo "::error::Could not find the latest published release tag. Ensure a release exists." |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | + fi |
| 51 | +
|
| 52 | + echo "Latest release tag found: $LATEST_TAG" |
| 53 | + echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV |
| 54 | + env: |
| 55 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + - name: Extract version from release tag |
33 | 57 | run: | |
34 | 58 | # Remove the 'v' prefix and any suffix after a space |
35 | | - VERSION=$(echo ${{ github.event.release.tag_name }} | sed 's/^v//' | sed 's/ .*$//') |
| 59 | + VERSION=$(echo ${{ env.LATEST_TAG }} | sed 's/^v//' | sed 's/ .*$//') |
36 | 60 | echo "::notice::Extracted version: $VERSION" |
37 | 61 | echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 62 | + - name: Setup doc deploy |
| 63 | + run: | |
| 64 | + git config --global user.name "github-actions[bot]" |
| 65 | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
38 | 66 | - name: Build and deploy docs |
39 | 67 | run: uv run mike deploy --push --update-aliases ${{ env.VERSION }} latest |
0 commit comments