Skip to content

Commit

Permalink
ci: configure semantic-release for automated releases
Browse files Browse the repository at this point in the history
Adds a configuration for semantic-release bot matching the existing tag
structure and integrates releases in the CI process.
  • Loading branch information
languitar committed Mar 14, 2023
1 parent a452121 commit 14a5a8c
Show file tree
Hide file tree
Showing 4 changed files with 10,467 additions and 1,493 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,61 @@ jobs:
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5

test-release:
name: Dry-run semantic-release
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Checkout branch
# Pretend to semantic-release that the PR result is eligible for
# building releases because --dry-run still filters for configured
# branches.
run: git checkout -b main
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Cache Node packages
uses: actions/cache@v3
with:
path: node_modules
key: release-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
run: npm ci
- name: Dry-run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# We need to convince semantic-release to not pick up some
# configuration from the CI environment by removing the variable that
# is used for CI detection.
run: unset GITHUB_ACTIONS && npx semantic-release --dry-run --ci false

release:
name: Run semantic release
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Cache Node packages
uses: actions/cache@v3
with:
path: node_modules
key: release-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
run: npm ci
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
21 changes: 21 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"branches": [
"main"
],
"tagFormat": "${version}",
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "angular"
}
],
"@semantic-release/github"
]
}
Loading

0 comments on commit 14a5a8c

Please sign in to comment.