|
| 1 | +name: Production Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +concurrency: production-release-main |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build and test (production) |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v6 |
| 17 | + with: |
| 18 | + ref: main |
| 19 | + - name: Set up Python 3.11 |
| 20 | + uses: actions/setup-python@v6 |
| 21 | + with: |
| 22 | + python-version: "3.11" |
| 23 | + - name: Setup fontspector |
| 24 | + uses: fonttools/setup-fontspector@main |
| 25 | + env: |
| 26 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 27 | + - name: Install toolset |
| 28 | + run: | |
| 29 | + sudo apt-get update |
| 30 | + sudo apt-get install ttfautohint libcairo2-dev python3-cairo-dev pkg-config python3-dev |
| 31 | + sudo snap install yq |
| 32 | + - uses: actions/cache@v4 |
| 33 | + with: |
| 34 | + path: ./venv/ |
| 35 | + key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements*.txt') }} |
| 36 | + restore-keys: | |
| 37 | + ${{ runner.os }}-venv- |
| 38 | + - name: Set artifact file name |
| 39 | + id: zip-name |
| 40 | + shell: bash |
| 41 | + # Set the archive name to repo name + "-fonts" e.g "radiocanadafonts-fonts.zip" |
| 42 | + run: echo "ZIP_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')-fonts" >> $GITHUB_ENV |
| 43 | + - name: Build font |
| 44 | + run: make build |
| 45 | + - name: Check with fontspector |
| 46 | + run: make test |
| 47 | + continue-on-error: true |
| 48 | + - name: Generate proofs |
| 49 | + run: make proof |
| 50 | + - name: Set up test result site |
| 51 | + run: cp scripts/index.html out/index.html |
| 52 | + - name: Archive artifacts |
| 53 | + uses: actions/upload-artifact@v4 |
| 54 | + with: |
| 55 | + name: ${{ env.ZIP_NAME }} |
| 56 | + path: | |
| 57 | + fonts |
| 58 | + out |
| 59 | + - name: Archive npm release artifacts |
| 60 | + uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: geist-font-fonts-npm |
| 63 | + path: | |
| 64 | + geist-font.zip |
| 65 | + packages/next/dist/fonts |
| 66 | + outputs: |
| 67 | + zip_name: ${{ env.ZIP_NAME }} |
| 68 | + |
| 69 | + release: |
| 70 | + name: Production release |
| 71 | + needs: build |
| 72 | + runs-on: ubuntu-latest |
| 73 | + steps: |
| 74 | + - name: Checkout |
| 75 | + uses: actions/checkout@v6 |
| 76 | + with: |
| 77 | + ref: main |
| 78 | + fetch-depth: 0 |
| 79 | + |
| 80 | + - name: Download font artifacts |
| 81 | + uses: actions/download-artifact@v5 |
| 82 | + with: |
| 83 | + name: geist-font-fonts-npm |
| 84 | + path: ./artifacts |
| 85 | + |
| 86 | + - name: Setup Node.js |
| 87 | + uses: actions/setup-node@v4 |
| 88 | + with: |
| 89 | + node-version-file: .nvmrc |
| 90 | + |
| 91 | + # Hardcoded because we know it works, it would be fine to try to upgrade |
| 92 | + - name: 'Install corepack@0.31' |
| 93 | + shell: bash |
| 94 | + run: | |
| 95 | + npm install -g corepack@0.31 |
| 96 | + echo "corepack version after: $(corepack --version)" |
| 97 | +
|
| 98 | + - name: Enable Corepack |
| 99 | + run: corepack enable |
| 100 | + |
| 101 | + - name: Configure npm auth |
| 102 | + run: npm config set //registry.npmjs.org/:_authToken="${NPM_TOKEN}" |
| 103 | + env: |
| 104 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }} |
| 105 | + |
| 106 | + - name: Install dependencies |
| 107 | + working-directory: packages/next |
| 108 | + run: pnpm install --frozen-lockfile |
| 109 | + |
| 110 | + - name: Ensure changeset exists |
| 111 | + run: | |
| 112 | + if ! find packages/next/.changeset -maxdepth 1 -type f -name "*.md" ! -name "README.md" | grep -q .; then |
| 113 | + echo "No changesets found in packages/next/.changeset. Add one before running a production release." |
| 114 | + exit 1 |
| 115 | + fi |
| 116 | +
|
| 117 | + - name: Ensure prerelease mode is not enabled |
| 118 | + run: | |
| 119 | + if [ -f packages/next/.changeset/pre.json ]; then |
| 120 | + echo "Changesets prerelease mode is enabled (packages/next/.changeset/pre.json). Exit prerelease mode before a production release." |
| 121 | + exit 1 |
| 122 | + fi |
| 123 | +
|
| 124 | + - name: Move the font files for npm from build artifacts to the npm package |
| 125 | + run: | |
| 126 | + rm -rf packages/next/dist/fonts |
| 127 | + mv artifacts/packages/next/dist/fonts packages/next/dist/fonts |
| 128 | +
|
| 129 | + - name: Version packages |
| 130 | + working-directory: packages/next |
| 131 | + run: pnpm changeset version |
| 132 | + |
| 133 | + - name: Commit version changes |
| 134 | + run: | |
| 135 | + if git diff --quiet; then |
| 136 | + echo "No version changes to commit." |
| 137 | + exit 0 |
| 138 | + fi |
| 139 | +
|
| 140 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 141 | + git config user.name "github-actions[bot]" |
| 142 | +
|
| 143 | + git checkout -B main |
| 144 | + git add -A |
| 145 | + if git diff --cached --quiet; then |
| 146 | + echo "Nothing staged." |
| 147 | + exit 0 |
| 148 | + fi |
| 149 | + git commit -m "chore: version packages for production release" |
| 150 | + git push origin "HEAD:main" |
| 151 | +
|
| 152 | + - name: Publish production |
| 153 | + working-directory: packages/next |
| 154 | + run: pnpm changeset publish |
| 155 | + env: |
| 156 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }} |
| 157 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 158 | + |
| 159 | + # Upload the built font zip to the GitHub release for the published npm package. |
| 160 | + - name: Upload font zip to GitHub Release |
| 161 | + env: |
| 162 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 163 | + run: | |
| 164 | + VERSION=$(jq -r '.version' packages/next/package.json) |
| 165 | + TAG="geist@$VERSION" |
| 166 | +
|
| 167 | + if ! gh release view "$TAG" >/dev/null 2>&1; then |
| 168 | + gh release create "$TAG" --title "$TAG" --notes "Production release for $TAG" |
| 169 | + fi |
| 170 | +
|
| 171 | + mv artifacts/geist-font.zip "geist-font-v$VERSION.zip" |
| 172 | + gh release upload "$TAG" "geist-font-v$VERSION.zip" --clobber |
0 commit comments