-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
38 lines (33 loc) · 1.05 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import * as core from '@actions/core';
import { context } from '@actions/github';
import { getChangedFiles } from './getChangedFiles';
import { getNewVersion } from './getNewVersion';
import { createRelease } from './createRelease';
async function run() {
try {
if (context.eventName !== 'push') {
core.setFailed('Generate Release action can only run on push event');
return;
}
if (!process.env.GITHUB_WORKSPACE) {
core.setFailed('🤔 Generate Release cannot find directory with your repo');
return;
}
const packagePath = core
.getInput('track-file', { required: false })
.replace(/^\//, '');
const changedFiles = await getChangedFiles(packagePath);
console.log(changedFiles);
if (changedFiles[packagePath]) {
const newVersion = getNewVersion(changedFiles[packagePath]);
console.log(`New version: ${newVersion}`);
if (newVersion) {
await createRelease(newVersion);
}
}
} catch (error: any) {
console.log(error);
core.setFailed(error.message);
}
}
run();