Skip to content

Commit

Permalink
ci: workflow for automated releases
Browse files Browse the repository at this point in the history
  • Loading branch information
slisson committed Feb 1, 2024
1 parent 16fbfc6 commit 709eb91
Show file tree
Hide file tree
Showing 6 changed files with 7,837 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/dry-run-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Dry-Run Release
on:
pull_request:

jobs:
lint-commits:
name: Lint PR commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5

test-release:
name: Dry-run semantic-release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
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@v4
with:
node-version: 18
- name: Cache Node packages
uses: actions/cache@v4
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.RELEASE_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
32 changes: 32 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release
on:
workflow_dispatch:
schedule:
- cron: '0 2 * * *' # run at 2 AM UTC

jobs:
release:
name: Run semantic release
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Cache Node packages
uses: actions/cache@v4
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.RELEASE_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"
]
}
18 changes: 18 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
rules: {
"scope-enum": [
2,
"always",
[
"mps-legacy-sync-plugin",
],
],
"subject-case": [0, 'never'],
"body-max-line-length": [0, 'always'],
"footer-max-line-length": [0, 'always']
},
ignores: [
(message) => message.includes('skip-lint')
],
};
Loading

0 comments on commit 709eb91

Please sign in to comment.