insomnia/packages/insomnia-app/scripts/getBuildContext.ts
Filipe Freire d985f5f3be Recurring releases of insomnia app (INS-1429) (#4474)
* Update default electron-builder targetgs

* Allow setting a build ref

Changes the default version to `0.0.1-dev+unknown`, so that build/packaging can be easily ran locally without setting any environment variables.

* Adds recurring release workflow

New workflow that'll pre-bake artifacts when there's changes on PRs or on develop.

Artifacts can be used for all platforms to test out a PR or latest develop without the need to build locally.

Co-Authored-By: David Marby <david@dmarby.se>

* Make recurring flow independent from Test flow

Co-Authored-By: David Marby <david@dmarby.se>

* Use setup-node@v2

Co-Authored-By: David Marby <david@dmarby.se>

* Update .github/workflows/release-recurring.yml

Co-authored-by: David Marby <david@dmarby.se>

* It's always the single quotes 🙏 😚

* Use bash shell

* Disable fail-fast

* Add cancel-in-progress setting to recurring releases

If someone pushes a new commit, triggering a new recurring job on a PR or develop, we cancel ongoing workflow.

Co-Authored-By: David Marby <david@dmarby.se>

* Change concurrency setting to workflow level

Co-Authored-By: David Marby <david@dmarby.se>

Co-authored-by: David Marby <david@dmarby.se>
2022-03-01 15:18:47 +01:00

41 lines
830 B
TypeScript

export interface BuildContext {
app?: string | null;
channel?: string | null;
gitCommit?: string | null;
gitRef?: string | null;
version: string | null;
}
const fromGitRef = (): BuildContext => {
const {
GITHUB_REF,
GITHUB_SHA,
} = process.env;
const gitCommit = GITHUB_SHA;
const gitRef = GITHUB_REF || '';
const tagMatch = gitRef.match(/(core)@(\d{4}\.\d+\.\d+(-(alpha|beta)\.\d+)?)$/);
const app = tagMatch ? tagMatch[1] : null;
const version = tagMatch ? tagMatch[2] : null;
const channel = tagMatch ? tagMatch[4] : 'stable';
return {
app,
channel,
gitCommit,
gitRef,
version,
};
};
export const getBuildContext = (forceFromGitRef: boolean) => {
if (forceFromGitRef) {
return fromGitRef();
}
return {
version: '0.0.1-dev+unknown',
} as const;
};