feat(ci): auto release (#53)

* feat(ci): allow auto release

* chore(ci): simplify release

* chore: apply suggestions from code review
This commit is contained in:
Michael Kriese 2020-05-05 09:15:37 +02:00 committed by GitHub
parent 1dd736bd72
commit 6cef3bd05f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 94 additions and 56 deletions

View file

@ -7,10 +7,7 @@ jobs:
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: | if: |
github.event.commits[0].message == 'chore(release): trigger release process [ci release]' || startsWith(github.event.commits[0].message, 'fix(deps): update renovate/renovate docker tag ')
github.event.commits[0].message == 'chore(release): trigger release process [ci release][major]' ||
github.event.commits[0].message == 'chore(release): trigger release process [ci release][minor]' ||
github.event.commits[0].message == 'chore(release): trigger release process [ci release][patch]'
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2.1.0 uses: actions/checkout@v2.1.0
@ -30,30 +27,34 @@ jobs:
run: npm ci run: npm ci
- name: Release - name: Release
run: | run: |
readonly COMMIT_MESSAGE="${{ github.event.commits[0].message }}" SEMVER_REGEX="v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)"
if [[ "${COMMIT_MESSAGE: -11: -1}" == 'ci release' ]]; then if [[ ! "${{ github.event.commits[0].message }}" =~ ${SEMVER_REGEX} ]]; then
echo "::set-env name=NEXT_VERSION::$(npm run release:version --silent)" echo Not a semver like version - aborting: ${1}
npx --no-install standard-version exit 1
else
readonly RELEASE_TYPE="${COMMIT_MESSAGE: -6: -1}"
echo "::set-env name=NEXT_VERSION::$(
npm run release:version --silent -- --releaseAs "${RELEASE_TYPE}"
)"
npx --no-install standard-version --release-as "${RELEASE_TYPE}"
fi fi
NEXT_VERSION="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}"
MAJOR_VERSION="${BASH_REMATCH[1]}"
echo "::set-env name=NEXT_VERSION::${NEXT_VERSION}"
echo "::set-env name=MAJOR_VERSION::${MAJOR_VERSION}"
npm version ${NEXT_VERSION} -m "chore(release): ${NEXT_VERSION}"
git tag "v${MAJOR_VERSION}"
- name: Publish release - name: Publish release
run: git push --follow-tags run: |
- name: Publish GitHub release git push origin "v${NEXT_VERSION}"
uses: actions/create-release@v1.0.1 git push -f origin "v${MAJOR_VERSION}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # - name: Publish GitHub release
with: # uses: actions/create-release@v1.0.1
tag_name: v${{ env.NEXT_VERSION }} # env:
release_name: v${{ env.NEXT_VERSION }} # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
body: | # with:
See the the [changelog]( # tag_name: v${{ env.NEXT_VERSION }}
https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md # release_name: v${{ env.NEXT_VERSION }}
) for the changes included in this release. # body: |
# See the the [changelog](
# https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md
# ) for the changes included in this release.
prevent_failed_status: prevent_failed_status:
name: Prevent failed status when skipped name: Prevent failed status when skipped
runs-on: ubuntu-latest runs-on: ubuntu-latest

68
package-lock.json generated
View file

@ -1,6 +1,6 @@
{ {
"name": "github-action", "name": "github-action",
"version": "1.0.5", "version": "0.0.0-PLACEHOLDER",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -408,6 +408,12 @@
} }
} }
}, },
"@zeit/ncc": {
"version": "0.22.1",
"resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.22.1.tgz",
"integrity": "sha512-Qq3bMuonkcnV/96jhy9SQYdh39NXHxNMJ1O31ZFzWG9n52fR2DLtgrNzhj/ahlEjnBziMLGVWDbaS9sf03/fEw==",
"dev": true
},
"JSONStream": { "JSONStream": {
"version": "1.3.5", "version": "1.3.5",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz",
@ -1623,22 +1629,22 @@
} }
}, },
"es-abstract": { "es-abstract": {
"version": "1.17.0-next.1", "version": "1.17.5",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.0-next.1.tgz", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.5.tgz",
"integrity": "sha512-7MmGr03N7Rnuid6+wyhD9sHNE2n4tFSwExnU2lQl3lIo2ShXWGePY80zYaoMOmILWv57H0amMjZGHNzzGG70Rw==", "integrity": "sha512-BR9auzDbySxOcfog0tLECW8l28eRGpDpU3Dm3Hp4q/N+VtLTmyj4EUN088XZWQDW/hzj6sYRDXeOFsaAODKvpg==",
"dev": true, "dev": true,
"requires": { "requires": {
"es-to-primitive": "^1.2.1", "es-to-primitive": "^1.2.1",
"function-bind": "^1.1.1", "function-bind": "^1.1.1",
"has": "^1.0.3", "has": "^1.0.3",
"has-symbols": "^1.0.1", "has-symbols": "^1.0.1",
"is-callable": "^1.1.4", "is-callable": "^1.1.5",
"is-regex": "^1.0.4", "is-regex": "^1.0.5",
"object-inspect": "^1.7.0", "object-inspect": "^1.7.0",
"object-keys": "^1.1.1", "object-keys": "^1.1.1",
"object.assign": "^4.1.0", "object.assign": "^4.1.0",
"string.prototype.trimleft": "^2.1.0", "string.prototype.trimleft": "^2.1.1",
"string.prototype.trimright": "^2.1.0" "string.prototype.trimright": "^2.1.1"
} }
}, },
"es-to-primitive": { "es-to-primitive": {
@ -3657,9 +3663,9 @@
"dev": true "dev": true
}, },
"pidtree": { "pidtree": {
"version": "0.3.0", "version": "0.3.1",
"resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.3.0.tgz", "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.3.1.tgz",
"integrity": "sha512-9CT4NFlDcosssyg8KVFltgokyKZIFjoBxw8CTGy+5F38Y1eQWrt8tRayiUOXE+zVKQnYu5BR8JjCtvK3BcnBhg==", "integrity": "sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA==",
"dev": true "dev": true
}, },
"pify": { "pify": {
@ -4233,24 +4239,46 @@
"es-abstract": "^1.17.0-next.1" "es-abstract": "^1.17.0-next.1"
} }
}, },
"string.prototype.trimleft": { "string.prototype.trimend": {
"version": "2.1.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz",
"integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==",
"dev": true, "dev": true,
"requires": { "requires": {
"define-properties": "^1.1.3", "define-properties": "^1.1.3",
"function-bind": "^1.1.1" "es-abstract": "^1.17.5"
}
},
"string.prototype.trimleft": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.2.tgz",
"integrity": "sha512-gCA0tza1JBvqr3bfAIFJGqfdRTyPae82+KTnm3coDXkZN9wnuW3HjGgN386D7hfv5CHQYCI022/rJPVlqXyHSw==",
"dev": true,
"requires": {
"define-properties": "^1.1.3",
"es-abstract": "^1.17.5",
"string.prototype.trimstart": "^1.0.0"
} }
}, },
"string.prototype.trimright": { "string.prototype.trimright": {
"version": "2.1.1", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.2.tgz",
"integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", "integrity": "sha512-ZNRQ7sY3KroTaYjRS6EbNiiHrOkjihL9aQE/8gfQ4DtAC/aEBRHFJa44OmoWxGGqXuJlfKkZW4WcXErGr+9ZFg==",
"dev": true, "dev": true,
"requires": { "requires": {
"define-properties": "^1.1.3", "define-properties": "^1.1.3",
"function-bind": "^1.1.1" "es-abstract": "^1.17.5",
"string.prototype.trimend": "^1.0.0"
}
},
"string.prototype.trimstart": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz",
"integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==",
"dev": true,
"requires": {
"define-properties": "^1.1.3",
"es-abstract": "^1.17.5"
} }
}, },
"string_decoder": { "string_decoder": {

View file

@ -1,24 +1,23 @@
{ {
"name": "github-action", "name": "github-action",
"version": "1.0.5", "version": "0.0.0-PLACEHOLDER",
"description": "GitHub Action to run Renovate self-hosted.", "description": "GitHub Action to run Renovate self-hosted.",
"private": true, "private": true,
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
"build:dist": "cd src && ncc build ./index.ts -o ../dist",
"build": "cd src && ncc build ./index.ts -o ../dist",
"format": "prettier --write \"**/*.{js,jsx,vue,ts,css,less,scss,html,htm,json,md,markdown,yml,yaml}\"",
"format:file": "prettier --write",
"git:dist": "git add -f dist",
"lint": "concurrently npm:lint-es", "lint": "concurrently npm:lint-es",
"lint:fix": "concurrently npm:lint-es:fix", "lint:fix": "concurrently npm:lint-es:fix",
"lint-es": "eslint --ext .ts,.tsx,.js,.jsx,.json .", "lint-es": "eslint --ext .ts,.tsx,.js,.jsx,.json .",
"lint-es:file": "eslint --ext .ts,.tsx,.js,.jsx,.json", "lint-es:file": "eslint --ext .ts,.tsx,.js,.jsx,.json",
"lint-es:fix": "eslint --ext .ts,.tsx,.js,.jsx,.json --fix .", "lint-es:fix": "eslint --ext .ts,.tsx,.js,.jsx,.json --fix .",
"lint-es:file:fix": "eslint --ext .ts,.tsx,.js,.jsx,.json --fix", "lint-es:file:fix": "eslint --ext .ts,.tsx,.js,.jsx,.json --fix",
"format": "prettier --write \"**/*.{js,jsx,vue,ts,css,less,scss,html,htm,json,md,markdown,yml,yaml}\"", "start": "run-s build:dist && node dist",
"format:file": "prettier --write", "version": "run-s build:* git:*"
"release:version": "next-standard-version",
"release:changelog": "standard-version --dry-run --skip.commit=true --skip.tag=true",
"release:commit": "git commit --allow-empty -m \"chore(release): trigger release process [ci release]\"",
"release:message": "chalk -t \"Run {green.bold git push} to publish the release or {red.bold git reset HEAD^} to undo the release.\"",
"release": "run-s release:changelog release:commit release:message",
"build": "tsc"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -40,6 +39,7 @@
"@types/node": "13.13.4", "@types/node": "13.13.4",
"@typescript-eslint/eslint-plugin": "2.31.0", "@typescript-eslint/eslint-plugin": "2.31.0",
"@typescript-eslint/parser": "2.31.0", "@typescript-eslint/parser": "2.31.0",
"@zeit/ncc": "0.22.1",
"chalk-cli": "4.1.0", "chalk-cli": "4.1.0",
"concurrently": "5.2.0", "concurrently": "5.2.0",
"eslint": "6.8.0", "eslint": "6.8.0",

10
src/tsconfig.json Normal file
View file

@ -0,0 +1,10 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"sourceMap": false,
"declaration": false,
"rootDir": ".",
"outDir": "dist",
"types": ["node"]
}
}

View file

@ -3,7 +3,6 @@
"target": "es2020", "target": "es2020",
"module": "commonjs", "module": "commonjs",
"moduleResolution": "node", "moduleResolution": "node",
"declaration": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"esModuleInterop": true, "esModuleInterop": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,