setup new versioning for release-start (#6244)

* setup new versioning for release-start

* delete bump version
This commit is contained in:
Filipe Freire 2023-08-10 10:04:28 +01:00 committed by GitHub
parent 9800ad5aee
commit 001a88af11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 94 deletions

View File

@ -62,7 +62,10 @@ jobs:
echo "INSO_VERSION=$(jq .version packages/insomnia-inso/package.json -rj)" >> $GITHUB_ENV
- name: Package inso
run: npm run inso-package
run: |
echo "Replacing electron binary with node binary"
node_modules/.bin/node-pre-gyp install --update-binary --directory node_modules/@getinsomnia/node-libcurl
npm run inso-package
env:
VERSION: ${{ env.INSO_VERSION }}

View File

@ -46,7 +46,7 @@ jobs:
- name: Bump version
shell: bash
run: BUILD_REF="$(git rev-parse --short HEAD)${{ github.event_name == 'pull_request' && '.pr-$PR_NUMBER' || '' }}" npm run app-bump-version
run: npm --workspaces version prerelease --preid="$(git rev-parse --short HEAD)${{ github.event_name == 'pull_request' && '.pr-$PR_NUMBER' || '' }}" --no-git-tag-version
- name: Package
shell: bash

View File

@ -12,39 +12,18 @@ on:
- beta
- stable
version:
required: true
description: version of the release (e.g. 2022.1.0)
iteration:
required: false
description: iteration of the release, used for non-stable releases (version-channel.iteration) (e.g. 0, 1, 2, 3 ...)
default: '0'
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}${{ github.event.inputs.channel != 'stable' && format('-{0}.{1}', github.event.inputs.channel, github.event.inputs.iteration) || '' }}
RELEASE_BRANCH: release/${{ github.event.inputs.version }}${{ github.event.inputs.channel != 'stable' && format('-{0}.{1}', github.event.inputs.channel, github.event.inputs.iteration) || '' }}
description: force version of the release (e.g. 2022.1.0)
jobs:
setup-release-branch:
runs-on: ubuntu-latest
steps:
- name: Create Branch # Create a branch if it doesn't exist
uses: peterjgrainger/action-create-branch@v2.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: ${{ env.RELEASE_BRANCH }}
- name: Checkout branch # Check out the new branch
- name: Checkout branch
uses: actions/checkout@v3
with:
ref: ${{ env.RELEASE_BRANCH }}
persist-credentials: false
- name: Configure Git user
id: configure_git_user
uses: Homebrew/actions/git-user-config@master
with:
username: ${{ (github.event_name == 'workflow_dispatch' && github.actor) || 'insomnia-infra' }}
ref: develop
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
@ -56,37 +35,43 @@ jobs:
- name: Install packages
run: npm ci
- name: App version (stable, no version doing patch)
if: github.event.inputs.channel == 'stable' && !github.event.inputs.version
run: npm --workspaces version patch
- name: App version (stable)
if: github.event.inputs.channel == 'stable'
run: npm --workspaces version minor
if: github.event.inputs.channel == 'stable' && github.event.inputs.version
run: npm --workspaces version "${{ github.event.inputs.version }}"
- name: App version (alpha/beta)
if: github.event.inputs.channel != 'stable'
run: npm --workspaces version prerelease --preid "${{ github.event.inputs.channel }}"."${{ github.event.inputs.iteration == '0' && 'preminor' || 'prerelease' }}"
run: npm --workspaces version --preid "${{ github.event.inputs.channel }}" prerelease
- name: Config version
run: APP_VERSION="${{ env.RELEASE_VERSION }}" npm run app-bump-version
- name: Get version
shell: bash
run: |
echo "RELEASE_VERSION=$(node -e "console.log(require('./packages/insomnia/package.json').version)")" >> $GITHUB_ENV
echo "RELEASE_BRANCH=release/$(node -e "console.log(require('./packages/insomnia/package.json').version)")" >> $GITHUB_ENV
- name: Commit
- name: Configure Git user
id: configure_git_user
uses: Homebrew/actions/git-user-config@master
with:
username: ${{ (github.event_name == 'workflow_dispatch' && github.actor) || 'insomnia-infra' }}
- name: Git create branch locally # Check out the new branch
run: git checkout -b ${{ env.RELEASE_BRANCH }}
- name: Git Commit
run: git commit -am "Bump app version to ${{ env.RELEASE_VERSION }}"
- name: Push changes
- name: Git Push changes
run: |
remote_repo="https://${GITHUB_ACTOR}:${RELEASE_GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git push "${remote_repo}" --follow-tags
env:
RELEASE_GH_TOKEN: ${{ secrets.RELEASE_GH_TOKEN }}
create-pull-request:
needs: setup-release-branch
runs-on: ubuntu-latest
steps:
- name: Checkout branch # Check out the new branch
uses: actions/checkout@v3
with:
ref: ${{ env.RELEASE_BRANCH }}
fetch-depth: 0
- name: Run the Action
uses: devops-infra/action-pull-request@v0.4.2
with:

