From 5ecb073ae3add304b9b8eb924782f9df6234909a Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Wed, 11 Oct 2023 15:47:31 +0000 Subject: [PATCH] ci: add commit lint and semantic-release process See added CONTRIBUTING.md for details. The purpose is to have 1-click release process done via GitHub actions. This is achieved via semantic-release which does the whole release process. Version bump is derived from commit messages using semantic versioning. That requires commit messages to follow a specific structure and thus commit lint is added to ensure that all commits follow the structure. Signed-off-by: Petr Vobornik --- .github/workflows/commitlint.yml | 33 + .github/workflows/release.yml | 40 + .gitignore | 1 + .releaserc | 44 + CONTRIBUTING.md | 100 + Makefile | 7 + package-lock.json | 13753 +++++++++++++++++++++++++++++ package.json | 60 + 8 files changed, 14038 insertions(+) create mode 100644 .github/workflows/commitlint.yml create mode 100644 .github/workflows/release.yml create mode 100644 .releaserc create mode 100644 CONTRIBUTING.md create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml new file mode 100644 index 0000000..eba2c64 --- /dev/null +++ b/.github/workflows/commitlint.yml @@ -0,0 +1,33 @@ +name: CI + +on: [push, pull_request] + +jobs: + commitlint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "lts/*" + - name: Print versions + run: | + git --version + node --version + npm --version + npx commitlint --version + - name: Install commitlint + run: | + npm install @commitlint/config-angular@latest + npm install commitlint@latest + - name: Validate current commit (last commit) with commitlint + if: github.event_name == 'push' + run: npx commitlint --from HEAD~1 --to HEAD --verbose + + - name: Validate PR commits with commitlint + if: github.event_name == 'pull_request' + run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f206dc1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +# Release process that runs on on manual request (workflow_dispatch) + +# How it works: +# 1. Prepares env to be able to run semantic-release +# 2. Runs semantic-release which does the whole release process + +# See CONTRIBUTING.md for more information how the semantic-release works + +--- +name: Release +on: workflow_dispatch + +permissions: + contents: read # for checkout + +jobs: + release: + name: Release + runs-on: ubuntu-latest + permissions: + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "lts/*" + - name: Install dependencies + run: npm clean-install + - 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 index 07374e8..5866bab 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ coverage.* # Binary host-metering dist/host-metering +node_modules diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000..57652ee --- /dev/null +++ b/.releaserc @@ -0,0 +1,44 @@ +{ + "branches": [ + "main", + "release" + ], + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + [ + "@semantic-release/exec", + { + "prepareCmd": "make version-update NEXT_VERSION=${nextRelease.version} ;", + "publishCmd": "make tarball" + } + ], + [ + "@semantic-release/changelog", + { + "changelogFile": "CHANGELOG.md" + } + ], + [ + "@semantic-release/git", + { + "assets": [ + "version/version.go", + "CHANGELOG.md" + ], + "message": "build(release): ${nextRelease.version}\n\n${nextRelease.notes}" + } + ], + [ + "@semantic-release/github", + { + "assets": [ + { + "path": "dist/*.tar.gz", + "label": "Tarball" + } + ] + } + ] + ] +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..0769011 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,100 @@ +# Contributing + +Open a pull request to contribute a change. + +## Commit message format + +The project is using [semantic-release](https://semantic-release.gitbook.io/semantic-release/) +and commit lint which enforces formatting rules on commit messages. + +This is a modified version from [Angular](https://github.com/angular/angular/blob/main/CONTRIBUTING.md#-commit-message-format) +project. + +Each commit message consists of a **header**, a **body**, and a **footer**. + + +``` +
+ + + +