From 001a88af11c252ec616cfdaae3a900d57dfd3f91 Mon Sep 17 00:00:00 2001 From: Filipe Freire Date: Thu, 10 Aug 2023 10:04:28 +0100 Subject: [PATCH] setup new versioning for release-start (#6244) * setup new versioning for release-start * delete bump version --- .github/workflows/release-build.yml | 5 +- .github/workflows/release-recurring.yml | 2 +- .github/workflows/release-start.yml | 69 ++++++++++-------------- package.json | 1 - packages/insomnia/package.json | 1 - packages/insomnia/scripts/bumpVersion.ts | 48 ----------------- 6 files changed, 32 insertions(+), 94 deletions(-) delete mode 100644 packages/insomnia/scripts/bumpVersion.ts diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 8101dcb8b..a118a588d 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -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 }} diff --git a/.github/workflows/release-recurring.yml b/.github/workflows/release-recurring.yml index f2212a334..7680e460f 100644 --- a/.github/workflows/release-recurring.yml +++ b/.github/workflows/release-recurring.yml @@ -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 diff --git a/.github/workflows/release-start.yml b/.github/workflows/release-start.yml index 539920c6f..d58877c60 100644 --- a/.github/workflows/release-start.yml +++ b/.github/workflows/release-start.yml @@ -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: diff --git a/package.json b/package.json index 0c30bf370..7e45eb121 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/insomnia/package.json b/packages/insomnia/package.json index 4b6675dfc..587ac3ee9 100644 --- a/packages/insomnia/package.json +++ b/packages/insomnia/package.json @@ -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\"", diff --git a/packages/insomnia/scripts/bumpVersion.ts b/packages/insomnia/scripts/bumpVersion.ts deleted file mode 100644 index 92e9ef7c5..000000000 --- a/packages/insomnia/scripts/bumpVersion.ts +++ /dev/null @@ -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'); -};