feat: auto-publish new app version on Inter font update; use IURLGene… #1
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
| # .github/workflows/update-inter-fonts.yml | ||
| # | ||
| # Monitors rsms/inter for new releases via a weekly schedule poll. | ||
| # When a newer Inter version is detected it: | ||
| # 1. Downloads the official Inter release ZIP | ||
| # 2. Extracts Inter[wght].woff2 and Inter-Italic[wght].woff2 | ||
| # 3. Bumps the app minor version in appinfo/info.xml and CHANGELOG.md | ||
| # 4. Updates the bundled-version comment in css/inter-font.css | ||
| # 5. Commits everything directly to main | ||
| # 6. Creates and pushes a Git tag for the new app version | ||
| # 7. Publishes a GitHub Release with release notes | ||
| # | ||
| # Triggers | ||
| # -------- | ||
| # - schedule : weekly poll every Sunday 02:00 UTC | ||
| # - workflow_dispatch: manual run with optional version override | ||
| name: Update Inter Fonts | ||
| on: | ||
| schedule: | ||
| - cron: "0 2 * * 0" | ||
| workflow_dispatch: | ||
| inputs: | ||
| force_version: | ||
| description: 'Force a specific Inter tag, e.g. "v4.2". Leave empty for latest.' | ||
| required: false | ||
| default: "" | ||
| permissions: | ||
| contents: write | ||
| jobs: | ||
| update-fonts: | ||
| name: Check & update Inter variable fonts | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| # ----------------------------------------------------------------------- | ||
| # 1. Checkout with full history so we can commit & tag | ||
| # ----------------------------------------------------------------------- | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| # ----------------------------------------------------------------------- | ||
| # 2. Resolve target Inter version | ||
| # ----------------------------------------------------------------------- | ||
| - name: Resolve target Inter version | ||
| id: resolve | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| if [[ -n "${{ inputs.force_version }}" ]]; then | ||
| TARGET="${{ inputs.force_version }}" | ||
| else | ||
| TARGET=$(gh release view --repo rsms/inter --json tagName -q '.tagName') | ||
| fi | ||
| if ! echo "$TARGET" | grep -qE '^v[0-9]+\.[0-9]+(\.[0-9]+)?$'; then | ||
| echo "ERROR: unexpected version format: $TARGET" >&2 | ||
| exit 1 | ||
| fi | ||
| echo "Resolved Inter version: $TARGET" | ||
| echo "target_version=$TARGET" >> "$GITHUB_OUTPUT" | ||
| # Also expose a clean numeric string, e.g. "4.1" | ||
| echo "target_version_num=${TARGET#v}" >> "$GITHUB_OUTPUT" | ||
| # ----------------------------------------------------------------------- | ||
| # 3. Read current committed Inter version | ||
| # ----------------------------------------------------------------------- | ||
| - name: Read current Inter version | ||
| id: current | ||
| run: | | ||
| if [[ -f fonts/inter-version.txt ]]; then | ||
| CURRENT=$(cat fonts/inter-version.txt | tr -d '[:space:]') | ||
| else | ||
| CURRENT="none" | ||
| fi | ||
| echo "current_version=$CURRENT" >> "$GITHUB_OUTPUT" | ||
| echo "Currently committed: $CURRENT" | ||
| # ----------------------------------------------------------------------- | ||
| # 4. Skip if already up-to-date | ||
| # ----------------------------------------------------------------------- | ||
| - name: Check if update is needed | ||
| id: check | ||
| run: | | ||
| TARGET="${{ steps.resolve.outputs.target_version }}" | ||
| CURRENT="${{ steps.current.outputs.current_version }}" | ||
| if [[ "$TARGET" == "$CURRENT" ]]; then | ||
| echo "Already at $TARGET — nothing to do." | ||
| echo "needs_update=false" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "Update needed: $CURRENT → $TARGET" | ||
| echo "needs_update=true" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| # ----------------------------------------------------------------------- | ||
| # 5. Compute new app version (bump minor component) | ||
| # | ||
| # App version follows: <major>.<minor>.<patch> | ||
| # On each font update we bump <minor> and reset <patch> to 0. | ||
| # Example: 1.0.0 → 1.1.0 → 1.2.0 | ||
| # ----------------------------------------------------------------------- | ||
| - name: Compute new app version | ||
| id: appver | ||
| if: steps.check.outputs.needs_update == 'true' | ||
| run: | | ||
| CURRENT_APP=$(grep -oP '(?<=<version>)[^<]+' appinfo/info.xml | tr -d '[:space:]') | ||
| MAJOR=$(echo "$CURRENT_APP" | cut -d. -f1) | ||
| MINOR=$(echo "$CURRENT_APP" | cut -d. -f2) | ||
| PATCH=$(echo "$CURRENT_APP" | cut -d. -f3) | ||
| NEW_MINOR=$(( MINOR + 1 )) | ||
| NEW_APP_VERSION="${MAJOR}.${NEW_MINOR}.0" | ||
| echo "App version: $CURRENT_APP → $NEW_APP_VERSION" | ||
| echo "current_app_version=$CURRENT_APP" >> "$GITHUB_OUTPUT" | ||
| echo "new_app_version=$NEW_APP_VERSION" >> "$GITHUB_OUTPUT" | ||
| # ----------------------------------------------------------------------- | ||
| # 6. Download Inter release ZIP | ||
| # ----------------------------------------------------------------------- | ||
| - name: Download Inter release ZIP | ||
| if: steps.check.outputs.needs_update == 'true' | ||
| env: | ||
| TARGET: ${{ steps.resolve.outputs.target_version }} | ||
| VERSION_NUM: ${{ steps.resolve.outputs.target_version_num }} | ||
| run: | | ||
| ZIP_URL="https://github.com/rsms/inter/releases/download/${TARGET}/Inter-${VERSION_NUM}.zip" | ||
| echo "Downloading: $ZIP_URL" | ||
| curl -fsSL "$ZIP_URL" -o /tmp/inter.zip | ||
| echo "Downloaded: $(du -h /tmp/inter.zip | cut -f1)" | ||
| # ----------------------------------------------------------------------- | ||
| # 7. Extract variable WOFF2 files | ||
| # | ||
| # Inter ZIP layout (v4.x): | ||
| # Inter-X.Y/extras/variable/Inter[wght].woff2 | ||
| # Inter-X.Y/extras/variable/Inter-Italic[wght].woff2 | ||
| # | ||
| # We use a pattern match then fall back to a full extract + find | ||
| # to survive any future ZIP layout changes. | ||
| # ----------------------------------------------------------------------- | ||
| - name: Extract variable WOFF2 files | ||
| if: steps.check.outputs.needs_update == 'true' | ||
| run: | | ||
| mkdir -p /tmp/inter_extracted fonts | ||
| unzip -o /tmp/inter.zip \ | ||
| '*/extras/variable/Inter[[]wght[]].woff2' \ | ||
| '*/extras/variable/Inter-Italic[[]wght[]].woff2' \ | ||
| -d /tmp/inter_extracted || true | ||
| ROMAN=$(find /tmp/inter_extracted -name 'Inter[wght].woff2' | head -1) | ||
| ITALIC=$(find /tmp/inter_extracted -name 'Inter-Italic[wght].woff2' | head -1) | ||
| if [[ -z "$ROMAN" || -z "$ITALIC" ]]; then | ||
| echo "Targeted extract failed — falling back to full ZIP extraction" | ||
| unzip -o /tmp/inter.zip -d /tmp/inter_extracted 2>/dev/null || true | ||
| ROMAN=$(find /tmp/inter_extracted -name 'Inter[wght].woff2' | head -1) | ||
| ITALIC=$(find /tmp/inter_extracted -name 'Inter-Italic[wght].woff2' | head -1) | ||
| fi | ||
| if [[ -z "$ROMAN" ]]; then | ||
| echo "ERROR: Inter[wght].woff2 not found in ZIP" >&2 | ||
| unzip -l /tmp/inter.zip | grep -i woff2 | ||
| exit 1 | ||
| fi | ||
| if [[ -z "$ITALIC" ]]; then | ||
| echo "ERROR: Inter-Italic[wght].woff2 not found in ZIP" >&2 | ||
| unzip -l /tmp/inter.zip | grep -i woff2 | ||
| exit 1 | ||
| fi | ||
| echo "Roman : $ROMAN ($(du -h "$ROMAN" | cut -f1))" | ||
| echo "Italic : $ITALIC ($(du -h "$ITALIC" | cut -f1))" | ||
| cp "$ROMAN" fonts/Inter.var.woff2 | ||
| cp "$ITALIC" fonts/InterItalic.var.woff2 | ||
| echo "${{ steps.resolve.outputs.target_version }}" > fonts/inter-version.txt | ||
| # ----------------------------------------------------------------------- | ||
| # 8. Bump app version in appinfo/info.xml | ||
| # ----------------------------------------------------------------------- | ||
| - name: Bump app version in info.xml | ||
| if: steps.check.outputs.needs_update == 'true' | ||
| env: | ||
| OLD: ${{ steps.appver.outputs.current_app_version }} | ||
| NEW: ${{ steps.appver.outputs.new_app_version }} | ||
| run: | | ||
| sed -i "s|<version>${OLD}</version>|<version>${NEW}</version>|" appinfo/info.xml | ||
| echo "info.xml version: $OLD → $NEW" | ||
| # ----------------------------------------------------------------------- | ||
| # 9. Update CHANGELOG.md — prepend a new entry | ||
| # ----------------------------------------------------------------------- | ||
| - name: Update CHANGELOG.md | ||
| if: steps.check.outputs.needs_update == 'true' | ||
| env: | ||
| NEW_APP: ${{ steps.appver.outputs.new_app_version }} | ||
| INTER: ${{ steps.resolve.outputs.target_version }} | ||
| TODAY: ${{ github.run_started_at }} | ||
| run: | | ||
| DATE=$(date -u +%Y-%m-%d) | ||
| ENTRY="## ${NEW_APP} — ${DATE}\n\n### Changed\n- Updated bundled Inter font to ${INTER}.\n Source: https://github.com/rsms/inter/releases/tag/${INTER}\n" | ||
| # Prepend after the first line (# Changelog header) | ||
| sed -i "1a\\\n${ENTRY}" CHANGELOG.md | ||
| # ----------------------------------------------------------------------- | ||
| # 10. Update bundled-version comment in css/inter-font.css | ||
| # ----------------------------------------------------------------------- | ||
| - name: Update CSS version comment | ||
| if: steps.check.outputs.needs_update == 'true' | ||
| env: | ||
| INTER: ${{ steps.resolve.outputs.target_version }} | ||
| run: | | ||
| # Update copyright year | ||
| sed -i "s|Copyright (c) 2016-[0-9]\{4\} The Inter Project|Copyright (c) 2016-$(date +%Y) The Inter Project|g" css/inter-font.css | ||
| # Update or insert bundled-version comment | ||
| if grep -q 'Bundled Inter version:' css/inter-font.css; then | ||
| sed -i "s|Bundled Inter version:.*|Bundled Inter version: ${INTER}|g" css/inter-font.css | ||
| else | ||
| sed -i "1s|^|/* Bundled Inter version: ${INTER} */\n|" css/inter-font.css | ||
| fi | ||
| # ----------------------------------------------------------------------- | ||
| # 11. Commit all changes directly to main | ||
| # ----------------------------------------------------------------------- | ||
| - name: Commit updated files | ||
| if: steps.check.outputs.needs_update == 'true' | ||
| env: | ||
| NEW_APP: ${{ steps.appver.outputs.new_app_version }} | ||
| INTER: ${{ steps.resolve.outputs.target_version }} | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add \ | ||
| fonts/Inter.var.woff2 \ | ||
| fonts/InterItalic.var.woff2 \ | ||
| fonts/inter-version.txt \ | ||
| appinfo/info.xml \ | ||
| CHANGELOG.md \ | ||
| css/inter-font.css | ||
| git commit -m "chore(release): bump app to ${NEW_APP}, update Inter font to ${INTER}" | ||
| git push origin main | ||
| # ----------------------------------------------------------------------- | ||
| # 12. Create and push a Git tag for the new app version | ||
| # ----------------------------------------------------------------------- | ||
| - name: Tag new app version | ||
| if: steps.check.outputs.needs_update == 'true' | ||
| env: | ||
| NEW_APP: ${{ steps.appver.outputs.new_app_version }} | ||
| INTER: ${{ steps.resolve.outputs.target_version }} | ||
| run: | | ||
| TAG="v${NEW_APP}" | ||
| git tag -a "$TAG" -m "Release ${TAG} — bundles Inter font ${INTER}" | ||
| git push origin "$TAG" | ||
| echo "Pushed tag: $TAG" | ||
| # ----------------------------------------------------------------------- | ||
| # 13. Publish a GitHub Release | ||
| # ----------------------------------------------------------------------- | ||
| - name: Publish GitHub Release | ||
| if: steps.check.outputs.needs_update == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| NEW_APP: ${{ steps.appver.outputs.new_app_version }} | ||
| OLD_APP: ${{ steps.appver.outputs.current_app_version }} | ||
| INTER: ${{ steps.resolve.outputs.target_version }} | ||
| run: | | ||
| gh release create "v${NEW_APP}" \ | ||
| --title "Inter Fonts ${NEW_APP}" \ | ||
| --notes "## What changed | ||
| Updated bundled Inter variable font from \`${{ steps.current.outputs.current_version }}\` to **${INTER}**. | ||
| | | | | ||
| |---|---| | ||
| | **App version** | \`${NEW_APP}\` (was \`${OLD_APP}\`) | | ||
| | **Bundled Inter** | [${INTER}](https://github.com/rsms/inter/releases/tag/${INTER}) | | ||
| ### Files updated | ||
| - \`fonts/Inter.var.woff2\` | ||
| - \`fonts/InterItalic.var.woff2\` | ||
| - \`fonts/inter-version.txt\` | ||
| - \`appinfo/info.xml\` | ||
| - \`CHANGELOG.md\` | ||
| - \`css/inter-font.css\` | ||
| --- | ||
| _Released automatically by the [Update Inter Fonts](${{ github.server_url }}/${{ github.repository }}/actions/workflows/update-inter-fonts.yml) workflow._" | ||