Skip to content

Commit a9eed5f

Browse files
author
Dimy Jeannot
committed
feat: preparing for release
1 parent bfc8088 commit a9eed5f

File tree

16 files changed

+252
-135
lines changed

16 files changed

+252
-135
lines changed

governance/NIGHTLY.md

Whitespace-only changes.

governance/RELEASE.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,10 @@
33

44
# Initial Release
55
nx release --first-release -p go-protobuf-sdk-v2beta --dry-run
6+
nx release --first-release -p go-sdk-v2beta --dry-run
67

78
# Subsequent Releases
89

9-
# Step 1: Run NX to Tag and version
10-
nx release -p go-protobuf-sdk-v2beta --yes
11-
12-
# Step 2: Push the tag and version bump
13-
git push --follow-tags
14-
15-
# Step 3: Run GoReleaser
16-
nx run go-protobuf-sdk-v2beta:distribute
17-
18-
1910

2011
# 0. Fail if working directory is dirty
2112
git diff --exit-code || (echo "Uncommitted changes. Aborting." && exit 1)
@@ -31,4 +22,6 @@ TAG=$(git describe --tags --abbrev=0)
3122
git checkout $TAG
3223

3324
# 4. Run GoReleaser from the tagged commit
34-
nx run go-protobuf-sdk-v2beta:distribute
25+
nx run go-protobuf-sdk-v2beta:distribute
26+
27+

