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>
This commit is contained in:
Filipe Freire 2022-02-10 15:32:33 +00:00 committed by GitHub
parent e1b4bb2def
commit 1160b4a09c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 84 additions and 26 deletions

View File

@ -264,5 +264,3 @@ jobs:
run: npm run bootstrap
- name: Release app
run: npm run app-release
env:
BUILD_TARGETS: AppImage,deb,tar.gz,rpm,snap

53
.github/workflows/release-recurring.yml vendored Normal file
View File

@ -0,0 +1,53 @@
name: Release recurring
# This workflow bakes executables of the major platforms for Testing purposes
on:
workflow_dispatch:
push:
branches:
- develop
pull_request:
types:
- opened
- synchronize
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-upload-artifacts:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: "macos-latest"
build-targets: "zip"
- os: "windows-latest"
build-targets: "portable"
- os: "ubuntu-latest"
build-targets: "tar.gz"
steps:
- name: Checkout branch
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
- name: Bootstrap packages
run: npm run bootstrap
- name: Package
shell: bash
run: BUILD_REF="$(git rev-parse --short HEAD)" BUILD_TARGETS='${{ matrix.build-targets }}' npm run app-package
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
if-no-files-found: ignore
name: ${{ matrix.os }}-artifacts-${{ github.run_number }}
path: |
packages/insomnia-app/dist/*.exe
packages/insomnia-app/dist/*.tar.gz
packages/insomnia-app/dist/*.zip

View File

@ -34,8 +34,8 @@
"storybook-start": "npm run storybook --prefix packages/insomnia-components",
"storybook-legacy-start": "npm run storybook --prefix packages/insomnia-app",
"preinstall": "node ./scripts/check-version.js",
"app-build:smoke": "cross-env SMOKE_TEST=true npm run app-build",
"app-package:smoke": "cross-env SMOKE_TEST=true npm run app-package",
"app-build:smoke": "cross-env npm run app-build",
"app-package:smoke": "cross-env npm run app-package",
"test:smoke:dev": "npm run test:dev --prefix packages/insomnia-smoke-test",
"test:smoke:build": "npm run test:build --prefix packages/insomnia-smoke-test",
"test:smoke:package": "npm run test:package --prefix packages/insomnia-smoke-test",

View File

@ -79,7 +79,11 @@
"synopsis": "__SYNOPSIS__",
"category": "Development",
"target": [
"AppImage"
"AppImage",
"deb",
"tar.gz",
"rpm",
"snap"
]
}
}

View File

@ -192,14 +192,12 @@ const generatePackageJson = async (relBasePkg: string, relOutPkg: string) => {
export const start = async ({ forceFromGitRef }: { forceFromGitRef: boolean }) => {
const buildContext = getBuildContext(forceFromGitRef);
const { gitRef, smokeTest, version } = buildContext;
const { gitRef, version } = buildContext;
if (smokeTest) {
console.log('[build] Starting build to smoke test');
} else {
if (forceFromGitRef) { // Require a valid git tag for release builds
if (!version) {
if (!gitRef) {
console.log('[build] No git ref found. Check for the presence of a `GIT_TAG`, `GITHUB_REF`, `TRAVIS_TAG`, or `TRAVIS_CURRENT_BRANCH` environment variable');
console.log('[build] No git ref found. Check for the presence of a `GIT_TAG`, `GITHUB_REF` environment variable');
} else {
console.log(`[build] git ref \`${gitRef}\` found`);
}
@ -213,6 +211,22 @@ export const start = async ({ forceFromGitRef }: { forceFromGitRef: boolean }) =
process.exit(1);
}
console.log(`[build] Starting build for ref "${gitRef}"`);
} else {
console.log('[build] Starting build');
const buildRef = process.env.BUILD_REF;
if (buildRef) {
// Ignore any existing semver prerelease/build tags
const cleanedVersion = appConfig.version.match(/^(\d{4}\.\d+\.\d)/);
if (!cleanedVersion) {
console.log('[build] Invalid version found in app config');
process.exit(1);
}
const fullVersion = `${cleanedVersion[1]}-dev+${buildRef}`;
console.log('Overwriting app config version:', fullVersion);
appConfig.version = fullVersion;
writeFileSync(path.resolve(__dirname, '../config/config.json'), JSON.stringify(appConfig, null, 2) + '\n');
}
}
console.log(`[build] npm: ${childProcess.spawnSync('npm', ['--version']).stdout}`.trim());

View File

@ -3,22 +3,17 @@ export interface BuildContext {
channel?: string | null;
gitCommit?: string | null;
gitRef?: string | null;
smokeTest: boolean;
version: string | null;
}
const fromGitRef = (): BuildContext => {
const {
GIT_TAG,
GITHUB_REF,
GITHUB_SHA,
TRAVIS_TAG,
TRAVIS_COMMIT,
TRAVIS_CURRENT_BRANCH,
} = process.env;
const gitCommit = GITHUB_SHA || TRAVIS_COMMIT;
const gitRef = GIT_TAG || GITHUB_REF || TRAVIS_TAG || TRAVIS_CURRENT_BRANCH || '';
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;
@ -30,7 +25,6 @@ const fromGitRef = (): BuildContext => {
channel,
gitCommit,
gitRef,
smokeTest: false,
version,
};
};
@ -40,12 +34,7 @@ export const getBuildContext = (forceFromGitRef: boolean) => {
return fromGitRef();
}
if (process.env.SMOKE_TEST) {
return {
smokeTest: true,
version: '0.0.1',
} as const;
}
return fromGitRef();
return {
version: '0.0.1-dev+unknown',
} as const;
};