Skip to content

Commit

Permalink
chore: generate version on pre-publish (#8872)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf committed Aug 31, 2022
1 parent 37906f4 commit 3499e12
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/pre-release.yml
Expand Up @@ -19,8 +19,9 @@ jobs:
- name: Install dependencies
run: npm install
- name: Build
env:
PUBLISH: 1
run: |
npm run generate:sources
npm run docs
- name: Version docs
working-directory: ./website
Expand Down
29 changes: 15 additions & 14 deletions utils/generate_sources.ts
Expand Up @@ -77,20 +77,21 @@ const INCLUDED_FOLDERS = ['common', 'node', 'generated', 'util'];
.outputs(['src/types.ts'])
.build();

job('', async ({inputs, outputs}) => {
const version = JSON.parse(await readFile(inputs[0]!, 'utf8')).version;
await writeFile(
outputs[0]!,
(
await readFile(outputs[0]!, {
encoding: 'utf-8',
})
).replace("'NEXT'", `v${version}`)
);
})
.inputs(['package.json'])
.outputs(['versions.js'])
.build();
if (process.env['PUBLISH']) {
job('', async ({inputs}) => {
const version = JSON.parse(await readFile(inputs[0]!, 'utf8')).version;
await writeFile(
inputs[1]!,
(
await readFile(inputs[1]!, {
encoding: 'utf-8',
})
).replace("'NEXT'", `'v${version}'`)
);
})
.inputs(['package.json', 'versions.js'])
.build();
}

job('', async ({inputs, outputs}) => {
const version = JSON.parse(await readFile(inputs[0]!, 'utf8')).version;
Expand Down

0 comments on commit 3499e12

Please sign in to comment.