-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: convert get-tags to esm (#946)
<!-- For Coveo Employees only. Fill this section. CDX-764 --> ## Proposed changes When I replaced the get latest tag function we had by the `@coveo/semantic-monorepo-tools` one, I forgot that `@coveo/semantic-monorepo-tools` is an ESM package. Fix: port the get-tags script to esm. ## Testing https://github.com/coveo/cli/actions/runs/3102070548
- Loading branch information
1 parent
e8d28b9
commit f4ac6be
Showing
3 changed files
with
40 additions
and
39 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {warning, exportVariable, setFailed} from '@actions/core'; | ||
import {context} from '@actions/github'; | ||
import {getLastTag} from '@coveo/semantic-monorepo-tools'; | ||
|
||
const releaseTagRegExp = /refs\/tags\/(release-\d+)/; | ||
const releaseTagPrefix = 'release-'; | ||
const cliTagPrefix = '@coveo/cli@'; | ||
|
||
const getReleaseTag = async () => { | ||
if (context.eventName === 'workflow_dispatch') { | ||
return context.payload.inputs.version; | ||
} | ||
if (context.eventName === 'release') { | ||
const ref = context.ref; | ||
const match = releaseTagRegExp.exec(ref); | ||
if (match && match[1]) { | ||
return match[1]; | ||
} | ||
} | ||
warning('Tag acquisition failed, fallbacking to the latest'); | ||
return getLastTag(releaseTagPrefix); | ||
}; | ||
|
||
const getCliVersion = async () => | ||
'v' + (await getLastTag(cliTagPrefix)).split(cliTagPrefix)[1]; | ||
|
||
(async () => { | ||
try { | ||
const releaseTag = await getReleaseTag(); | ||
exportVariable('tag', releaseTag); | ||
const cliReleaseVersion = await getCliVersion(); | ||
exportVariable('cliversion', cliReleaseVersion); | ||
} catch (error) { | ||
setFailed(error.message); | ||
} | ||
})(); |