View File

@ -37,7 +37,6 @@
"watch:app": "npm run build:main.min.js --workspace=packages/insomnia && npm run start:dev-server --workspace=packages/insomnia",
"app-build": "npm run build --workspace=packages/insomnia",
"app-package": "npm run build --workspace=packages/insomnia && npm run package --workspace=packages/insomnia",
"app-bump-version": "npm run bump-version --workspace=packages/insomnia",
"test:smoke:dev": "npm run test:dev --workspace=packages/insomnia-smoke-test -- --project=Smoke",
"test:smoke:build": "npm run test:build --workspace=packages/insomnia-smoke-test -- --project=Smoke",
"test:smoke:package": "npm run test:package --workspace=packages/insomnia-smoke-test -- --project=Smoke",

View File

@ -21,7 +21,6 @@
"build:app": "esr --cache ./scripts/build.ts --noErrorTruncation",
"build:main.min.js": "cross-env NODE_ENV=development esr esbuild.main.ts",
"build:sr": "esr esbuild.sr.ts && tsc --build tsconfig.build.sr.json",
"bump-version": "esr scripts/bumpVersion.ts",
"lint": "eslint . --ext .js,.ts,.tsx --cache",
"package": "cross-env USE_HARD_LINKS=false electron-builder build --config electron-builder.config.js",
"start": "concurrently -n dev,app --kill-others \"npm run start:dev-server\" \"npm run start:electron\"",

View File

@ -1,48 +0,0 @@
import { writeFileSync } from 'fs';
import path from 'path';
import packageLockConfig from '../../../package-lock.json';
import packageConfig from '../package.json';
// Start build if ran from CLI
if (require.main === module) {
process.nextTick(async () => {
try {
await module.exports.start();
} catch (err) {
console.log('[build] ERROR:', err);
process.exit(1);
}
});
}
export const start = async () => {
// Used to overwrite the app version entirely for release builds
let appVersionOverride = process.env.APP_VERSION;
// Used to append a build ref to the end of an existing app version for non-release builds
const buildRef = process.env.BUILD_REF;
if (buildRef) {
// Ignore any existing semver prerelease/build tags
const cleanedVersion = packageConfig.version.match(/^(\d{4}\.\d+\.\d+)/);
if (!cleanedVersion) {
console.log('[build] Invalid version found in app config');
process.exit(1);
}
appVersionOverride = `${cleanedVersion[1]}-dev+${buildRef}`;
}
if (!appVersionOverride) {
console.log('[build] Missing app version override, please ensure the environment variables APP_VERSION or BUILD_REF are set correctly.');
process.exit(1);
}
console.log('Overwriting app config version:', appVersionOverride);
packageConfig.version = appVersionOverride;
writeFileSync(path.resolve(__dirname, '../package.json'), JSON.stringify(packageConfig, null, 2) + '\n');
packageLockConfig.version = appVersionOverride;
packageLockConfig.packages[''].version = appVersionOverride;
writeFileSync(path.resolve(__dirname, '../package-lock.json'), JSON.stringify(packageLockConfig, null, '\t') + '\n');
};