From b79d54666d2cc8892c93ef970fdef2efb9ea2562 Mon Sep 17 00:00:00 2001 From: Tom Morelly Date: Fri, 13 Dec 2024 08:32:51 +1100 Subject: [PATCH] feat(GHA): add commitlint and semrel --- .github/workflows/commitlint.yml | 15 +++++++++ .github/workflows/monthly-snapshot.yml | 31 ------------------ .github/workflows/release.yml | 26 +++++++++++++++ .releaserc.json | 45 ++++++++++++++++++++++++++ commitlint.config.js | 5 +++ 5 files changed, 91 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/commitlint.yml delete mode 100644 .github/workflows/monthly-snapshot.yml create mode 100644 .github/workflows/release.yml create mode 100644 .releaserc.json create mode 100644 commitlint.config.js diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml new file mode 100644 index 00000000..c65fdead --- /dev/null +++ b/.github/workflows/commitlint.yml @@ -0,0 +1,15 @@ +name: Lint Commit Messages +on: + push: + branches: + - main + pull_request: + +jobs: + commitlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: wagoid/commitlint-github-action@v5 \ No newline at end of file diff --git a/.github/workflows/monthly-snapshot.yml b/.github/workflows/monthly-snapshot.yml deleted file mode 100644 index b8bef663..00000000 --- a/.github/workflows/monthly-snapshot.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -name: Release Monthly Snapshot - -on: - schedule: - # Arbitrary time so we're not competing with all of the 0:00 jobs for compute - # Run at 03:42 on the 1st of every month. - - cron: "42 3 1 * *" - -jobs: - build: - name: Release Monthly Snapshot - runs-on: ubuntu-latest - steps: - - name: Get current date - id: date - run: echo "DATE=$(date +'%Y.%m.%d')" >> $GITHUB_ENV - - name: Checkout master Branch - uses: actions/checkout@v2 - with: - ref: 'master' - - name: Create Release - id: monthly-snapshot - uses: actions/create-release@latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ env.DATE }} - release_name: "Monthly snapshot for ${{ env.DATE }}" - draft: false - prerelease: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..0e54da2f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: Semantic Releaser +on: + push: + branches: + - main + +permissions: + contents: write + packages: write + pull-requests: write + +jobs: + semrel: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Semantic Release + uses: cycjimmy/semantic-release-action@v4 + with: + extra_plugins: | + @semantic-release/changelog@6.0.0 + @semantic-release/git@10.0.0 + conventional-changelog-conventionalcommits@4.6.3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 00000000..e26b4457 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,45 @@ +{ + "branches": [ + "main", + "master" + ], + "ci": false, + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits" + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits" + } + ], + [ + "@semantic-release/github", + { + "successComment": "This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:", + "labels": false, + "releasedLabels": false + } + ], + [ + "@semantic-release/changelog", + { + "changelogFile": "CHANGELOG.md", + "changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file." + } + ], + [ + "@semantic-release/git", + { + "assets": [ + "CHANGELOG.md" + ], + "message": "chore(release): version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + } + ] + ] + } \ No newline at end of file diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 00000000..3628b5fa --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,5 @@ +// commitlint.config.js +module.exports = { + extends: ['@commitlint/config-conventional'], + ignores: [(message) => /^Bumps \[.+]\(.+\) from .+ to .+\.$/m.test(message)], + } \ No newline at end of file