mirror of
https://github.com/wagoid/commitlint-github-action.git
synced 2025-11-07 16:06:56 +00:00
Merge pull request #46 from wagoid/ci/add-release-workflow
ci: add release job
This commit is contained in:
commit
9bda486b02
6 changed files with 1140 additions and 104 deletions
15
.github/tasks/actionYamlUpdater.js
vendored
Normal file
15
.github/tasks/actionYamlUpdater.js
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
const yaml = require('yaml')
|
||||
|
||||
yaml.scalarOptions.str.fold.lineWidth = 100
|
||||
|
||||
const versionRegex = /\d+\.\d+\.\d+/
|
||||
|
||||
module.exports.readVersion = contents =>
|
||||
yaml.parse(contents).runs.image.match(versionRegex)[0]
|
||||
|
||||
module.exports.writeVersion = (contents, version) => {
|
||||
const actionFile = yaml.parse(contents)
|
||||
actionFile.runs.image = actionFile.runs.image.replace(versionRegex, version)
|
||||
|
||||
return yaml.stringify(actionFile)
|
||||
}
|
||||
58
.github/workflows/ci.yml
vendored
58
.github/workflows/ci.yml
vendored
|
|
@ -10,5 +10,63 @@ jobs:
|
|||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '12.x'
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.npm
|
||||
**/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
- run: npm install
|
||||
- run: npm test -- --ci --coverage
|
||||
release:
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
if: "github.ref == 'refs/heads/master' && !contains(toJSON(github.event.commits.*.message), '[skip-ci]')"
|
||||
env:
|
||||
DOCKER_REGISTRY_URL: registry.hub.docker.com
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '12.x'
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.npm
|
||||
**/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
- run: npm install
|
||||
- name: Configure git user
|
||||
run: |
|
||||
git config user.email 'github-action@users.noreply.github.com'
|
||||
git config user.name 'GitHub Action'
|
||||
- name: Update versions and changelog
|
||||
run: npx standard-version
|
||||
- name: Set VERSION env var
|
||||
run: |
|
||||
version=`node -p "require('./package.json').version"`
|
||||
echo "::set-env name=VERSION::$version"
|
||||
- name: Login to docker registry
|
||||
env:
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
|
||||
run: docker login -u $DOCKER_USERNAME -p $DOCKER_TOKEN $DOCKER_REGISTRY_URL
|
||||
- name: Build image
|
||||
run: |
|
||||
docker build -t $DOCKER_REGISTRY_URL/wagoid/commitlint-github-action:$VERSION .
|
||||
- name: Push to docker registry
|
||||
run: |
|
||||
docker push $DOCKER_REGISTRY_URL/wagoid/commitlint-github-action:$VERSION
|
||||
- run: git push --follow-tags origin master
|
||||
- name: Create a git tag for the major version
|
||||
run: |
|
||||
major=`echo $VERSION | sed -E 's/([0-9]+)(.+)/\1/'`
|
||||
version_name="v$major"
|
||||
tag_heading="This version points to the latest version available (v$VERSION)."
|
||||
tag_body="This is necessary because currently Github Actions don't apply any semantic versioning matching when downloading versions."
|
||||
git tag -fa "$version_name" -m "$version_name" -m "$tag_heading" -m "$tag_body"
|
||||
git push -f origin "$version_name"
|
||||
|
|
|
|||
15
.versionrc.js
Normal file
15
.versionrc.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
const actionYamlUpdater = require.resolve('./.github/tasks/actionYamlUpdater')
|
||||
|
||||
module.exports = {
|
||||
packageFiles: ['package.json'],
|
||||
bumpFiles: [
|
||||
'package.json',
|
||||
'package-lock.json',
|
||||
{
|
||||
filename: 'action.yml',
|
||||
updater: actionYamlUpdater,
|
||||
},
|
||||
],
|
||||
releaseCommitMessageFormat:
|
||||
'chore(release): publish {{currentTag}} [skip-ci]',
|
||||
}
|
||||
38
action.yml
38
action.yml
|
|
@ -1,38 +1,38 @@
|
|||
name: 'Commit Linter'
|
||||
description: 'Lints Pull Request commit messages with commitlint'
|
||||
author: 'Wagner Santos'
|
||||
name: Commit Linter
|
||||
description: Lints Pull Request commit messages with commitlint
|
||||
author: Wagner Santos
|
||||
inputs:
|
||||
configFile:
|
||||
description: 'Commitlint config file'
|
||||
default: './commitlint.config.js'
|
||||
description: Commitlint config file
|
||||
default: ./commitlint.config.js
|
||||
required: false
|
||||
firstParent:
|
||||
description: >
|
||||
When set to true, we follow only the first parent commit when seeing a merge commit.
|
||||
More info in git-log docs https://git-scm.com/docs/git-log#Documentation/git-log.txt---first-parent
|
||||
default: 'true'
|
||||
When set to true, we follow only the first parent commit when seeing a merge commit. More info
|
||||
in git-log docs https://git-scm.com/docs/git-log#Documentation/git-log.txt---first-parent
|
||||
default: "true"
|
||||
required: false
|
||||
failOnWarnings:
|
||||
description: 'Whether you want to fail on warnings or not'
|
||||
default: 'false'
|
||||
description: Whether you want to fail on warnings or not
|
||||
default: "false"
|
||||
required: false
|
||||
helpURL:
|
||||
description: 'Link to a page explaining your commit message convention'
|
||||
default: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint'
|
||||
description: Link to a page explaining your commit message convention
|
||||
default: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
|
||||
required: false
|
||||
token:
|
||||
description: >
|
||||
Personal access token (PAT) used to interact with the GitHub API.
|
||||
By default, the automatic token provided by GitHub is used.
|
||||
You can see more info about GitHub's default token here: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
|
||||
Personal access token (PAT) used to interact with the GitHub API. By default, the automatic
|
||||
token provided by GitHub is used. You can see more info about GitHub's default token here:
|
||||
https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
|
||||
default: ${{ github.token }}
|
||||
required: false
|
||||
outputs:
|
||||
results:
|
||||
description: The error and warning messages for each one of the analyzed commits
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'docker://wagoid/commitlint-github-action:2.0.1'
|
||||
using: docker
|
||||
image: docker://wagoid/commitlint-github-action:2.0.1
|
||||
branding:
|
||||
icon: 'check-square'
|
||||
color: 'blue'
|
||||
icon: check-square
|
||||
color: blue
|
||||
|
|
|
|||
1109
package-lock.json
generated
1109
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -2,7 +2,8 @@
|
|||
"name": "commitlint-github-action",
|
||||
"version": "2.0.1",
|
||||
"description": "commitlint github action",
|
||||
"main": "index.js",
|
||||
"private": true,
|
||||
"main": "run.js",
|
||||
"scripts": {
|
||||
"test": "NODE_PATH=./node_modules jest",
|
||||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
|
||||
|
|
@ -39,7 +40,9 @@
|
|||
"jest": "^24.9.0",
|
||||
"prettier": "^1.18.2",
|
||||
"pretty-quick": "^1.11.1",
|
||||
"testdouble": "^3.12.4"
|
||||
"standard-version": "^9.0.0",
|
||||
"testdouble": "^3.12.4",
|
||||
"yaml": "^1.10.0"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue