-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(github-actions-release): properly tag to
latest
(#2472)
## Proposed change Properly tag to `latest` the actual latest version <!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context. --> ## Related issues <!-- Please make sure to follow the [contribution guidelines](https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md) --> *- No issue associated -* <!-- * 🐛 Fix #issue --> <!-- * 🐛 Fix resolves #issue --> <!-- * 🚀 Feature #issue --> <!-- * 🚀 Feature resolves #issue --> <!-- * Pull Request #issue -->
- Loading branch information
Showing
7 changed files
with
120 additions
and
36 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
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
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,21 @@ | ||
import { valid, lt } from 'semver'; | ||
|
||
export async function isLatest(versionInput?: string) { | ||
const newVersion = valid(versionInput); | ||
let data = ''; | ||
|
||
for await (const chunk of process.stdin) data += chunk; | ||
|
||
if (!newVersion) { | ||
console.error('Invalid version provided'); | ||
process.exit(1); | ||
} | ||
|
||
const isLatest = (JSON.parse(data) as string[]) | ||
.filter((tag) => !!tag) | ||
.map((tag) => ({ tag, version: valid(tag) })) | ||
.filter((item): item is { tag: string, version: string } => !!item.version) | ||
.every(({ version }) => lt(version, newVersion)); | ||
|
||
process.stdout.write(isLatest ? 'true' : 'false'); | ||
} |
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,15 @@ | ||
#!/usr/bin/env node | ||
import * as minimist from 'minimist'; | ||
import { getPreviousVersion } from './get-previous-version.cjs'; | ||
import { isLatest } from './is-latest.cjs'; | ||
|
||
const argv = minimist(process.argv.slice(2)); | ||
const cmd = argv._.at(0); | ||
|
||
if (cmd === 'previous-version') { | ||
void getPreviousVersion(argv._.at(1)); | ||
} else if (cmd === 'is-latest') { | ||
void isLatest(argv._.at(1)); | ||
} else { | ||
throw new Error(`Unknown command ${cmd}`) | ||
} |