diff --git a/.github/workflows/update-external-docs.yml b/.github/workflows/update-external-docs.yml index 468aec6e75..caa2e12f9c 100644 --- a/.github/workflows/update-external-docs.yml +++ b/.github/workflows/update-external-docs.yml @@ -14,8 +14,15 @@ jobs: if: github.repository_owner == 'expressjs' steps: - uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 - name: Run scripts - run: bash ./get-contributing.sh && bash ./get-readmes.sh + run: | + bash ./get-contributing.sh + bash ./get-readmes.sh + node ./get-express-version.mjs - name: Create Pull Request uses: gr2m/create-or-update-pull-request-action@v1 env: diff --git a/get-express-version.mjs b/get-express-version.mjs new file mode 100755 index 0000000000..8f8766470b --- /dev/null +++ b/get-express-version.mjs @@ -0,0 +1,20 @@ +import { readFile, writeFile } from 'node:fs/promises' +import path from 'node:path' + +const NPMURL = 'https://registry.npmjs.org/express' + +const response = await (await fetch(NPMURL)).json() + +const { next, latest } = response['dist-tags'] + +try { + const filePath = path.resolve(path.join('_data', 'express.yml')) + let content = await readFile(filePath, 'utf8') + + content = content.replace(/current_version: ".*"/, `current_version: "${latest}"`) + content = content.replace(/next_version: ".*"/, `next_version: "${next}"`) + + await writeFile(filePath, content, 'utf8') +} catch (error) { + console.error('Error updating versions in _data/express.yml:', error) +}