Publish manifest #286
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish manifest | |
| on: | |
| workflow_dispatch: {} | |
| push: | |
| tags: ["20*"] # still fires on tag pushes, but cron/manual also work | |
| schedule: | |
| - cron: "3 2 * * *" # 02:03 UTC nightly | |
| jobs: | |
| build: | |
| runs-on: blacksmith-2vcpu-ubuntu-2404 | |
| env: | |
| GH_TOKEN: ${{ secrets.SPONSORS_TOKEN }} | |
| SPONSOR_LOGIN: "mtthidoteu" | |
| steps: | |
| # ----------------------------------------------------------- | |
| # Grab the source *and* every tag so we can look up the latest. | |
| # ----------------------------------------------------------- | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 # ← crucial for git describe | |
| # ----------------------------------------------------------- | |
| # (1) Fetch sponsors – unchanged | |
| # ----------------------------------------------------------- | |
| - name: Fetch sponsors | |
| shell: bash | |
| run: | | |
| gh api graphql \ | |
| -F login="$SPONSOR_LOGIN" \ | |
| -F query=' | |
| query($login:String!, $cursor:String) { | |
| user(login:$login) { | |
| sponsorshipsAsMaintainer(first:100, after:$cursor) { | |
| pageInfo { hasNextPage endCursor } | |
| nodes { | |
| sponsorEntity { | |
| ... on User { login url avatarUrl } | |
| ... on Organization { login url avatarUrl } | |
| } | |
| } | |
| } | |
| } | |
| }' \ | |
| --paginate \ | |
| -q '.data.user.sponsorshipsAsMaintainer.nodes[]' \ | |
| | jq -s '.' > sponsors.json | |
| # ----------------------------------------------------------- | |
| # 🆕 (2) Work out the latest tag name | |
| # ----------------------------------------------------------- | |
| - name: Determine latest stable version | |
| id: get_version | |
| shell: bash | |
| run: | | |
| git fetch --tags --force # no-ops if already present | |
| # Prioritize v2025.x.x format over older formats for latest version | |
| tag=$(git tag -l --sort=-version:refname | grep -E '^v2[0-9]+\.[0-9]+\.[0-9]+$' | head -n1) | |
| if [ -z "$tag" ]; then | |
| # Fallback to 2025.x.x format (no v prefix) if no v2025.x.x tags found | |
| tag=$(git tag -l --sort=-version:refname | grep -E '^2[0-9]+\.[0-9]+\.[0-9]+$' | head -n1) | |
| fi | |
| if [ -z "$tag" ]; then | |
| # Further fallback to v4.x.x format | |
| tag=$(git tag -l --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n1) | |
| fi | |
| if [ -z "$tag" ]; then | |
| # Final fallback to any tag | |
| tag=$(git describe --tags --abbrev=0) | |
| fi | |
| echo "latest_version=${tag#v}" >> "$GITHUB_OUTPUT" | |
| # ----------------------------------------------------------- | |
| # (3) Build manifest.json | |
| # ----------------------------------------------------------- | |
| - name: Build manifest.json | |
| shell: bash | |
| env: | |
| LATEST_VERSION: ${{ steps.get_version.outputs.latest_version }} | |
| run: | | |
| python <<'PY' | |
| import json, os, pathlib | |
| from datetime import datetime, timezone | |
| latest = os.environ["LATEST_VERSION"] # always present now | |
| with open('sponsors.json') as f: | |
| sponsors = json.load(f) | |
| manifest = { | |
| "latest_version": latest, | |
| "released": datetime.now(timezone.utc).isoformat(timespec='seconds'), | |
| "sponsors": sponsors | |
| } | |
| pathlib.Path('manifest.json').write_text(json.dumps(manifest, indent=2)) | |
| PY | |
| # ----------------------------------------------------------- | |
| # (4) Prepare deploy directory | |
| # ----------------------------------------------------------- | |
| - name: Prepare deploy directory | |
| run: | | |
| mkdir -p deploy | |
| mv manifest.json deploy/ | |
| # ----------------------------------------------------------- | |
| # (5) Deploy to gh-pages – unchanged | |
| # ----------------------------------------------------------- | |
| - name: Deploy to gh-pages | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_branch: gh-pages | |
| publish_dir: deploy | |
| keep_files: true |