|
| 1 | +import path from 'node:path' |
| 2 | +import url from 'node:url' |
| 3 | + |
1 | 4 | import { Octokit } from '@octokit/rest' |
| 5 | +import * as dotenv from 'dotenv' |
2 | 6 |
|
3 | 7 | import pkg from '../../../lerna.json' with { type: 'json' } |
| 8 | + |
4 | 9 | /** |
5 | 10 | * make GitHub release for machine readable changelog |
6 | 11 | */ |
| 12 | +const __dirname = path.dirname(url.fileURLToPath(import.meta.url)) |
| 13 | +const root = path.resolve(__dirname, '..', '..', '..') |
| 14 | +dotenv.config({ path: path.join(root, '.env') }) |
7 | 15 |
|
8 | 16 | const api = new Octokit({ auth: process.env.GITHUB_AUTH }) |
9 | | - |
10 | | -const isGithubActions = Boolean(process.env.GITHUB_ACTIONS) |
11 | | -if (!isGithubActions) { |
12 | | - console.log('\nSkip creating the Github Release because this is not running on the Github Actions.') |
13 | | - process.exit(0) |
14 | | -} |
15 | 17 | const newChangelog = process.env.VSCODE_WDIO_RELEASE_NOTE |
16 | 18 | if (!newChangelog) { |
17 | 19 | console.error('The release note is not set. please set as environment variable `VSCODE_WDIO_RELEASE_NOTE`') |
18 | 20 | process.exit(1) |
19 | 21 | } |
20 | 22 |
|
| 23 | +const repo = process.env.GITHUB_REPOSITORY || '' |
| 24 | +const [owner, repoName] = repo.split('/') |
| 25 | +if (owner !=='webdriverio' || repoName !== 'vscode-webdriverio'){ |
| 26 | + console.error(`This repository is not correct repository. (Current: ${repo})`) |
| 27 | + process.exit(1) |
| 28 | +} |
| 29 | + |
| 30 | +if (process.env.VSCODE_WDIO_DRY_RUN === 'yes') { |
| 31 | + console.log('*---- DRY RUN ----*') |
| 32 | + console.log(`tag_name: v${pkg.version}`) |
| 33 | + console.log(`name: v${pkg.version}`) |
| 34 | + console.log(newChangelog) |
| 35 | + process.exit(0) |
| 36 | +} |
| 37 | +console.log(`Creating Github Release: v${pkg.version}`) |
21 | 38 | api.repos.createRelease({ |
22 | 39 | owner: 'webdriverio', |
23 | 40 | repo: 'vscode-webdriverio', |
24 | 41 | tag_name: `v${pkg.version}`, |
25 | 42 | name: `v${pkg.version}`, |
26 | 43 | body: newChangelog, |
27 | 44 | }) |
| 45 | +console.log(`Created Github Release: v${pkg.version}`) |
0 commit comments