Skip to content

Commit 219ec5e

Browse files
committed
feat: initial build setup
1 parent 686bd4f commit 219ec5e

File tree

12 files changed

+11587
-91
lines changed

12 files changed

+11587
-91
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Dry-Run Release
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
lint-commits:
7+
name: Lint PR commits
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
11+
with:
12+
fetch-depth: 0
13+
- uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6
14+
15+
test-release:
16+
name: Dry-run semantic-release
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
21+
with:
22+
fetch-depth: 0
23+
- name: Checkout branch
24+
# Pretend to semantic-release that the PR result is eligible for
25+
# building releases because --dry-run still filters for configured
26+
# branches.
27+
run: git checkout -b main
28+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
29+
with:
30+
node-version-file: '.nvmrc'
31+
- name: Install dependencies
32+
run: npm ci
33+
- name: Dry-run release
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
36+
# We need to convince semantic-release to not pick up some
37+
# configuration from the CI environment by removing the variable that
38+
# is used for CI detection.
39+
run: unset GITHUB_ACTIONS && npx semantic-release --dry-run --ci false

.github/workflows/release.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Release
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: '0 2 * * *' # run at 2 AM UTC
6+
7+
jobs:
8+
release:
9+
name: Run semantic release
10+
runs-on: ubuntu-latest
11+
if: ${{ github.ref == 'refs/heads/main' }}
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
15+
with:
16+
fetch-depth: 0
17+
token: ${{ secrets.RELEASE_TOKEN }}
18+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
19+
with:
20+
node-version-file: '.nvmrc'
21+
- name: Install dependencies
22+
run: npm ci
23+
- name: Release
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
26+
run: npx semantic-release

.pre-commit-config.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
default_install_hook_types:
3+
- pre-commit
4+
- commit-msg
5+
repos:
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: v5.0.0
8+
hooks:
9+
# - id: end-of-file-fixer # disabled, because it modifies MPS XML files
10+
- id: check-toml
11+
- id: check-yaml
12+
- id: check-added-large-files
13+
- id: check-merge-conflict
14+
- id: check-symlinks
15+
- id: fix-byte-order-marker
16+
- id: mixed-line-ending
17+
# - id: trailing-whitespace # disabled, because it modifies multiline string literals to invalid values
18+
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
19+
rev: v9.22.0
20+
hooks:
21+
- id: commitlint
22+
stages: [commit-msg]
23+
additional_dependencies: ["@commitlint/config-angular"]
24+
args: ["--config", "./commitlint.config.js"]
25+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
26+
rev: v2.14.0
27+
hooks:
28+
- id: pretty-format-kotlin
29+
args:
30+
- --ktlint-version=1.5.0
31+
- --autofix

.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+
}

api-server-stubs-ktor/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ tasks.compileKotlin {
7575

7676
tasks.named("sourcesJar") {
7777
dependsOn(tasks.fabriktGenerate)
78-
}
78+
}

build.gradle.kts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ plugins {
55
alias(libs.plugins.kotlin.jvm) apply false
66
alias(libs.plugins.kotlin.serialization) apply false
77
alias(libs.plugins.gitVersion)
8-
//alias(libs.plugins.node)
98
`maven-publish`
109
}
1110

