diff --git a/.github/configs/commitlint.config.js b/.github/configs/commitlint.config.js new file mode 100644 index 0000000..2c3951d --- /dev/null +++ b/.github/configs/commitlint.config.js @@ -0,0 +1,27 @@ +const { maxLineLength } = require('@commitlint/ensure') + +const bodyMaxLineLength = 100 + +const validateBodyMaxLengthIgnoringDeps = (parsedCommit) => { + const { type, scope, body } = parsedCommit + const isDepsCommit = + type === 'chore' && scope === 'release' + + return [ + isDepsCommit || !body || maxLineLength(body, bodyMaxLineLength), + `body's lines must not be longer than ${bodyMaxLineLength}`, + ] +} + +module.exports = { + extends: ['@commitlint/config-conventional'], + plugins: ['commitlint-plugin-function-rules'], + rules: { + 'body-max-line-length': [0], + 'function-rules/body-max-line-length': [ + 2, + 'always', + validateBodyMaxLengthIgnoringDeps, + ], + }, +} diff --git a/.github/workflows/checks.base.yaml b/.github/workflows/checks.base.yaml new file mode 100644 index 0000000..015fc18 --- /dev/null +++ b/.github/workflows/checks.base.yaml @@ -0,0 +1,16 @@ +name: Checks (base) + +on: + workflow_call: + +jobs: + commitlint: + name: (check) Commitlint + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - name: Run Commitlint + uses: wagoid/commitlint-github-action@v5 + with: + configFile: .github/configs/commitlint.config.js diff --git a/.github/workflows/checks.branches.yaml b/.github/workflows/checks.branches.yaml new file mode 100644 index 0000000..f22bfbf --- /dev/null +++ b/.github/workflows/checks.branches.yaml @@ -0,0 +1,11 @@ +name: Checks (branches) + +on: + push: + branches-ignore: + - main + - staging + +jobs: + checks: + uses: ./.github/workflows/checks.base.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..00961b4 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,46 @@ +name: Release +run-name: "Release `${{ github.ref_name }}` (SHA: ${{ github.sha }})" + +on: + push: + branches: + - main + - staging + +permissions: + contents: read + +jobs: + checks: + name: Run Checks + uses: ./.github/workflows/checks.base.yaml + release: + name: Release + needs: checks + runs-on: ubuntu-latest + permissions: + contents: write + issues: write + pull-requests: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "lts/*" + - name: Install plugins + run: > + npm install -D + @semantic-release/git + @semantic-release/changelog + conventional-changelog-conventionalcommits + @saithodev/semantic-release-backmerge + - name: Verify the integrity of provenance attestations and registry signatures for installed dependencies + run: npm audit signatures + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: npx semantic-release diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..47fb503 --- /dev/null +++ b/.gitignore @@ -0,0 +1,103 @@ +# Dependency directory +node_modules + +# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# OS metadata +.DS_Store +Thumbs.db + +# Ignore built ts files +__tests__/runner/* + +# IDE files +.idea +.vscode +*.code-workspace diff --git a/.releaserc.yaml b/.releaserc.yaml new file mode 100644 index 0000000..cb54f1d --- /dev/null +++ b/.releaserc.yaml @@ -0,0 +1,129 @@ +preset: conventionalcommits +tagFormat: "${version}" + +branches: + - "+([0-9])?(.{+([0-9]),x}).x" + - main + - next + - next-major + - name: staging + prerelease: rc + - name: beta + prerelease: true + - name: alpha + prerelease: true + +plugins: + - "@semantic-release/commit-analyzer" + - "@semantic-release/release-notes-generator" + - "@semantic-release/changelog" + - "@semantic-release/git" + - "@semantic-release/github" + - "@saithodev/semantic-release-backmerge" + +verifyConditions: + - "@semantic-release/changelog" + - "@semantic-release/git" + - "@semantic-release/github" + - path: "@saithodev/semantic-release-backmerge" + backmergeBranches: + - from: main + to: staging + +analyzeCommits: + - path: "@semantic-release/commit-analyzer" + releaseRules: + - breaking: true + release: major + - type: build + release: patch + - type: chore + release: false + - type: ci + release: false + - type: docs + release: patch + - type: feat + release: minor + - type: fix + release: patch + - type: perf + release: patch + - type: refactor + release: false + - type: revert + release: patch + - type: style + release: false + - type: test + release: false + +generateNotes: + - path: "@semantic-release/release-notes-generator" + writerOpts: + groupBy: type + commitGroupsSort: title + commitsSort: header + linkCompare: true + linkReferences: true + presetConfig: + types: + - type: build + section: "๐ฆ CI/CD" + hidden: false + - type: chore + section: "Other" + hidden: true + - type: ci + section: "๐ฆ CI/CD" + hidden: false + - type: docs + section: "๐ Docs" + hidden: false + - type: example + section: "๐ Examples" + hidden: true + - type: feat + section: "๐ Features" + hidden: false + - type: fix + section: "๐ Fixes" + hidden: false + - type: perf + section: "โฉ Performance" + hidden: false + - type: refactor + section: ":scissors: Refactor" + hidden: false + - type: revert + section: "๐ โโ๏ธ Reverts" + hidden: false + - type: style + section: "๐ Style" + hidden: false + - type: test + section: "๐งช Tests" + hidden: false + +prepare: + - path: "@semantic-release/changelog" + changelogFile: CHANGELOG.md + + - path: "@semantic-release/git" + message: "chore(release): release <%= nextRelease.version %> - <%= new Date().toLocaleDateString('en-US', {year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric' }) %> \n\n<%= nextRelease.notes %>" + assets: + - CHANGELOG.md + - pyproject.toml + +publish: + - path: "@semantic-release/github" + +success: + - path: "@semantic-release/github" + - path: "@saithodev/semantic-release-backmerge" + backmergeBranches: + - from: main + to: staging + +fail: + - path: "@semantic-release/github" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3cd08a8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Ethiack, Lda. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..6398e44 --- /dev/null +++ b/README.md @@ -0,0 +1,152 @@ + + +[version-shield]: https://img.shields.io/github/v/release/ethiack/github-action?style=for-the-badge +[version-url]: https://github.com/ethiack/github-action/releases/latest + +[license-shield]: https://img.shields.io/github/license/ethiack/github-action?style=for-the-badge +[license-url]: LICENSE + +[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555 +[linkedin-url]: https://linkedin.com/company/ethiack + + + + +