From db34337e88659202f6679bc1b6e2ab5699a896d6 Mon Sep 17 00:00:00 2001 From: Andrea Lamparelli Date: Thu, 6 Jul 2023 10:17:14 +0200 Subject: [PATCH] build: automate release preparation --- .github/workflows/prepare-release.yml | 50 +++++++++++++++++++++++++++ .github/workflows/release.yml | 8 +++-- dist/cli/index.js | 2 +- package.json | 3 +- 4 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/prepare-release.yml diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 0000000..4d14141 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,50 @@ +# this workflow prepare the project for the next release, it will update changelog and version based on the previous commits. +# after that it will open a pull request for this change +name: "prepare release" + +on: + workflow_dispatch: + inputs: + options: + description: 'Additional release-it options' + required: false + default: '' + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + +jobs: + prepare-release: + name: Prepare release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Git config + run: | + git config user.name "${GITHUB_ACTOR}" + git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" + - name: Npm config + run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN + - run: npm ci + - name: Compute next version + run: | + next_version=$(npx release-it --release-version --no-git.requireCleanWorkingDir) + echo "NEXT_VERSION=${next_version}" >> $GITHUB_ENV + - name: Prepare the release changes + run: npm run release:prepare -- --ci --no-git.commit ${{ github.event.inputs.options }} + - name: Create Pull Request + uses: gr2m/create-or-update-pull-request-action@v1.x + with: + title: "chore: release v${{ env.NEXT_VERSION }}" + body: > + Creating changes for the next release. + branch: release/v${{ env.NEXT_VERSION }} + commit-message: "chore: release v${{ env.NEXT_VERSION }}" + team_reviewers: lampajr \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c3a60a4..34c968e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,12 +24,14 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18 - - name: git config + - name: Git config run: | git config user.name "${GITHUB_ACTOR}" git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" - - name: npm config + - name: Npm config run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN - run: npm ci # the version/changelog must be already updated on main branch using "npm run release:prepare" - - run: npm run release -- --ci --no-increment --no-git.commit ${{ github.event.inputs.options }} \ No newline at end of file + # or check prepare-release.yml workflow + - name: New version release + run: npm run release -- --ci --no-increment --no-git.commit ${{ github.event.inputs.options }} \ No newline at end of file diff --git a/dist/cli/index.js b/dist/cli/index.js index 315cd3a..e2288b4 100755 --- a/dist/cli/index.js +++ b/dist/cli/index.js @@ -23331,7 +23331,7 @@ module.exports = axios; /***/ ((module) => { "use strict"; -module.exports = JSON.parse('{"name":"@lampajr/bper","version":"3.1.0","description":"BPer is a tool to execute automatic git backporting.","author":"","license":"MIT","private":false,"main":"./dist/gha/index.js","bin":{"bper":"./dist/cli/index.js"},"files":["dist/cli/index.js"],"scripts":{"prepare":"husky install","clean":"rm -rf ./build ./dist","compile":"tsc -p tsconfig.json && tsc-alias -p tsconfig.json","package":"npm run package:cli && npm run package:gha","package:cli":"ncc build ./build/src/bin/cli.js -o dist/cli","package:gha":"ncc build ./build/src/bin/gha.js -o dist/gha","build":"npm run clean && npm run compile && npm run package","test":"jest","test:report":"npm test -- --coverage --testResultsProcessor=jest-sonar-reporter","lint":"eslint . --ext .ts","lint:fix":"npm run lint -- --fix","ts-node":"ts-node","postversion":"npm run build && git add dist && rm -rf build","release":"release-it","release:branch":"git checkout -b release/$(release-it --release-version) main","release:prepare":"npm run release:branch && release-it --ci --no-npm.publish --no-github.release --no-git.push --no-git.tag --no-git.requireUpstream"},"repository":{"type":"git","url":"git+https://github.com/lampajr/backporting.git"},"keywords":["backporting","pull-requests","github-action","cherry-pick"],"bugs":{"url":"https://github.com/lampajr/backporting/issues"},"homepage":"https://github.com/lampajr/backporting#readme","devDependencies":{"@commitlint/cli":"^17.4.0","@commitlint/config-conventional":"^17.4.0","@gitbeaker/rest":"^39.1.0","@kie/mock-github":"^1.1.0","@release-it/conventional-changelog":"^5.1.1","@types/fs-extra":"^9.0.13","@types/jest":"^29.2.4","@types/node":"^18.11.17","@typescript-eslint/eslint-plugin":"^5.47.0","@typescript-eslint/parser":"^5.47.0","@vercel/ncc":"^0.36.0","eslint":"^8.30.0","husky":"^8.0.2","jest":"^29.0.0","jest-sonar-reporter":"^2.0.0","release-it":"^15.6.0","semver":"^7.3.8","ts-jest":"^29.0.0","ts-node":"^10.8.1","tsc-alias":"^1.8.2","tsconfig-paths":"^4.1.0","typescript":"^4.9.3","@octokit/webhooks-types":"^6.8.0"},"dependencies":{"@actions/core":"^1.10.0","@octokit/rest":"^18.12.0","axios":"^1.4.0","commander":"^9.3.0","fs-extra":"^11.1.0","https":"^1.0.0","simple-git":"^3.15.1"}}'); +module.exports = JSON.parse('{"name":"@lampajr/bper","version":"3.1.0","description":"BPer is a tool to execute automatic git backporting.","author":"","license":"MIT","private":false,"main":"./dist/gha/index.js","bin":{"bper":"./dist/cli/index.js"},"files":["dist/cli/index.js"],"scripts":{"prepare":"husky install","clean":"rm -rf ./build ./dist","compile":"tsc -p tsconfig.json && tsc-alias -p tsconfig.json","package":"npm run package:cli && npm run package:gha","package:cli":"ncc build ./build/src/bin/cli.js -o dist/cli","package:gha":"ncc build ./build/src/bin/gha.js -o dist/gha","build":"npm run clean && npm run compile && npm run package","test":"jest","test:report":"npm test -- --coverage --testResultsProcessor=jest-sonar-reporter","lint":"eslint . --ext .ts","lint:fix":"npm run lint -- --fix","ts-node":"ts-node","postversion":"npm run build && git add dist && rm -rf build","release":"release-it","release:branch":"git checkout -b release/$(release-it --release-version) main","release:prepare":"release-it --no-npm.publish --no-github.release --no-git.push --no-git.tag --no-git.requireUpstream","release:prepare:all":"npm run release:branch && npm run release:prepare"},"repository":{"type":"git","url":"git+https://github.com/lampajr/backporting.git"},"keywords":["backporting","pull-requests","github-action","cherry-pick"],"bugs":{"url":"https://github.com/lampajr/backporting/issues"},"homepage":"https://github.com/lampajr/backporting#readme","devDependencies":{"@commitlint/cli":"^17.4.0","@commitlint/config-conventional":"^17.4.0","@gitbeaker/rest":"^39.1.0","@kie/mock-github":"^1.1.0","@release-it/conventional-changelog":"^5.1.1","@types/fs-extra":"^9.0.13","@types/jest":"^29.2.4","@types/node":"^18.11.17","@typescript-eslint/eslint-plugin":"^5.47.0","@typescript-eslint/parser":"^5.47.0","@vercel/ncc":"^0.36.0","eslint":"^8.30.0","husky":"^8.0.2","jest":"^29.0.0","jest-sonar-reporter":"^2.0.0","release-it":"^15.6.0","semver":"^7.3.8","ts-jest":"^29.0.0","ts-node":"^10.8.1","tsc-alias":"^1.8.2","tsconfig-paths":"^4.1.0","typescript":"^4.9.3","@octokit/webhooks-types":"^6.8.0"},"dependencies":{"@actions/core":"^1.10.0","@octokit/rest":"^18.12.0","axios":"^1.4.0","commander":"^9.3.0","fs-extra":"^11.1.0","https":"^1.0.0","simple-git":"^3.15.1"}}'); /***/ }), diff --git a/package.json b/package.json index 2d9edc5..2efe277 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ "postversion": "npm run build && git add dist && rm -rf build", "release": "release-it", "release:branch": "git checkout -b release/$(release-it --release-version) main", - "release:prepare": "npm run release:branch && release-it --ci --no-npm.publish --no-github.release --no-git.push --no-git.tag --no-git.requireUpstream" + "release:prepare": "release-it --no-npm.publish --no-github.release --no-git.push --no-git.tag --no-git.requireUpstream", + "release:prepare:all": "npm run release:branch && npm run release:prepare" }, "repository": { "type": "git",