Skip to content

Commit 09f077b

Browse files
SamVerschuerenAriPerkkio
authored andcommitted
ci: add automated releases
1 parent d8a5a34 commit 09f077b

File tree

11 files changed

+534
-39
lines changed

11 files changed

+534
-39
lines changed

.github/workflows/publish.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: 'Version to publish'
7+
required: true
8+
type: string
9+
tag:
10+
description: 'Tag to publish'
11+
required: false
12+
type: string
13+
default: 'latest'
14+
15+
jobs:
16+
publish_packages:
17+
name: Publish packages
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Setup
21+
uses: pnpm/action-setup@v4
22+
with:
23+
version: 8
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
- name: Bump version
27+
run: pnpm --recursive --filter "@tutorialkit/*" --filter tutorialkit --filter create-tutorial exec npm version --allow-same-version ${{ inputs.version }}
28+
# Generate changelogs
29+
- name: Create Pull Request
30+
uses: peter-evans/create-pull-request@v6
31+
with:
32+
commit-message: "chore: bump version ${{ inputs.version }}"
33+
title: "chore: bump version ${{ inputs.version }}"
34+
body: "Bump packages to version ${{ inputs.version }}"
35+
reviewers: SamVerschueren,d3lm,Nemikolh
36+
branch: chore/bump-version

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dist-ssr
1818
*.sln
1919
*.sw?
2020
.pnpm-store
21-
/tutorialkit/template
21+
/packages/cli/template
2222
tsconfig.tsbuildinfo
2323
tsconfig.build.tsbuildinfo
2424
.tmp

