diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index 4d41153..ae6a513 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -63,20 +63,28 @@ jobs: - name: Publish the release if: steps.v.outputs.skip == 'false' + env: + TAG: ${{ steps.v.outputs.tag }} + VER: ${{ steps.v.outputs.ver }} + PRE: ${{ steps.v.outputs.pre }} run: | set -euo pipefail - pre=(); [ "${{ steps.v.outputs.pre }}" = "true" ] && pre=(--prerelease) - gh release create "${{ steps.v.outputs.tag }}" --repo "$GITHUB_REPOSITORY" \ - --target "$GITHUB_SHA" --title "${{ steps.v.outputs.ver }}" --notes-file notes.md "${pre[@]}" + pre=(); [ "$PRE" = "true" ] && pre=(--prerelease) + gh release create "$TAG" --repo "$GITHUB_REPOSITORY" \ + --target "$GITHUB_SHA" --title "$VER" --notes-file notes.md "${pre[@]}" - name: Deploy it # Pre-releases are for testing and never go live. if: steps.v.outputs.skip == 'false' && steps.v.outputs.pre == 'false' - run: gh workflow run release.yml --repo "$GITHUB_REPOSITORY" --ref "${{ steps.v.outputs.tag }}" -f tag="${{ steps.v.outputs.tag }}" + env: + TAG: ${{ steps.v.outputs.tag }} + run: gh workflow run release.yml --repo "$GITHUB_REPOSITORY" --ref "$TAG" -f tag="$TAG" - name: Publish the Docker image # Same pattern as the deploy above: the image is built and pushed from the # release tag by docker.yml. Pre-releases get one too: an image tag is # pulled on purpose, so a test image costs nothing. if: steps.v.outputs.skip == 'false' - run: gh workflow run docker.yml --repo "$GITHUB_REPOSITORY" --ref "${{ steps.v.outputs.tag }}" -f tag="${{ steps.v.outputs.tag }}" + env: + TAG: ${{ steps.v.outputs.tag }} + run: gh workflow run docker.yml --repo "$GITHUB_REPOSITORY" --ref "$TAG" -f tag="$TAG" diff --git a/.github/workflows/perf-comment.yml b/.github/workflows/perf-comment.yml index 9508742..a214fff 100644 --- a/.github/workflows/perf-comment.yml +++ b/.github/workflows/perf-comment.yml @@ -20,6 +20,8 @@ jobs: - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: name: perf + # Outside the workspace: the files come from a PR's run and are only ever read as text. + path: ${{ runner.temp }}/perf run-id: ${{ github.event.workflow_run.id }} github-token: ${{ secrets.GITHUB_TOKEN }} - name: Post or update the comment @@ -28,6 +30,7 @@ jobs: REPO: ${{ github.repository }} HEAD_SHA: ${{ github.event.workflow_run.head_sha }} run: | + cd "$RUNNER_TEMP/perf" pr=$(tr -cd '0-9' < pr-number.txt) [ -n "$pr" ] || { echo "no PR number"; exit 0; } # Trust the number only if that PR's head is the commit that was benchmarked. diff --git a/scripts/dev.js b/scripts/dev.js index 79b10b7..2a5ffda 100644 --- a/scripts/dev.js +++ b/scripts/dev.js @@ -53,8 +53,10 @@ const server = http.createServer((req, res) => { res.writeHead(200, { 'content-type': TYPES[path.extname(file)] || 'application/octet-stream', 'cache-control': 'no-store' }); fs.createReadStream(file).pipe(res); } catch (e) { + // The stack goes to the terminal running the server, never into the response. + console.error(e); res.writeHead(500, { 'content-type': 'text/plain; charset=utf-8' }); - res.end(String(e && e.stack || e)); + res.end('Could not build the page: see the terminal running npm run dev.'); } }); const relay = createRelay({ server }); diff --git a/scripts/i18n-add.js b/scripts/i18n-add.js index 27468e5..027b3db 100644 --- a/scripts/i18n-add.js +++ b/scripts/i18n-add.js @@ -36,7 +36,7 @@ if (args[0] === '--rename') { for (const f of listFiles(src)) { if (f === 'i18n/en.js') continue; const p = path.join(src, f), t = fs.readFileSync(p, 'utf8'); - const u = t.replace(new RegExp(String.raw`(['"\x60])${from.replace(/\./g, '\\.')}\1`, 'g'), (m, q) => { n++; return q + to + q; }); + const u = t.replace(new RegExp(String.raw`(['"\x60])${from.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\1`, 'g'), (m, q) => { n++; return q + to + q; }); if (u !== t) fs.writeFileSync(p, u); } console.log(`renamed ${from} → ${to} in every dictionary and ${n} place(s) in src/`); diff --git a/scripts/i18n-check.js b/scripts/i18n-check.js index fd21bb2..eacf61a 100644 --- a/scripts/i18n-check.js +++ b/scripts/i18n-check.js @@ -103,7 +103,7 @@ function registration(lang, html) { const sw = fs.readFileSync(path.join(SITE, 'sw.js'), 'utf8'); const out = []; const m = html.match(/SOT_LANGS=\{([^}]*)\}/); - if (!m || !new RegExp(String.raw`(^|[,{\s])${lang}\s*:`).test(m[1])) out.push('not in the language list (SOT_LANGS in src/index.html)'); + if (!m || !new RegExp(String.raw`(^|[,{\s])${lang.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\s*:`).test(m[1])) out.push('not in the language list (SOT_LANGS in src/index.html)'); if (!sw.includes(`/i18n/${lang}.js`)) out.push('not cached for offline play (CORE in site/sw.js)'); if (!D.tidy(lang)) out.push('not sorted one entry per line: run npm run i18n:fix'); return out;