Merge branch 'releases/v3' into add-support-for-private-repo

releases/v3
Tycho Bokdam 2022-05-26 07:22:42 +02:00 committed by GitHub
commit 97921d5c4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 74 additions and 34 deletions

View File

@ -3,6 +3,7 @@ on:
pull_request: pull_request:
branches: branches:
- master - master
- releases/*
jobs: jobs:
test-json: test-json:
@ -15,10 +16,9 @@ jobs:
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'"
- name: Generate changelog - name: Generate changelog
id: changelog id: changelog
@ -50,10 +50,9 @@ jobs:
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'"
- name: Generate changelog - name: Generate changelog
id: changelog id: changelog
@ -85,10 +84,9 @@ jobs:
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'"
- run: touch ./test-file-empty.json - run: touch ./test-file-empty.json
@ -126,7 +124,7 @@ jobs:
- run: git tag | xargs git tag -d - run: git tag | xargs git tag -d
- name: Create fake tag - name: Create fake tag
run: "git tag -a 'v0.55.8' -m 'v0.55.8'" run: "git tag -a 'v0.55.8' -m 'v0.55.8'"
- run: "git add . && git commit -m 'fix: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'fix: Added fake file so version will be bumped'"
- name: Generate changelog - name: Generate changelog
id: changelog id: changelog
@ -155,7 +153,7 @@ jobs:
- run: git tag | xargs git tag -d - run: git tag | xargs git tag -d
- name: Create fake tag - name: Create fake tag
run: "git tag -a 'v0.55.8' -m 'v0.55.8'" run: "git tag -a 'v0.55.8' -m 'v0.55.8'"
- run: "git add . && git commit -m 'fix: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'fix: Added fake file so version will be bumped'"
- name: Generate changelog - name: Generate changelog
id: changelog id: changelog
@ -180,10 +178,9 @@ jobs:
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'"
- run: git tag | xargs git tag -d - run: git tag | xargs git tag -d
@ -214,7 +211,7 @@ jobs:
- run: git tag | xargs git tag -d - run: git tag | xargs git tag -d
- name: Create fake tag - name: Create fake tag
run: "git tag -a 'v0.55.8' -m 'v0.55.8'" run: "git tag -a 'v0.55.8' -m 'v0.55.8'"
- run: "git add . && git commit -m 'fix: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'fix: Added fake file so version will be bumped'"
- name: Generate changelog - name: Generate changelog
id: changelog id: changelog
@ -239,10 +236,9 @@ jobs:
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'"
- name: Generate changelog - name: Generate changelog
id: changelog id: changelog
@ -310,10 +306,9 @@ jobs:
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'"
- run: touch ./test-file-empty.yaml - run: touch ./test-file-empty.yaml
@ -349,10 +344,9 @@ jobs:
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'"
- name: Generate changelog - name: Generate changelog
id: changelog id: changelog
@ -386,10 +380,9 @@ jobs:
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'"
- name: Generate changelog - name: Generate changelog
id: changelog id: changelog
@ -423,10 +416,9 @@ jobs:
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'"
- name: Generate changelog - name: Generate changelog
id: changelog id: changelog
@ -460,10 +452,9 @@ jobs:
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'"
- run: touch ./test-file-empty.toml - run: touch ./test-file-empty.toml
@ -500,10 +491,9 @@ jobs:
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'"
- run: test -f pre-commit.test.json && (echo should not be here yet && exit 1) || exit 0 - run: test -f pre-commit.test.json && (echo should not be here yet && exit 1) || exit 0
@ -533,10 +523,9 @@ jobs:
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'"
- run: test -f pre-changelog-generation.test.json && (echo should not be here yet && exit 1) || exit 0 - run: test -f pre-changelog-generation.test.json && (echo should not be here yet && exit 1) || exit 0
@ -568,10 +557,9 @@ jobs:
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'"
- name: Generate changelog - name: Generate changelog
id: changelog id: changelog
@ -610,10 +598,9 @@ jobs:
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'" - run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'"
- name: Generate Changelog - name: Generate Changelog
id: changelog id: changelog
@ -633,3 +620,42 @@ jobs:
else else
echo "Changelog config not applied" && exit 1 echo "Changelog config not applied" && exit 1
fi fi
test-skip-ci:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
path: "./"
- run: npm ci --prod
- run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'"
- run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'"
- name: Generate changelog
id: changelog
uses: ./
env:
ENV: 'dont-use-git'
EXPECTED_TAG: 'v1.5.0'
SKIP_CI: 'false'
with:
github-token: ${{ secrets.github_token }}
version-file: 'test-file.json'
skip-ci: 'false'
- name: Show file
run: |
echo "$(<test-file.json)"
- name: Test output
run: node ./test-output.js
env:
FILES: 'test-file.json'
EXPECTED_VERSION: '1.5.0'

View File

@ -24,6 +24,7 @@ This action will bump version, tag commit and generate a changelog with conventi
- **Optional** `fallback-version`: The fallback version, if no older one can be detected, or if it is the first one. Default `'0.1.0'` - **Optional** `fallback-version`: The fallback version, if no older one can be detected, or if it is the first one. Default `'0.1.0'`
- **Optional** `config-file-path`: Path to the conventional changelog config file. If set, the preset setting will be ignored - **Optional** `config-file-path`: Path to the conventional changelog config file. If set, the preset setting will be ignored
- **Optional** `pre-changelog-generation`: Path to the pre-changelog-generation script file. No hook by default. - **Optional** `pre-changelog-generation`: Path to the pre-changelog-generation script file. No hook by default.
- **Optional** `skip-ci`: Adds instruction to github to not consider the push something to rebuild. Default `true`.
### Pre-Commit hook ### Pre-Commit hook

View File

@ -113,6 +113,10 @@ inputs:
default: 'github.com' default: 'github.com'
required: false required: false
skip-ci:
description: 'Adds [skip ci] to commit message, to avoid triggering a new build'
default: 'true'
required: false
outputs: outputs:
changelog: changelog:

View File

@ -162,7 +162,7 @@ module.exports = new (class Git {
*/ */
testHistory = () => { testHistory = () => {
if (ENV === 'dont-use-git') { if (ENV === 'dont-use-git') {
const { EXPECTED_TAG, SKIPPED_COMMIT, EXPECTED_NO_PUSH, SKIPPED_PULL } = process.env const { EXPECTED_TAG, SKIPPED_COMMIT, EXPECTED_NO_PUSH, SKIPPED_PULL, SKIP_CI } = process.env
const expectedCommands = [ const expectedCommands = [
'git config user.name "Conventional Changelog Action"', 'git config user.name "Conventional Changelog Action"',
@ -175,7 +175,11 @@ module.exports = new (class Git {
if (!SKIPPED_COMMIT) { if (!SKIPPED_COMMIT) {
expectedCommands.push('git add .') expectedCommands.push('git add .')
expectedCommands.push(`git commit -m "chore(release): ${EXPECTED_TAG}"`) if (SKIP_CI === false) {
expectedCommands.push(`git commit -m "chore(release): ${EXPECTED_TAG}"`)
} else {
expectedCommands.push(`git commit -m "chore(release): ${EXPECTED_TAG} [skip ci]"`)
}
} }
expectedCommands.push(`git tag -a ${EXPECTED_TAG} -m "${EXPECTED_TAG}"`) expectedCommands.push(`git tag -a ${EXPECTED_TAG} -m "${EXPECTED_TAG}"`)

View File

@ -25,7 +25,7 @@ async function handleVersioningByExtension(ext, file, versionPath, releaseType)
async function run() { async function run() {
try { try {
const gitCommitMessage = core.getInput('git-message') let gitCommitMessage = core.getInput('git-message')
const gitUserName = core.getInput('git-user-name') const gitUserName = core.getInput('git-user-name')
const gitUserEmail = core.getInput('git-user-email') const gitUserEmail = core.getInput('git-user-email')
const gitPush = core.getInput('git-push').toLowerCase() === 'true' const gitPush = core.getInput('git-push').toLowerCase() === 'true'
@ -43,6 +43,11 @@ async function run() {
const conventionalConfigFile = core.getInput('config-file-path') const conventionalConfigFile = core.getInput('config-file-path')
const preChangelogGenerationFile = core.getInput('pre-changelog-generation') const preChangelogGenerationFile = core.getInput('pre-changelog-generation')
const gitUrl = core.getInput('git-url') const gitUrl = core.getInput('git-url')
const skipCi = core.getInput('skip-ci')
if (skipCi) {
gitCommitMessage += " [skip ci]"
}
core.info(`Using "${preset}" preset`) core.info(`Using "${preset}" preset`)
core.info(`Using "${gitCommitMessage}" as commit message`) core.info(`Using "${gitCommitMessage}" as commit message`)