5
0
Fork 0
mirror of https://github.com/wagoid/commitlint-github-action.git synced 2025-11-07 16:06:56 +00:00

ci: add release job

This commit is contained in:
Wagner Santos 2020-08-21 05:48:51 -03:00
parent 1ffd33d395
commit 7ccafb1f5f
6 changed files with 1132 additions and 104 deletions

15
.github/tasks/actionYamlUpdater.js vendored Normal file
View 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)
}

View file

@ -12,3 +12,53 @@ jobs:
node-version: '12.x' node-version: '12.x'
- run: npm install - run: npm install
- run: npm test -- --ci --coverage - 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
View 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]',
}

View file

@ -1,38 +1,38 @@
name: 'Commit Linter' name: Commit Linter
description: 'Lints Pull Request commit messages with commitlint' description: Lints Pull Request commit messages with commitlint
author: 'Wagner Santos' author: Wagner Santos
inputs: inputs:
configFile: configFile:
description: 'Commitlint config file' description: Commitlint config file
default: './commitlint.config.js' default: ./commitlint.config.js
required: false required: false
firstParent: firstParent:
description: > description: >
When set to true, we follow only the first parent commit when seeing a merge commit. When set to true, we follow only the first parent commit when seeing a merge commit. More info
More info in git-log docs https://git-scm.com/docs/git-log#Documentation/git-log.txt---first-parent in git-log docs https://git-scm.com/docs/git-log#Documentation/git-log.txt---first-parent
default: 'true' default: "true"
required: false required: false
failOnWarnings: failOnWarnings:
description: 'Whether you want to fail on warnings or not' description: Whether you want to fail on warnings or not
default: 'false' default: "false"
required: false required: false
helpURL: helpURL:
description: 'Link to a page explaining your commit message convention' description: Link to a page explaining your commit message convention
default: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint' default: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
required: false required: false
token: token:
description: > description: >
Personal access token (PAT) used to interact with the GitHub API. Personal access token (PAT) used to interact with the GitHub API. By default, the automatic
By default, the automatic token provided by GitHub is used. token provided by GitHub is used. You can see more info about GitHub's default token here:
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 https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
default: ${{ github.token }} default: ${{ github.token }}
required: false required: false
outputs: outputs:
results: results:
description: The error and warning messages for each one of the analyzed commits description: The error and warning messages for each one of the analyzed commits
runs: runs:
using: 'docker' using: docker
image: 'docker://wagoid/commitlint-github-action:2.0.1' image: docker://wagoid/commitlint-github-action:2.0.1
branding: branding:
icon: 'check-square' icon: check-square
color: 'blue' color: blue

1109
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,8 @@
"name": "commitlint-github-action", "name": "commitlint-github-action",
"version": "2.0.1", "version": "2.0.1",
"description": "commitlint github action", "description": "commitlint github action",
"main": "index.js", "private": true,
"main": "run.js",
"scripts": { "scripts": {
"test": "NODE_PATH=./node_modules jest", "test": "NODE_PATH=./node_modules jest",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s" "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
@ -39,7 +40,9 @@
"jest": "^24.9.0", "jest": "^24.9.0",
"prettier": "^1.18.2", "prettier": "^1.18.2",
"pretty-quick": "^1.11.1", "pretty-quick": "^1.11.1",
"testdouble": "^3.12.4" "standard-version": "^9.0.0",
"testdouble": "^3.12.4",
"yaml": "^1.10.0"
}, },
"husky": { "husky": {
"hooks": { "hooks": {