integration/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Integration
2+
3+
TODO add comment
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`npm > should create a project 1`] = `
4+
[
5+
".gitignore",
6+
".vscode",
7+
".vscode/extensions.json",
8+
".vscode/launch.json",
9+
".vscode/settings.json",
10+
"README.md",
11+
"astro.config.ts",
12+
"icons",
13+
"icons/languages",
14+
"icons/languages/css.svg",
15+
"icons/languages/html.svg",
16+
"icons/languages/js.svg",
17+
"icons/languages/json.svg",
18+
"icons/languages/markdown.svg",
19+
"icons/languages/sass.svg",
20+
"icons/languages/ts.svg",
21+
"package-lock.json",
22+
"package.json",
23+
"public",
24+
"public/favicon.svg",
25+
"public/logo.svg",
26+
"src",
27+
"src/content",
28+
"src/content/config.ts",
29+
"src/content/tutorial",
30+
"src/content/tutorial/1-basics",
31+
"src/content/tutorial/1-basics/1-introduction",
32+
"src/content/tutorial/1-basics/1-introduction/1-welcome",
33+
"src/content/tutorial/1-basics/1-introduction/1-welcome/_files",
34+
"src/content/tutorial/1-basics/1-introduction/1-welcome/_files/counter.js",
35+
"src/content/tutorial/1-basics/1-introduction/1-welcome/_solution",
36+
"src/content/tutorial/1-basics/1-introduction/1-welcome/_solution/counter.js",
37+
"src/content/tutorial/1-basics/1-introduction/1-welcome/content.md",
38+
"src/content/tutorial/1-basics/1-introduction/meta.md",
39+
"src/content/tutorial/1-basics/meta.md",
40+
"src/content/tutorial/meta.md",
41+
"src/env.d.ts",
42+
"src/templates",
43+
"src/templates/default",
44+
"src/templates/default/.gitignore",
45+
"src/templates/default/counter.js",
46+
"src/templates/default/index.html",
47+
"src/templates/default/javascript.svg",
48+
"src/templates/default/main.js",
49+
"src/templates/default/package-lock.json",
50+
"src/templates/default/package.json",
51+
"src/templates/default/public",
52+
"src/templates/default/public/vite.svg",
53+
"src/templates/default/style.css",
54+
"tsconfig.json",
55+
"uno.config.ts",
56+
]
57+
`;
58+
59+
exports[`pnpm > should create a project 1`] = `
60+
[
61+
".gitignore",
62+
".vscode",
63+
".vscode/extensions.json",
64+
".vscode/launch.json",
65+
".vscode/settings.json",
66+
"README.md",
67+
"astro.config.ts",
68+
"icons",
69+
"icons/languages",
70+
"icons/languages/css.svg",
71+
"icons/languages/html.svg",
72+
"icons/languages/js.svg",
73+
"icons/languages/json.svg",
74+
"icons/languages/markdown.svg",
75+
"icons/languages/sass.svg",
76+
"icons/languages/ts.svg",
77+
"package.json",
78+
"pnpm-lock.yaml",
79+
"public",
80+
"public/favicon.svg",
81+
"public/logo.svg",
82+
"src",
83+
"src/content",
84+
"src/content/config.ts",
85+
"src/content/tutorial",
86+
"src/content/tutorial/1-basics",
87+
"src/content/tutorial/1-basics/1-introduction",
88+
"src/content/tutorial/1-basics/1-introduction/1-welcome",
89+
"src/content/tutorial/1-basics/1-introduction/1-welcome/_files",
90+
"src/content/tutorial/1-basics/1-introduction/1-welcome/_files/counter.js",
91+
"src/content/tutorial/1-basics/1-introduction/1-welcome/_solution",
92+
"src/content/tutorial/1-basics/1-introduction/1-welcome/_solution/counter.js",
93+
"src/content/tutorial/1-basics/1-introduction/1-welcome/content.md",
94+
"src/content/tutorial/1-basics/1-introduction/meta.md",
95+
"src/content/tutorial/1-basics/meta.md",
96+
"src/content/tutorial/meta.md",
97+
"src/env.d.ts",
98+
"src/templates",
99+
"src/templates/default",
100+
"src/templates/default/.gitignore",
101+
"src/templates/default/counter.js",
102+
"src/templates/default/index.html",
103+
"src/templates/default/javascript.svg",
104+
"src/templates/default/main.js",
105+
"src/templates/default/package-lock.json",
106+
"src/templates/default/package.json",
107+
"src/templates/default/public",
108+
"src/templates/default/public/vite.svg",
109+
"src/templates/default/style.css",
110+
"tsconfig.json",
111+
"uno.config.ts",
112+
]
113+
`;
114+
115+
exports[`yarn > should create a project 1`] = `
116+
[
117+
".gitignore",
118+
".vscode",
119+
".vscode/extensions.json",
120+
".vscode/launch.json",
121+
".vscode/settings.json",
122+
"README.md",
123+
"astro.config.ts",
124+
"icons",
125+
"icons/languages",
126+
"icons/languages/css.svg",
127+
"icons/languages/html.svg",
128+
"icons/languages/js.svg",
129+
"icons/languages/json.svg",
130+
"icons/languages/markdown.svg",
131+
"icons/languages/sass.svg",
132+
"icons/languages/ts.svg",
133+
"package.json",
134+
"public",
135+
"public/favicon.svg",
136+
"public/logo.svg",
137+
"src",
138+
"src/content",
139+
"src/content/config.ts",
140+
"src/content/tutorial",
141+
"src/content/tutorial/1-basics",
142+
"src/content/tutorial/1-basics/1-introduction",
143+
"src/content/tutorial/1-basics/1-introduction/1-welcome",
144+
"src/content/tutorial/1-basics/1-introduction/1-welcome/_files",
145+
"src/content/tutorial/1-basics/1-introduction/1-welcome/_files/counter.js",
146+
"src/content/tutorial/1-basics/1-introduction/1-welcome/_solution",
147+
"src/content/tutorial/1-basics/1-introduction/1-welcome/_solution/counter.js",
148+
"src/content/tutorial/1-basics/1-introduction/1-welcome/content.md",
149+
"src/content/tutorial/1-basics/1-introduction/meta.md",
150+
"src/content/tutorial/1-basics/meta.md",
151+
"src/content/tutorial/meta.md",
152+
"src/env.d.ts",
153+
"src/templates",
154+
"src/templates/default",
155+
"src/templates/default/.gitignore",
156+
"src/templates/default/counter.js",
157+
"src/templates/default/index.html",
158+
"src/templates/default/javascript.svg",
159+
"src/templates/default/main.js",
160+
"src/templates/default/package-lock.json",
161+
"src/templates/default/package.json",
162+
"src/templates/default/public",
163+
"src/templates/default/public/vite.svg",
164+
"src/templates/default/style.css",
165+
"tsconfig.json",
166+
"uno.config.ts",
167+
"yarn.lock",
168+
]
169+
`;
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import path from 'node:path';
2+
import fs from 'node:fs/promises';
3+
import { describe, beforeEach, afterAll, expect, it } from 'vitest';
4+
import { execa } from 'execa';
5+
import { temporaryDirectory } from 'tempy';
6+
7+
const baseDir = path.resolve(__dirname, '../..');
8+
9+
const cli = path.join(baseDir, 'packages/cli/dist/index.js');
10+
11+
interface TestContext {
12+
projectName: string;
13+
dest: string;
14+
}
15+
16+
const tmp = temporaryDirectory();
17+
18+
beforeEach<TestContext>(async (context) => {
19+
context.projectName = Math.random().toString(36).substring(7);
20+
context.dest = path.join(tmp, context.projectName);
21+
});
22+
23+
afterAll(async () => {
24+
await fs.rm(tmp, { force: true, recursive: true });
25+
});
26+
27+
describe('npm', () => {
28+
const packageManager = 'npm';
29+
30+
it<TestContext>('should create a project', async ({ projectName, dest }) => {
31+
await createProject(projectName, packageManager, { cwd: tmp });
32+
33+
const projectFiles = await fs.readdir(dest, { recursive: true });
34+
35+
expect(projectFiles.map(normaliseSlash).sort()).toMatchSnapshot();
36+
});
37+
38+
it<TestContext>('should create and build a project', async ({ projectName, dest }) => {
39+
await createProject(projectName, packageManager, { cwd: tmp, install: true });
40+
41+
await execa(packageManager, ['run', 'build'], {
42+
cwd: dest,
43+
});
44+
45+
// remove `_astro` before taking the snapshot
46+
await fs.rm(path.join(dest, 'dist/_astro'), { force: true, recursive: true });
47+
48+
const distFiles = await fs.readdir(path.join(dest, 'dist'), { recursive: true });
49+
50+
expect(distFiles.map(normaliseSlash).sort()).toMatchSnapshot();
51+
});
52+
});
53+
54+
describe('pnpm', () => {
55+
const packageManager = 'pnpm';
56+
57+
it<TestContext>('should create a project', async ({ projectName, dest }) => {
58+
await createProject(projectName, packageManager, { cwd: tmp });
59+
60+
const projectFiles = await fs.readdir(dest, { recursive: true });
61+
62+
expect(projectFiles.map(normaliseSlash).sort()).toMatchSnapshot();
63+
});
64+
65+
it<TestContext>('should create and build a project', async ({ projectName, dest }) => {
66+
await createProject(projectName, packageManager, { cwd: tmp, install: true });
67+
68+
await execa(packageManager, ['run', 'build'], {
69+
cwd: dest,
70+
});
71+
72+
// remove `_astro` before taking the snapshot
73+
await fs.rm(path.join(dest, 'dist/_astro'), { force: true, recursive: true });
74+
75+
const distFiles = await fs.readdir(path.join(dest, 'dist'), { recursive: true });
76+
77+
expect(distFiles.map(normaliseSlash).sort()).toMatchSnapshot();
78+
});
79+
});
80+
81+
describe('yarn', () => {
82+
const packageManager = 'yarn';
83+
84+
it<TestContext>('should create a project', async ({ projectName, dest }) => {
85+
await createProject(projectName, packageManager, { cwd: tmp });
86+
87+
const projectFiles = await fs.readdir(dest, { recursive: true });
88+
89+
expect(projectFiles.map(normaliseSlash).sort()).toMatchSnapshot();
90+
});
91+
92+
it<TestContext>('should create and build a project', async ({ projectName, dest }) => {
93+
await createProject(projectName, packageManager, { cwd: tmp, install: true });
94+
95+
await execa(packageManager, ['run', 'build'], {
96+
cwd: dest,
97+
});
98+
99+
// remove `_astro` before taking the snapshot
100+
await fs.rm(path.join(dest, 'dist/_astro'), { force: true, recursive: true });
101+
102+
const distFiles = await fs.readdir(path.join(dest, 'dist'), { recursive: true });
103+
104+
expect(distFiles.map(normaliseSlash).sort()).toMatchSnapshot();
105+
});
106+
});
107+
108+
async function createProject(name: string, packageManager: string, options: { cwd: string; install?: boolean }) {
109+
await execa(
110+
'node',
111+
[
112+
cli,
113+
'create',
114+
name,
115+
`--${options.install ? '' : 'no-'}install`,
116+
'--no-git',
117+
'--package-manager',
118+
packageManager,
119+
'--defaults',
120+
],
121+
{
122+
cwd: options.cwd,
123+
},
124+
);
125+
}
126+
127+
function normaliseSlash(filePath: string) {
128+
return filePath.replace(/\\/g, '/');
129+
}

integration/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "tutorialkit-integration",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"test": "vitest --testTimeout=300000"
7+
},
8+
"dependencies": {
9+
"execa": "^9.2.0",
10+
"tempy": "^3.1.0",
11+
"vitest": "^1.6.0"
12+
}
13+
}

packages/cli/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
"scripts": {
1717
"build": "node scripts/build.js",
1818
"prepack": "node scripts/pre-pack.js",
19-
"postpack": "node scripts/cleanup.js",
20-
"test": "vitest --testTimeout=300000"
19+
"postpack": "node scripts/cleanup.js"
2120
},
2221
"files": [
2322
"dist",
@@ -45,7 +44,7 @@
4544
"esbuild": "^0.20.2",
4645
"esbuild-node-externals": "^1.13.1",
4746
"fs-extra": "^11.2.0",
48-
"vitest": "^1.6.0"
47+
"tempy": "^3.1.0"
4948
},
5049
"engines": {
5150
"node": ">=18.18.0"

0 commit comments

Comments
 (0)