@@ -40,11 +39,12 @@ subprojects {
4039
repositories {
4140
maven {
4241
name = "itemis"
43-
url = if (version.toString().contains("SNAPSHOT")) {
44-
uri("https://artifacts.itemis.cloud/repository/maven-mps-snapshots/")
45-
} else {
46-
uri("https://artifacts.itemis.cloud/repository/maven-mps-releases/")
47-
}
42+
url =
43+
if (version.toString().contains("SNAPSHOT")) {
44+
uri("https://artifacts.itemis.cloud/repository/maven-mps-snapshots/")
45+
} else {
46+
uri("https://artifacts.itemis.cloud/repository/maven-mps-releases/")
47+
}
4848
credentials {
4949
username = project.findProperty("artifacts.itemis.cloud.user").toString()
5050
password = project.findProperty("artifacts.itemis.cloud.pw").toString()

client-ts/build.gradle.kts

Lines changed: 101 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -23,92 +23,110 @@ fun registerNpmPackageTasks(
2323
openApiGeneratorName: String, // e.g., "typescript-fetch"
2424
) {
2525
val clientBuildDir = layout.buildDirectory.dir("generate").map { it.dir(openApiGeneratorName) }
26-
val publicationFile = clientBuildDir.map { it.file("modelix-${npmPackageName}-${project.version}.tgz") }
27-
28-
val generatorTask = tasks.register("generateTypescript$clientType", GenerateTask::class) {
29-
dependsOn(":redocly:npm_run_join")
30-
group = "openapi tools"
31-
inputSpec = project(":redocly").layout.buildDirectory.file("joined.yaml").get().asFile.absolutePath
32-
configOptions = mapOf(
33-
"npmRepository" to "https://artifacts.itemis.cloud/repository/npm-open/",
34-
"npmVersion" to project.version.toString(),
35-
"npmName" to "@modelix/$npmPackageName",
36-
)
37-
gitUserId = "modelix"
38-
gitRepoId = "modelix.openapi"
39-
generatorName = openApiGeneratorName
40-
outputDir = layout.buildDirectory.dir("generate/$openApiGeneratorName").get().asFile.absolutePath
41-
}
26+
val publicationFile = clientBuildDir.map { it.file("modelix-$npmPackageName-${project.version}.tgz") }
27+
28+
val generatorTask =
29+
tasks.register("generateTypescript$clientType", GenerateTask::class) {
30+
dependsOn(":redocly:npm_run_join")
31+
group = "openapi tools"
32+
inputSpec =
33+
project(":redocly")
34+
.layout.buildDirectory
35+
.file("joined.yaml")
36+
.get()
37+
.asFile.absolutePath
38+
configOptions =
39+
mapOf(
40+
"npmRepository" to "https://artifacts.itemis.cloud/repository/npm-open/",
41+
"npmVersion" to project.version.toString(),
42+
"npmName" to "@modelix/$npmPackageName",
43+
)
44+
gitUserId = "modelix"
45+
gitRepoId = "modelix.openapi"
46+
generatorName = openApiGeneratorName
47+
outputDir =
48+
layout.buildDirectory
49+
.dir("generate/$openApiGeneratorName")
50+
.get()
51+
.asFile.absolutePath
52+
}
4253

4354
// Task to run 'pnpm install'
44-
val pnpmInstallTask = tasks.register<PnpmTask>("pnpmInstall${clientType.capitalize()}") {
45-
group = "build"
46-
description = "Run pnpm install for $openApiGeneratorName client"
47-
dependsOn(generatorTask) // Must run after generation
48-
49-
workingDir.set(clientBuildDir)
50-
pnpmCommand = listOf("install")
51-
52-
// Define inputs/outputs for better up-to-date checks and caching
53-
//inputs.dir(clientBuildDir.map { it.dir("src") }).withPathSensitivity(PathSensitivity.RELATIVE) // Source might change
54-
inputs.file(clientBuildDir.map { it.file("package.json") }).withPathSensitivity(PathSensitivity.RELATIVE)
55-
// Add pnpm-lock.yaml if you commit/use it
56-
// inputs.file(clientBuildDir.map { it.file("pnpm-lock.yaml") }).optional().withPathSensitivity(PathSensitivity.RELATIVE)
57-
outputs.dir(clientBuildDir.map { it.dir("node_modules") })
58-
// If 'pnpm install' triggers a build (via 'prepare' script) that creates a 'dist' folder:
59-
// outputs.dir(clientBuildDir.map { it.dir("dist") })
60-
}
55+
val pnpmInstallTask =
56+
tasks.register<PnpmTask>("pnpmInstall${clientType.capitalize()}") {
57+
group = "build"
58+
description = "Run pnpm install for $openApiGeneratorName client"
59+
dependsOn(generatorTask) // Must run after generation
60+
61+
workingDir.set(clientBuildDir)
62+
pnpmCommand = listOf("install")
63+
64+
// Define inputs/outputs for better up-to-date checks and caching
65+
// inputs.dir(clientBuildDir.map { it.dir("src") }).withPathSensitivity(PathSensitivity.RELATIVE) // Source might change
66+
inputs.file(clientBuildDir.map { it.file("package.json") }).withPathSensitivity(PathSensitivity.RELATIVE)
67+
// Add pnpm-lock.yaml if you commit/use it
68+
// inputs.file(clientBuildDir.map { it.file("pnpm-lock.yaml") }).optional().withPathSensitivity(PathSensitivity.RELATIVE)
69+
outputs.dir(clientBuildDir.map { it.dir("node_modules") })
70+
// If 'pnpm install' triggers a build (via 'prepare' script) that creates a 'dist' folder:
71+
// outputs.dir(clientBuildDir.map { it.dir("dist") })
72+
}
6173

6274
// Task to run 'npm pack'
63-
val npmPackTask = tasks.register<NpmTask>("npmPack${clientType.capitalize()}") {
64-
group = "build"
65-
description = "Run npm pack for $npmPackageName"
66-
dependsOn(pnpmInstallTask) // Must run after pnpm install
67-
68-
// npm pack creates the .tgz in the *current* working directory
69-
workingDir.set(clientBuildDir.get().asFile) // Run npm pack from the project root
70-
npmCommand = listOf("pack")
71-
// Argument is the path to the directory containing package.json
72-
args.set(listOf(clientBuildDir.get().asFile.absolutePath))
73-
74-
inputs.dir(clientBuildDir)
75-
inputs.files(pnpmInstallTask.map { it.outputs.files })
76-
77-
outputs.file(publicationFile)
78-
}
75+
val npmPackTask =
76+
tasks.register<NpmTask>("npmPack${clientType.capitalize()}") {
77+
group = "build"
78+
description = "Run npm pack for $npmPackageName"
79+
dependsOn(pnpmInstallTask) // Must run after pnpm install
80+
81+
// npm pack creates the .tgz in the *current* working directory
82+
workingDir.set(clientBuildDir.get().asFile) // Run npm pack from the project root
83+
npmCommand = listOf("pack")
84+
// Argument is the path to the directory containing package.json
85+
args.set(listOf(clientBuildDir.get().asFile.absolutePath))
86+
87+
inputs.dir(clientBuildDir)
88+
inputs.files(pnpmInstallTask.map { it.outputs.files })
89+
90+
outputs.file(publicationFile)
91+
}
7992

80-
val publishPackageTasks = tasks.register<NpmTask>("publish${clientType.capitalize()}") {
81-
group = "publishing" // Standard Gradle group for publishing
82-
description = "Publishes the $npmPackageName package to the configured NPM registry."
83-
dependsOn(npmPackTask) // Must run after the package is copied
84-
85-
// Input: The specific .tgz file to be published
86-
inputs.file(publicationFile)
87-
88-
workingDir.set(project.projectDir) // Can run from project root
89-
npmCommand.set(listOf("publish"))
90-
// Argument is the path to the .tgz file in the build/packages directory
91-
args.set(listOf(
92-
publicationFile.get().asFile.absolutePath,
93-
"--registry=https://artifacts.itemis.cloud/repository/npm-open/",
94-
"--//artifacts.itemis.cloud/repository/npm-open/:_authToken=${project.findProperty("artifacts.itemis.cloud.npm.token").toString()}"
95-
))
96-
97-
// Add --access public if publishing public packages to npmjs.com scoped or not
98-
// if (isPublicPackage) {
99-
// args.add("--access")
100-
// args.add("public")
101-
// }
102-
103-
// Ensure registry/auth is configured via .npmrc or node {} block
104-
doFirst {
105-
logger.lifecycle("Attempting to publish ${publicationFile.get().asFile.name}...")
106-
logger.info("Ensure NPM registry and authentication are configured (e.g., via .npmrc)")
107-
if (!publicationFile.get().asFile.exists()) {
108-
throw GradleException("Package file to publish does not exist: ${publicationFile.get().asFile.absolutePath}")
93+
val publishPackageTasks =
94+
tasks.register<NpmTask>("publish${clientType.capitalize()}") {
95+
group = "publishing" // Standard Gradle group for publishing
96+
description = "Publishes the $npmPackageName package to the configured NPM registry."
97+
dependsOn(npmPackTask) // Must run after the package is copied
98+
99+
// Input: The specific .tgz file to be published
100+
inputs.file(publicationFile)
101+
102+
workingDir.set(project.projectDir) // Can run from project root
103+
npmCommand.set(listOf("publish"))
104+
// Argument is the path to the .tgz file in the build/packages directory
105+
args.set(
106+
listOf(
107+
publicationFile.get().asFile.absolutePath,
108+
"--registry=https://artifacts.itemis.cloud/repository/npm-open/",
109+
"--//artifacts.itemis.cloud/repository/npm-open/:_authToken=${project.findProperty(
110+
"artifacts.itemis.cloud.npm.token",
111+
)}",
112+
),
113+
)
114+
115+
// Add --access public if publishing public packages to npmjs.com scoped or not
116+
// if (isPublicPackage) {
117+
// args.add("--access")
118+
// args.add("public")
119+
// }
120+
121+
// Ensure registry/auth is configured via .npmrc or node {} block
122+
doFirst {
123+
logger.lifecycle("Attempting to publish ${publicationFile.get().asFile.name}...")
124+
logger.info("Ensure NPM registry and authentication are configured (e.g., via .npmrc)")
125+
if (!publicationFile.get().asFile.exists()) {
126+
throw GradleException("Package file to publish does not exist: ${publicationFile.get().asFile.absolutePath}")
127+
}
109128
}
110129
}
111-
}
112130

113131
packageAllClients {
114132
dependsOn(npmPackTask)
@@ -122,17 +140,17 @@ fun registerNpmPackageTasks(
122140
registerNpmPackageTasks(
123141
clientType = "fetch",
124142
npmPackageName = "api-client-ts-fetch",
125-
openApiGeneratorName = "typescript-fetch"
143+
openApiGeneratorName = "typescript-fetch",
126144
)
127145
registerNpmPackageTasks(
128146
clientType = "axios",
129147
npmPackageName = "api-client-ts-axios",
130-
openApiGeneratorName = "typescript-axios"
148+
openApiGeneratorName = "typescript-axios",
131149
)
132150
registerNpmPackageTasks(
133151
clientType = "redux",
134152
npmPackageName = "api-client-ts-redux",
135-
openApiGeneratorName = "typescript-redux-query"
153+
openApiGeneratorName = "typescript-redux-query",
136154
)
137155

138156
tasks.assemble {
@@ -141,4 +159,4 @@ tasks.assemble {
141159

142160
tasks.publish {
143161
dependsOn(publishAllClients)
144-
}
162+
}

commitlint.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
extends: ["@commitlint/config-conventional"],
3+
rules: {
4+
"scope-enum": [
5+
2,
6+
"always",
7+
[
8+
"deps",
9+
"projectional-editor",
10+
"mps-plugin",
11+
"interpreter",
12+
"react"
13+
],
14+
],
15+
"subject-case": [0, 'never'],
16+
"body-max-line-length": [0, 'always'],
17+
"footer-max-line-length": [0, 'always']
18+
},
19+
ignores: [
20+
(message) => message.includes('skip-lint')
21+
],
22+
};

0 commit comments

Comments
 (0)