From 173f3f38751831923b72e7cc5bad14e76e0b725b Mon Sep 17 00:00:00 2001 From: lotyp Date: Fri, 10 May 2024 02:57:13 +0300 Subject: [PATCH 1/2] ci: auto release support by release-please action --- .github/.commitlint.config.mjs | 44 ++++++++++++++++ .github/.cz.config.js | 65 ++++++++++++++++++++++++ .github/.release-please-config.json | 72 +++++++++++++++++++++++++++ .github/.release-please-manifest.json | 3 ++ .github/workflows/create-release.yml | 27 ++++++++++ 5 files changed, 211 insertions(+) create mode 100644 .github/.commitlint.config.mjs create mode 100644 .github/.cz.config.js create mode 100644 .github/.release-please-config.json create mode 100644 .github/.release-please-manifest.json create mode 100644 .github/workflows/create-release.yml diff --git a/.github/.commitlint.config.mjs b/.github/.commitlint.config.mjs new file mode 100644 index 00000000..49f1f956 --- /dev/null +++ b/.github/.commitlint.config.mjs @@ -0,0 +1,44 @@ +// More info: https://github.com/wayofdev/npm-shareable-configs/blob/master/packages/commitlint-config/src/index.js +const automaticCommitPattern = /^chore\(release\):.*\[skip ci]/ + +export default { + extends: ['@commitlint/config-conventional'], + /* + This resolves a linting conflict between commitlint's body-max-line-length + due to @semantic-release/git putting release notes in the commit body + https://github.com/semantic-release/git/issues/331 + */ + ignores: [(commitMessage) => automaticCommitPattern.test(commitMessage)], + rules: { + 'body-leading-blank': [1, 'always'], + 'body-max-line-length': [2, 'always', 120], + 'footer-leading-blank': [1, 'always'], + 'footer-max-line-length': [2, 'always', 120], + 'header-max-length': [2, 'always', 100], + 'scope-case': [2, 'always', 'lower-case'], + 'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']], + 'subject-empty': [2, 'never'], + 'subject-full-stop': [2, 'never', '.'], + 'type-case': [2, 'always', 'lower-case'], + 'type-empty': [2, 'never'], + 'type-enum': [ + 2, + 'always', + [ + 'feat', // New feature + 'fix', // Bug fix + 'perf', // Performance improvement + 'docs', // Documentation changes + 'style', // Code style update (formatting, missing semi colons, etc) + 'deps', // Dependency updates + 'refactor', // Code refactoring + 'ci', // Continuous integration changes + 'test', // Adding missing tests + 'revert', // Revert to a previous commit + 'build', // Changes that affect the build system + 'chore', // Other changes that don't modify src or test files + 'security', // Security improvements + ], + ], + }, +} diff --git a/.github/.cz.config.js b/.github/.cz.config.js new file mode 100644 index 00000000..5f951c6c --- /dev/null +++ b/.github/.cz.config.js @@ -0,0 +1,65 @@ +// @see https://cz-git.qbb.sh/config/#configure-template +module.exports = { + alias: { fd: 'docs: fix typos' }, + messages: { + type: 'Select the type of change that you\'re committing:', + scope: 'Denote the SCOPE of this change (optional):', + customScope: 'Denote the SCOPE of this change:', + subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n', + body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n', + breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n', + footerPrefixesSelect: 'Select the ISSUES type of changeList by this change (optional):', + customFooterPrefix: 'Input ISSUES prefix:', + footer: 'List any ISSUES by this change. E.g.: #31, #34:\n', + generatingByAI: 'Generating your AI commit subject...', + generatedSelectByAI: 'Select suitable subject by AI generated:', + confirmCommit: 'Are you sure you want to proceed with the commit above?' + }, + types: [ + { value: 'feat', name: 'feat: A new feature', emoji: ':sparkles:' }, + { value: 'fix', name: 'fix: A bug fix', emoji: ':bug:' }, + { value: 'perf', name: 'perf: A code change that improves performance', emoji: ':zap:' }, + { value: 'docs', name: 'docs: Documentation only changes', emoji: ':memo:' }, + { value: 'style', name: 'style: Changes that do not affect the meaning of the code', emoji: ':lipstick:' }, + { value: 'deps', name: 'deps: A dependency update', emoji: ':package:' }, + { value: 'refactor', name: 'refactor: A code change that neither fixes a bug nor adds a feature', emoji: ':recycle:' }, + { value: 'ci', name: 'ci: Changes to our CI configuration files and scripts', emoji: ':ferris_wheel:' }, + { value: 'test', name: 'test: Adding missing tests or correcting existing tests', emoji: ':white_check_mark:' }, + { value: 'revert', name: 'revert: Reverts a previous commit', emoji: ':rewind:' }, + { value: 'build', name: 'build: Changes that affect the build system or external dependencies', emoji: ':package:' }, + { value: 'chore', name: 'chore: Other changes that don\'t modify src or test files', emoji: ':hammer:' }, + { value: 'security', name: 'security: A code change that fixes a security issue', emoji: ':lock:' } + ], + useEmoji: false, + emojiAlign: 'center', + useAI: false, + aiNumber: 1, + themeColorCode: '', + scopes: [], + allowCustomScopes: true, + allowEmptyScopes: true, + customScopesAlign: 'bottom', + customScopesAlias: 'custom', + emptyScopesAlias: 'empty', + upperCaseSubject: false, + markBreakingChangeMode: false, + allowBreakingChanges: ['feat', 'fix'], + breaklineNumber: 100, + breaklineChar: '|', + skipQuestions: [], + issuePrefixes: [{ value: 'closed', name: 'closed: ISSUES has been processed' }], + customIssuePrefixAlign: 'top', + emptyIssuePrefixAlias: 'skip', + customIssuePrefixAlias: 'custom', + allowCustomIssuePrefix: true, + allowEmptyIssuePrefix: true, + confirmColorize: true, + maxHeaderLength: Infinity, + maxSubjectLength: Infinity, + minSubjectLength: 0, + scopeOverrides: undefined, + defaultBody: '', + defaultIssues: '', + defaultScope: '', + defaultSubject: '' +} diff --git a/.github/.release-please-config.json b/.github/.release-please-config.json new file mode 100644 index 00000000..d89aa956 --- /dev/null +++ b/.github/.release-please-config.json @@ -0,0 +1,72 @@ +{ + "release-type": "php", + "packages": { + ".": { + "package-name": "trap", + "changelog-path": "/CHANGELOG.md" + } + }, + "include-component-in-tag": false, + "changelog-sections": [ + { + "type": "feat", + "section": "Features", + "hidden": false + }, + { + "type": "fix", + "section": "Bug Fixes", + "hidden": false + }, + { + "type": "perf", + "section": "Performance Improvements", + "hidden": false + }, + { + "type": "docs", + "section": "Documentation", + "hidden": false + }, + { + "type": "deps", + "section": "Dependencies", + "hidden": false + }, + { + "type": "refactor", + "section": "Code Refactoring", + "hidden": false + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System", + "hidden": true + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + }, + { + "type": "chore", + "section": "Miscellaneous", + "hidden": true + }, + { + "type": "style", + "section": "Styles", + "hidden": true + }, + { + "type": "revert", + "section": "Reverts", + "hidden": true + } + ] +} diff --git a/.github/.release-please-manifest.json b/.github/.release-please-manifest.json new file mode 100644 index 00000000..a4f6ddce --- /dev/null +++ b/.github/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "1.6.0" +} diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 00000000..db77c6d4 --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,27 @@ +--- + +# https://github.com/wayofdev/gh-actions/blob/master/.github/workflows/create-release.yml +# https://github.com/google-github-actions/release-please-action#release-types-supported +# https://github.com/googleapis/release-please/blob/main/docs/customizing.md + +on: # yamllint disable-line rule:truthy + push: + branches: + - master + +name: 📦 Create release + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: 🎉 Create release + uses: google-github-actions/release-please-action@v4 + id: release + with: + token: ${{ secrets.GITHUB_TOKEN }} + config-file: .github/.release-please-config.json + manifest-file: .github/.release-please-manifest.json + target-branch: master + +... From ebbe101e77f11a3be9379d8f98669c6211722e8e Mon Sep 17 00:00:00 2001 From: lotyp Date: Fri, 10 May 2024 16:45:03 +0300 Subject: [PATCH 2/2] chore: change version file --- .github/.commitlint.config.mjs | 1 + .github/.release-please-config.json | 5 +++++ .github/workflows/create-release.yml | 2 +- .github/.release-please-manifest.json => src/version.json | 0 4 files changed, 7 insertions(+), 1 deletion(-) rename .github/.release-please-manifest.json => src/version.json (100%) diff --git a/.github/.commitlint.config.mjs b/.github/.commitlint.config.mjs index 49f1f956..8b68c159 100644 --- a/.github/.commitlint.config.mjs +++ b/.github/.commitlint.config.mjs @@ -34,6 +34,7 @@ export default { 'refactor', // Code refactoring 'ci', // Continuous integration changes 'test', // Adding missing tests + 'tests', // Adding missing tests 'revert', // Revert to a previous commit 'build', // Changes that affect the build system 'chore', // Other changes that don't modify src or test files diff --git a/.github/.release-please-config.json b/.github/.release-please-config.json index d89aa956..afcbefa3 100644 --- a/.github/.release-please-config.json +++ b/.github/.release-please-config.json @@ -43,6 +43,11 @@ "section": "Tests", "hidden": true }, + { + "type": "tests", + "section": "Tests", + "hidden": true + }, { "type": "build", "section": "Build System", diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index db77c6d4..eef7915a 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -21,7 +21,7 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} config-file: .github/.release-please-config.json - manifest-file: .github/.release-please-manifest.json + manifest-file: src/version.json target-branch: master ... diff --git a/.github/.release-please-manifest.json b/src/version.json similarity index 100% rename from .github/.release-please-manifest.json rename to src/version.json