Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/create-release-post.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ defaults:

permissions:
contents: write
pull-requests: write

jobs:
create-post:
Expand All @@ -33,13 +34,16 @@ jobs:
use-version-file: true

- run: node --run scripts:release-post "$VERSION"
working-directory: apps/site
env:
VERSION: ${{ inputs.version }}

- name: Open pull request
uses: gr2m/create-or-update-pull-request-action@b65137ca591da0b9f43bad7b24df13050ea45d1b # v1.10.1
# Creates a PR or update the Action's existing PR, or
# no-op if the base branch is already up-to-date.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
update-pull-request-title-and-body: true
branch: release-${{ inputs.version }}
Expand Down
20 changes: 14 additions & 6 deletions apps/site/scripts/release-post/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import { existsSync, readFileSync } from 'node:fs';
import { writeFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import { parseArgs } from 'node:util';

import handlebars from 'handlebars';
import { format } from 'prettier';
Expand Down Expand Up @@ -58,10 +59,20 @@ const ERRORS = {
new Error(`Failed to write Release post: Reason: ${reason}`),
};

const parsedArgs = parseArgs({
options: {
force: {
type: 'boolean',
short: 'f',
},
},
allowPositionals: true,
});

const ARGS = {
CURRENT_PATH: process.argv[1],
SPECIFIC_VERSION: process.argv[2] && process.argv[2].replace('--force', ''),
SHOULD_FORCE: (process.argv[3] || process.argv[2]) === '--force',
SPECIFIC_VERSION: parsedArgs.positionals[0]?.replace(/^v/, ''),
SHOULD_FORCE: Boolean(parsedArgs.values.force),
};

// this allows us to get the current module working directory
Expand Down Expand Up @@ -262,9 +273,6 @@ if (import.meta.url.startsWith('file:')) {
.then(renderPost)
.then(formatPost)
.then(writeToFile)
.then(
filepath => console.log('Release post created:', filepath),
error => console.error('Some error occurred here!', error.stack)
);
.then(filepath => console.log('Release post created:', filepath));
}
}
Loading