governance/SNAPSHOT.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# To snapshot
2+
3+
nx run go-protobuf-sdk-v2beta:snapshot
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# nx-goreleaser-sdk
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
## Building
6+
7+
Run `nx build nx-goreleaser-sdk` to build the library.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@platform/nx-goreleaser-sdk",
3+
"version": "0.0.1",
4+
"dependencies": {
5+
"tslib": "^2.3.0"
6+
},
7+
"type": "commonjs",
8+
"main": "./src/index.js",
9+
"typings": "./src/index.d.ts",
10+
"private": true
11+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "nx-goreleaser-sdk",
3+
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "libs/plugins/nx-goreleaser-sdk/src",
5+
"projectType": "library",
6+
"tags": [],
7+
"targets": {
8+
"build": {
9+
"executor": "@nx/js:tsc",
10+
"outputs": ["{options.outputPath}"],
11+
"options": {
12+
"outputPath": "dist/libs/plugins/nx-goreleaser-sdk",
13+
"main": "libs/plugins/nx-goreleaser-sdk/src/index.ts",
14+
"tsConfig": "libs/plugins/nx-goreleaser-sdk/tsconfig.lib.json",
15+
"assets": [
16+
"libs/plugins/nx-goreleaser-sdk/*.md",
17+
{
18+
"input": "./libs/plugins/nx-goreleaser-sdk/src",
19+
"glob": "**/!(*.ts)",
20+
"output": "./src"
21+
},
22+
{
23+
"input": "./libs/plugins/nx-goreleaser-sdk/src",
24+
"glob": "**/*.d.ts",
25+
"output": "./src"
26+
},
27+
{
28+
"input": "./libs/plugins/nx-goreleaser-sdk",
29+
"glob": "generators.json",
30+
"output": "."
31+
},
32+
{
33+
"input": "./libs/plugins/nx-goreleaser-sdk",
34+
"glob": "executors.json",
35+
"output": "."
36+
}
37+
]
38+
}
39+
}
40+
}
41+
}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
import { ProjectConfiguration } from 'nx/src/config/workspace-json-project-json';
2+
import { dirname, join, relative, sep } from 'path';
3+
import { existsSync } from 'fs';
4+
import * as fs from 'fs';
5+
import * as path from 'path';
6+
7+
export const createNodes = [
8+
'**/go.mod',
9+
(file: string): { projects: Record<string, ProjectConfiguration> } => {
10+
const projectRoot = dirname(file);
11+
const distPath = join('dist', projectRoot);
12+
const goreleaserPath = join(projectRoot, '.goreleaser.sdk.yaml');
13+
const packageJsonPath = join(projectRoot, 'package.json');
14+
15+
if (!existsSync(packageJsonPath)) {
16+
return { projects: {} };
17+
}
18+
19+
if (!existsSync(goreleaserPath)) {
20+
return { projects: {} };
21+
}
22+
23+
try {
24+
const content = fs.readFileSync(packageJsonPath, 'utf-8');
25+
const json = JSON.parse(content);
26+
const projectName = json.name;
27+
const targets: ProjectConfiguration['targets'] = {
28+
build: {
29+
executor: 'nx:run-commands',
30+
outputs: [
31+
`{workspaceRoot}/${distPath}/artifacts.json`,
32+
],
33+
options: {
34+
commands: [
35+
`goreleaser build --clean --snapshot --config ${projectRoot}/.goreleaser.sdk.yaml`
36+
],
37+
parallel: false,
38+
forwardAllArgs: false,
39+
cwd: "",
40+
},
41+
},
42+
test: {
43+
executor: 'nx:run-commands',
44+
options: {
45+
command: 'go test -v ./... -cover -race',
46+
cwd: projectRoot,
47+
},
48+
},
49+
clean: {
50+
executor: 'nx:run-commands',
51+
options: {
52+
command: `rm -rf ${distPath}`,
53+
cwd: "",
54+
},
55+
},
56+
format: {
57+
executor: 'nx:run-commands',
58+
options: {
59+
commands: [
60+
'go mod tidy',
61+
'gofumpt -l -w .',
62+
'golangci-lint run ./... --timeout=5m --fix',
63+
],
64+
parallel: false,
65+
cwd: projectRoot,
66+
},
67+
},
68+
distribute: {
69+
executor: 'nx:run-commands',
70+
dependsOn: ['build'],
71+
outputs: [`{workspaceRoot}/dist/${projectRoot}`],
72+
options: {
73+
commands: [
74+
`goreleaser release --config ${projectRoot}/.goreleaser.sdk.yaml --clean`,
75+
],
76+
parallel: false,
77+
forwardAllArgs: false,
78+
},
79+
cache: false
80+
},
81+
snapshot: {
82+
executor: 'nx:run-commands',
83+
dependsOn: ['build'],
84+
outputs: [`{workspaceRoot}/dist/${projectRoot}`],
85+
options: {
86+
commands: [
87+
`goreleaser release --config ${projectRoot}/.goreleaser.sdk.yaml --snapshot --clean --skip=sign,sbom --verbose`,
88+
],
89+
parallel: false,
90+
forwardAllArgs: false,
91+
},
92+
cache: false
93+
},
94+
nightly: {
95+
executor: 'nx:run-commands',
96+
dependsOn: ['build'],
97+
outputs: [`{workspaceRoot}/dist/${projectRoot}`],
98+
options: {
99+
commands: [
100+
`goreleaser release --config ${projectRoot}/.goreleaser.sdk.yaml --nightly --clean --verbose`,
101+
],
102+
parallel: false,
103+
forwardAllArgs: false,
104+
},
105+
cache: false
106+
},
107+
};
108+
109+
const project: ProjectConfiguration = {
110+
name: projectName,
111+
root: projectRoot,
112+
projectType: 'library',
113+
targets,
114+
tags: [
115+
'lang:go',
116+
"language:golang",
117+
"type:sdk",
118+
],
119+
};
120+
121+
return {
122+
projects: {
123+
[projectName]: project,
124+
},
125+
};
126+
127+
128+
} catch (err) {
129+
console.warn(`Failed to read or parse package.json at ${packageJsonPath}:`, err);
130+
return { projects: {} };
131+
}
132+
133+
},
134+
];
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "commonjs"
5+
},
6+
"files": [],
7+
"include": [],
8+
"references": [
9+
{
10+
"path": "./tsconfig.lib.json"
11+
}
12+
]
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../../dist/out-tsc",
5+
"declaration": true,
6+
"types": ["node"]
7+
},
8+
"include": ["src/**/*.ts"]
9+
}
File renamed without changes.

0 commit comments

Comments
 (0)