Skip to content

Commit 8904c01

Browse files
authored
Merge pull request #42 from modelix/feature/semantic-releases
Implement automated releases
2 parents 925b3b1 + b1d0d27 commit 8904c01

File tree

8 files changed

+12863
-0
lines changed

8 files changed

+12863
-0
lines changed

.github/workflows/release.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request: {}
7+
8+
jobs:
9+
lint-commits:
10+
name: Lint PR commits
11+
runs-on: ubuntu-latest
12+
if: ${{ github.event_name == 'pull_request' }}
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
- uses: wagoid/commitlint-github-action@v5
18+
19+
test-release:
20+
name: Dry-run semantic-release
21+
runs-on: ubuntu-latest
22+
if: ${{ github.event_name == 'pull_request' }}
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
with:
27+
fetch-depth: 0
28+
- name: Checkout branch
29+
# Pretend to semantic-release that the PR result is eligible for
30+
# building releases because --dry-run still filters for configured
31+
# branches.
32+
run: git checkout -b main
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v3
35+
with:
36+
node-version: 18
37+
- name: Cache Node packages
38+
uses: actions/cache@v3
39+
with:
40+
path: node_modules
41+
key: release-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
42+
- name: Install dependencies
43+
run: npm ci
44+
- name: Dry-run release
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
# We need to convince semantic-release to not pick up some
48+
# configuration from the CI environment by removing the variable that
49+
# is used for CI detection.
50+
run: unset GITHUB_ACTIONS && npx semantic-release --dry-run --ci false
51+
52+
release:
53+
name: Run semantic release
54+
runs-on: ubuntu-latest
55+
if: ${{ github.ref == 'refs/heads/main' }}
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v3
59+
with:
60+
fetch-depth: 0
61+
- name: Setup Node.js
62+
uses: actions/setup-node@v3
63+
with:
64+
node-version: 18
65+
- name: Cache Node packages
66+
uses: actions/cache@v3
67+
with:
68+
path: node_modules
69+
key: release-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
70+
- name: Install dependencies
71+
run: npm ci
72+
- name: Release
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
run: npx semantic-release

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
*.iml
88
kotlin_gen
99
/version.txt
10+
/node_modules

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
default_install_hook_types:
3+
- pre-commit
4+
- commit-msg
5+
repos:
6+
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
7+
rev: v9.4.0
8+
hooks:
9+
- id: commitlint
10+
stages: [commit-msg]
11+
additional_dependencies: ["@commitlint/config-angular"]
12+
args: ["--config", "./commitlint.config.js"]

.releaserc.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"branches": [
3+
"main"
4+
],
5+
"tagFormat": "${version}",
6+
"plugins": [
7+
[
8+
"@semantic-release/commit-analyzer",
9+
{
10+
"preset": "conventionalcommits"
11+
}
12+
],
13+
[
14+
"@semantic-release/release-notes-generator",
15+
{
16+
"preset": "angular"
17+
}
18+
],
19+
"@semantic-release/github"
20+
]
21+
}

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
# modelix.core
2+
23
All the Modelix components that don't have a dependency on JetBrains MPS
4+
5+
## Development
6+
7+
### Commit convention
8+
9+
This project uses [conventional commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/) as the convention for Git commits.
10+
11+
### pre-commit
12+
13+
This project uses [pre-commit](https://pre-commit.com/) to validate that new commits follow intended conventions.
14+
To enable pre-commit hooks, you have to run the following command initially after cloning the repository:
15+
16+
```console
17+
$ pre-commit install
18+
pre-commit installed at .git/hooks/pre-commit
19+
```

commitlint.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
extends: ["@commitlint/config-conventional"],
3+
rules: {
4+
"scope-enum": [
5+
2,
6+
"always",
7+
[
8+
"light-model-client",
9+
"light-model-server",
10+
"metamodel-export-mps",
11+
"metamodel-generator",
12+
"metamodel-gradle",
13+
"model-api",
14+
"model-client",
15+
"model-server",
16+
"ts-model-api",
17+
],
18+
],
19+
},
20+
};

0 commit comments

Comments
 (0)