build: automate release preparation

This commit is contained in:
Andrea Lamparelli 2023-07-06 10:17:14 +02:00
parent 729b380b05
commit db34337e88
4 changed files with 58 additions and 5 deletions

50
.github/workflows/prepare-release.yml vendored Normal file
View file

@ -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

View file

@ -24,12 +24,14 @@ jobs:
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 18 node-version: 18
- name: git config - name: Git config
run: | run: |
git config user.name "${GITHUB_ACTOR}" git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" 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 config set //registry.npmjs.org/:_authToken $NPM_TOKEN
- run: npm ci - run: npm ci
# the version/changelog must be already updated on main branch using "npm run release:prepare" # 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 }} # or check prepare-release.yml workflow
- name: New version release
run: npm run release -- --ci --no-increment --no-git.commit ${{ github.event.inputs.options }}

2
dist/cli/index.js vendored
View file

@ -23331,7 +23331,7 @@ module.exports = axios;
/***/ ((module) => { /***/ ((module) => {
"use strict"; "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"}}');
/***/ }), /***/ }),

View file

@ -28,7 +28,8 @@
"postversion": "npm run build && git add dist && rm -rf build", "postversion": "npm run build && git add dist && rm -rf build",
"release": "release-it", "release": "release-it",
"release:branch": "git checkout -b release/$(release-it --release-version) main", "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": { "repository": {
"type": "git", "type": "git",