feat: initial common-repo source template for semantic releases
Includes: - .releaserc.yaml (conventionalcommits preset, changelog, git, github, major-tag) - commitlint.config.js (@commitlint/config-conventional) - .github/workflows/commitlint.yml (PR commit linting via wagoid/commitlint-github-action) - .github/workflows/release.yaml (semantic-release on push to main, GitHub App token auth) - .common-repo.yaml (source-level excludes for README, LICENSE, self-config)
This commit is contained in:
7
.common-repo.yaml
Normal file
7
.common-repo.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
# Source-level common-repo config
|
||||
# Excludes files that are part of this template repo itself,
|
||||
# not intended to be distributed to consumers.
|
||||
- exclude:
|
||||
- "README.md"
|
||||
- ".common-repo.yaml"
|
||||
- "LICENSE"
|
||||
20
.github/workflows/commitlint.yml
vendored
Normal file
20
.github/workflows/commitlint.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: Commitlint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
|
||||
jobs:
|
||||
commitlint:
|
||||
name: Lint Commits
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548c61b7286b4ffe7cb3d # v6
|
||||
70
.github/workflows/release.yaml
vendored
Normal file
70
.github/workflows/release.yaml
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
name: CI
|
||||
permissions:
|
||||
issues: write
|
||||
contents: write
|
||||
pull-requests: write
|
||||
uses: ./.github/workflows/ci.yaml
|
||||
secrets: inherit
|
||||
|
||||
release:
|
||||
name: Release
|
||||
needs: ci
|
||||
permissions:
|
||||
contents: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Generate app token
|
||||
id: app-token
|
||||
uses: actions/create-github-app-token@v1
|
||||
with:
|
||||
app-id: ${{ vars.CHRISTMAS_ISLAND_APP_ID }}
|
||||
private-key: ${{ secrets.CHRISTMAS_ISLAND_PRIVATE_KEY }}
|
||||
owner: christmas-island
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ steps.app-token.outputs.token }}
|
||||
persist-credentials: true
|
||||
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
|
||||
with:
|
||||
cache: npm
|
||||
cache-dependency-path: ".releaserc.yaml"
|
||||
node-version: lts/*
|
||||
- name: Semantic Release
|
||||
id: release
|
||||
run: |
|
||||
# Semantic Release
|
||||
npm install --no-save --no-package-lock \
|
||||
"@semantic-release/commit-analyzer" \
|
||||
"@semantic-release/release-notes-generator" \
|
||||
"@semantic-release/changelog" \
|
||||
"@semantic-release/git" \
|
||||
"@semantic-release/github" \
|
||||
"semantic-release-major-tag" \
|
||||
"conventional-changelog-conventionalcommits"
|
||||
npx semantic-release > release.log 2>&1 || true
|
||||
cat release.log
|
||||
if grep -q "There are no relevant changes, so no new version is released." release.log; then
|
||||
echo "publish=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "publish=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
|
||||
outputs:
|
||||
publish: ${{ steps.release.outputs.publish }}
|
||||
61
.releaserc.yaml
Normal file
61
.releaserc.yaml
Normal file
@@ -0,0 +1,61 @@
|
||||
---
|
||||
branches:
|
||||
- main
|
||||
|
||||
preset: "conventionalcommits"
|
||||
tagFormat: "v${version}"
|
||||
|
||||
plugins:
|
||||
- - "@semantic-release/commit-analyzer"
|
||||
- preset: conventionalcommits
|
||||
- - "@semantic-release/release-notes-generator"
|
||||
- preset: conventionalcommits
|
||||
- - "@semantic-release/changelog"
|
||||
- - "@semantic-release/git"
|
||||
- - "@semantic-release/github"
|
||||
# Disable noisy issue/PR comments to avoid GH rate limits
|
||||
- failComment: false
|
||||
failTitle: false
|
||||
labels: false
|
||||
releasedLabels: false
|
||||
successComment: false
|
||||
- - "semantic-release-major-tag"
|
||||
|
||||
generateNotes:
|
||||
- path: "@semantic-release/release-notes-generator"
|
||||
writerOpts:
|
||||
commitsSort:
|
||||
- subject
|
||||
- scope
|
||||
presetConfig:
|
||||
types:
|
||||
- type: build
|
||||
section: Build System
|
||||
hidden: false
|
||||
- type: chore
|
||||
section: Miscellaneous
|
||||
hidden: false
|
||||
- type: ci
|
||||
section: Continuous Integration
|
||||
hidden: false
|
||||
- type: docs
|
||||
section: Documentation
|
||||
hidden: false
|
||||
- type: feat
|
||||
section: Features
|
||||
hidden: false
|
||||
- type: fix
|
||||
section: Bug Fixes
|
||||
hidden: false
|
||||
- type: perf
|
||||
section: Performance Improvements
|
||||
hidden: false
|
||||
- type: refactor
|
||||
section: Code Refactoring
|
||||
hidden: false
|
||||
- type: style
|
||||
section: Styles
|
||||
hidden: false
|
||||
- type: test
|
||||
section: Tests
|
||||
hidden: false
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Christmas Island
|
||||
|
||||
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.
|
||||
88
README.md
Normal file
88
README.md
Normal file
@@ -0,0 +1,88 @@
|
||||
# cr-semantic-release
|
||||
|
||||
A [common-repo](https://github.com/common-repo/common-repo) source template for conventional commits and semantic releases.
|
||||
|
||||
## What's Included
|
||||
|
||||
| File | Purpose |
|
||||
|---|---|
|
||||
| `.releaserc.yaml` | semantic-release config (conventionalcommits preset, changelog, git, GitHub release, major-tag) |
|
||||
| `commitlint.config.js` | commitlint config extending `@commitlint/config-conventional` |
|
||||
| `.github/workflows/commitlint.yml` | PR commit lint workflow using `wagoid/commitlint-github-action` |
|
||||
| `.github/workflows/release.yaml` | Semantic release workflow (triggers on push to main, uses GitHub App token) |
|
||||
|
||||
## Usage
|
||||
|
||||
### Add to a new repo
|
||||
|
||||
```bash
|
||||
cr init https://github.com/christmas-island/cr-semantic-release
|
||||
```
|
||||
|
||||
### Add to an existing `.common-repo.yaml`
|
||||
|
||||
```bash
|
||||
cr add https://github.com/christmas-island/cr-semantic-release
|
||||
```
|
||||
|
||||
Or manually:
|
||||
|
||||
```yaml
|
||||
# .common-repo.yaml
|
||||
- repo:
|
||||
url: https://github.com/christmas-island/cr-semantic-release
|
||||
ref: v1.0.0
|
||||
```
|
||||
|
||||
### Apply
|
||||
|
||||
```bash
|
||||
cr diff # preview changes
|
||||
cr apply # apply
|
||||
```
|
||||
|
||||
## Prerequisites
|
||||
|
||||
The release workflow expects the following GitHub org-level vars and secrets:
|
||||
|
||||
| Name | Type | Purpose |
|
||||
|---|---|---|
|
||||
| `CHRISTMAS_ISLAND_APP_ID` | Variable | GitHub App ID for generating tokens |
|
||||
| `CHRISTMAS_ISLAND_PRIVATE_KEY` | Secret | GitHub App private key |
|
||||
|
||||
These are used by `actions/create-github-app-token` to generate a token with write permissions for creating releases and pushing tags/changelogs.
|
||||
|
||||
## Customization
|
||||
|
||||
### Release workflow
|
||||
|
||||
The included `release.yaml` contains only the semantic-release job. It does **not** include a publish step (goreleaser, Docker, etc.) — add that in your repo's own workflow or extend via common-repo merge operators.
|
||||
|
||||
The workflow calls `./.github/workflows/ci.yaml` as a prerequisite. Your repo must have a CI workflow at that path (or remove the `ci` job dependency).
|
||||
|
||||
### Excluding files
|
||||
|
||||
If you only want a subset of files:
|
||||
|
||||
```yaml
|
||||
- repo:
|
||||
url: https://github.com/christmas-island/cr-semantic-release
|
||||
ref: v1.0.0
|
||||
with:
|
||||
- exclude: [".github/workflows/commitlint.yml"]
|
||||
```
|
||||
|
||||
### Overriding `.releaserc.yaml`
|
||||
|
||||
Use common-repo's YAML merge operator to patch specific fields:
|
||||
|
||||
```yaml
|
||||
- repo:
|
||||
url: https://github.com/christmas-island/cr-semantic-release
|
||||
ref: v1.0.0
|
||||
- yaml:
|
||||
source: my-releaserc-overrides.yaml
|
||||
dest: .releaserc.yaml
|
||||
path: plugins
|
||||
array_mode: replace
|
||||
```
|
||||
3
commitlint.config.js
Normal file
3
commitlint.config.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
extends: ["@commitlint/config-conventional"],
|
||||
};
|
||||
Reference in New Issue
Block a user