-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: Support monorepo based tag names. (#4)
- Loading branch information
Showing
5 changed files
with
65 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,23 +23,54 @@ function getRoot(): string { | |
return process.env.GITHUB_WORKSPACE!; | ||
} | ||
|
||
let TAG: string | null = null; | ||
let PLUGIN: string | null = null; | ||
let PLUGIN_VERSION: string | null = null; | ||
|
||
function detectVersion() { | ||
function detectVersionAndProject() { | ||
const ref = process.env.GITHUB_REF; | ||
|
||
if (ref && ref.startsWith('refs/tags/')) { | ||
let version = ref.replace('refs/tags/', ''); | ||
const tag = ref.replace('refs/tags/', ''); | ||
let project = ''; | ||
let version = ''; | ||
|
||
core.info(`Detected tag ${tag}`); | ||
TAG = tag; | ||
|
||
// project-v1.0.0 | ||
if (project.includes('-')) { | ||
const lastIndex = project.lastIndexOf('-'); | ||
|
||
project = project.slice(0, lastIndex); | ||
version = project.slice(lastIndex + 1); | ||
} | ||
|
||
// [email protected] | ||
else if (project.includes('@')) { | ||
[project, version] = project.split('@'); | ||
} | ||
|
||
// v1.0.0 | ||
else { | ||
version = tag; | ||
} | ||
|
||
if (version.startsWith('v') || version.startsWith('V')) { | ||
version = version.slice(1); | ||
} | ||
|
||
core.setOutput('tag-version', version); | ||
|
||
core.info(`Detected tagged version ${version}`); | ||
core.setOutput('tagged-version', version); | ||
|
||
PLUGIN_VERSION = version; | ||
|
||
if (project) { | ||
core.info(`Detected tagged project ${project}`); | ||
core.setOutput('tagged-project', project); | ||
|
||
PLUGIN = project; | ||
} | ||
} | ||
} | ||
|
||
|
@@ -133,6 +164,11 @@ async function findBuildablePackages() { | |
return; | ||
} | ||
|
||
if (PLUGIN && pkg.name !== PLUGIN) { | ||
core.info(`Skipping ${pkg.name}, not associated to tag ${TAG}`); | ||
return; | ||
} | ||
|
||
core.info(`Found ${pkg.name}, loading manifest ${pkg.manifest_path}, checking targets`); | ||
|
||
const manifest = TOML.parse(fs.readFileSync(pkg.manifest_path, 'utf8')) as Manifest; | ||
|
@@ -243,10 +279,11 @@ async function extractChangelog() { | |
async function run() { | ||
core.setOutput('built', 'false'); | ||
core.setOutput('changelog-entry', ''); | ||
core.setOutput('tag-version', ''); | ||
core.setOutput('tagged-project', ''); | ||
core.setOutput('tagged-version', ''); | ||
|
||
try { | ||
detectVersion(); | ||
detectVersionAndProject(); | ||
|
||
const builds = await findBuildablePackages(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.