Skip to content

Commit 29da35d

Browse files
committed
ci: release workflow
1 parent 5b8b83d commit 29da35d

File tree

12 files changed

+347
-115
lines changed

12 files changed

+347
-115
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Resolve version
2+
description: Read "version" of "@tutorialkit/astro" to "steps.resolve-release-version.outputs.version"
3+
4+
outputs:
5+
version:
6+
description: 'Version of @tutorialkit/astro'
7+
value: ${{ steps.resolve-release-version.outputs.version }}
8+
9+
runs:
10+
using: composite
11+
12+
steps:
13+
- name: Resolve release version
14+
id: resolve-release-version
15+
shell: bash
16+
run: >
17+
echo "$(
18+
node -e "
19+
const fs = require('fs');
20+
const pkg = fs.readFileSync('./packages/astro/package.json', 'utf8');
21+
const version = JSON.parse(pkg).version
22+
console.log('version=' + version);
23+
"
24+
)" >> $GITHUB_OUTPUT
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Integration Tests CLI
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
cli-integration-test:
8+
name: CLI Integration Tests
9+
# Note: `prepare-release.yaml` sets this commit message
10+
if: ${{ contains(github.event.pull_request.title, 'release tutorialkit CLI') }}
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- uses: ./.github/actions/setup-and-build
19+
20+
- name: Update template's versions
21+
working-directory: ./packages/cli
22+
run: pnpm update-template
23+
24+
- name: Integration Tests
25+
working-directory: ./integration
26+
run: pnpm test
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Prepare release PR
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to publish, e.g. 0.0.1'
8+
required: true
9+
default: '0.0.1'
10+
type: string
11+
12+
jobs:
13+
prepare_release:
14+
name: Prepare release PR
15+
if: ${{ github.event_name == 'workflow_dispatch' }}
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- uses: ./.github/actions/setup-and-build
24+
25+
- name: Bump versions
26+
run: >
27+
pnpm --recursive
28+
--filter "@tutorialkit/*"
29+
--filter create-tutorial
30+
exec pnpm version --no-git-tag-version --allow-same-version ${{ inputs.version }}
31+
32+
- name: Generage changelog
33+
run: |
34+
pnpm run changelog
35+
git checkout ./packages/cli
36+
37+
- name: Create Pull Request
38+
uses: peter-evans/create-pull-request@v6
39+
with:
40+
# Note: `publish-release.yaml` checks explicitly for this commit message
41+
commit-message: 'chore: release @tutorialkit packages and create-tutorial, version: ${{ inputs.version }}'
42+
title: 'chore: release @tutorialkit packages and create-tutorial, version: ${{ inputs.version }}'
43+
body: 'Bump packages to version ${{ inputs.version }} and generate changelogs'
44+
#reviewers: SamVerschueren,d3lm,Nemikolh,AriPerkkio
45+
reviewers: AriPerkkio
46+
branch: chore/release-${{ inputs.version }}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Publish release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish_release:
10+
name: Publish release
11+
runs-on: ubuntu-latest
12+
# Note: `prepare-release.yaml` sets this commit message
13+
if: ${{ contains(github.event.head_commit.message, 'release @tutorialkit packages') }}
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- uses: ./.github/actions/setup-and-build
21+
22+
# Sets steps.resolve-release-version.outputs.version
23+
- uses: ./.github/actions/resolve-release-version
24+
id: resolve-release-version
25+
26+
# TODO: Remove --dry-run
27+
- name: Publish to npm
28+
run: >
29+
pnpm --recursive
30+
--filter "@tutorialkit/*"
31+
--filter create-tutorial
32+
exec pnpm publish --provenance --dry-run
33+
env:
34+
NODE_AUTH_TOKEN: fail-and-prevent-release
35+
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
36+
37+
- name: Create and push git tag
38+
run: |
39+
git config --global user.name 'github-actions'
40+
git config --global user.email '[email protected]'
41+
git tag v${{ steps.resolve-release-version.outputs.version }}
42+
git push origin v${{ steps.resolve-release-version.outputs.version }}
43+
44+
prepare_cli_release:
45+
name: Prepare release for CLI
46+
needs: [publish_release]
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v4
51+
with:
52+
fetch-depth: 0
53+
54+
- uses: ./.github/actions/setup-and-build
55+
56+
# Sets steps.resolve-release-version.outputs.version
57+
- uses: ./.github/actions/resolve-release-version
58+
id: resolve-release-version
59+
60+
# Create release PR for CLI packages
61+
- name: Bump version
62+
run: >
63+
pnpm --recursive
64+
--filter tutorialkit
65+
exec npm version --no-git-tag-version --allow-same-version ${{ steps.resolve-release-version.outputs.version }}
66+
67+
- name: Generage changelog
68+
run: |
69+
pnpm run changelog
70+
git add ./packages/cli ./packages/template
71+
git checkout ./packages
72+
git checkout CHANGELOG.md
73+
74+
- name: Create Pull Request
75+
uses: peter-evans/create-pull-request@v6
76+
with:
77+
# Note: `publish-release.yaml` checks explicitly for this commit message
78+
commit-message: 'chore: release tutorialkit CLI, version: ${{ steps.resolve-release-version.outputs.version }}'
79+
title: 'chore: release tutorialkit CLI, version: ${{ steps.resolve-release-version.outputs.version }}'
80+
body: 'Bump tutorialkit CLI to version ${{ steps.resolve-release-version.outputs.version }} and generate changelog'
81+
#reviewers: SamVerschueren,d3lm,Nemikolh,AriPerkkio
82+
reviewers: AriPerkkio
83+
branch: chore/release-cli-${{ steps.resolve-release-version.outputs.version }}
84+
85+
publish_release_CLI:
86+
name: Publish release CLI
87+
runs-on: ubuntu-latest
88+
# Note: `prepare-release.yaml` sets this commit message
89+
if: ${{ contains(github.event.head_commit.message, 'release tutorialkit CLI') }}
90+
steps:
91+
- name: Checkout
92+
uses: actions/checkout@v4
93+
with:
94+
fetch-depth: 0
95+
96+
- uses: ./.github/actions/setup-and-build
97+
98+
- name: Update template's versions
99+
working-directory: ./packages/cli
100+
run: pnpm update-template
101+
102+
- name: Integration Tests
103+
working-directory: ./integration
104+
run: pnpm test
105+
106+
# TODO: Remove --dry-run
107+
- name: Publish to npm
108+
run: pnpm --recursive --filter tutorialkit exec pnpm publish --provenance --dry-run
109+
env:
110+
NODE_AUTH_TOKEN: fail-and-prevent-release
111+
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/publish.yaml

Lines changed: 0 additions & 36 deletions
This file was deleted.

integration/cli/__snapshots__/create-tutorial.test.ts.snap

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ exports[`npm > should create a project 1`] = `
2020
"icons/languages/ts.svg",
2121
"package-lock.json",
2222
"package.json",
23+
"pnpm-lock.yaml",
2324
"public",
2425
"public/favicon.svg",
26+
"public/logo-dark.svg",
2527
"public/logo.svg",
2628
"src",
2729
"src/content",
@@ -53,6 +55,23 @@ exports[`npm > should create a project 1`] = `
5355
"src/templates/default/style.css",
5456
"tsconfig.json",
5557
"uno.config.ts",
58+
"yarn.lock",
59+
]
60+
`;
61+
62+
exports[`npm > should create and build a project 1`] = `
63+
[
64+
"1-basics",
65+
"1-basics-1-introduction-1-welcome-files.json",
66+
"1-basics-1-introduction-1-welcome-solution.json",
67+
"1-basics/1-introduction",
68+
"1-basics/1-introduction/1-welcome",
69+
"1-basics/1-introduction/1-welcome/index.html",
70+
"favicon.svg",
71+
"index.html",
72+
"logo-dark.svg",
73+
"logo.svg",
74+
"template-default.json",
5675
]
5776
`;
5877

@@ -74,10 +93,12 @@ exports[`pnpm > should create a project 1`] = `
7493
"icons/languages/markdown.svg",
7594
"icons/languages/sass.svg",
7695
"icons/languages/ts.svg",
96+
"package-lock.json",
7797
"package.json",
7898
"pnpm-lock.yaml",
7999
"public",
80100
"public/favicon.svg",
101+
"public/logo-dark.svg",
81102
"public/logo.svg",
82103
"src",
83104
"src/content",
@@ -109,6 +130,23 @@ exports[`pnpm > should create a project 1`] = `
109130
"src/templates/default/style.css",
110131
"tsconfig.json",
111132
"uno.config.ts",
133+
"yarn.lock",
134+
]
135+
`;
136+
137+
exports[`pnpm > should create and build a project 1`] = `
138+
[
139+
"1-basics",
140+
"1-basics-1-introduction-1-welcome-files.json",
141+
"1-basics-1-introduction-1-welcome-solution.json",
142+
"1-basics/1-introduction",
143+
"1-basics/1-introduction/1-welcome",
144+
"1-basics/1-introduction/1-welcome/index.html",
145+
"favicon.svg",
146+
"index.html",
147+
"logo-dark.svg",
148+
"logo.svg",
149+
"template-default.json",
112150
]
113151
`;
114152

@@ -130,9 +168,12 @@ exports[`yarn > should create a project 1`] = `
130168
"icons/languages/markdown.svg",
131169
"icons/languages/sass.svg",
132170
"icons/languages/ts.svg",
171+
"package-lock.json",
133172
"package.json",
173+
"pnpm-lock.yaml",
134174
"public",
135175
"public/favicon.svg",
176+
"public/logo-dark.svg",
136177
"public/logo.svg",
137178
"src",
138179
"src/content",
@@ -167,3 +208,19 @@ exports[`yarn > should create a project 1`] = `
167208
"yarn.lock",
168209
]
169210
`;
211+
212+
exports[`yarn > should create and build a project 1`] = `
213+
[
214+
"1-basics",
215+
"1-basics-1-introduction-1-welcome-files.json",
216+
"1-basics-1-introduction-1-welcome-solution.json",
217+
"1-basics/1-introduction",
218+
"1-basics/1-introduction/1-welcome",
219+
"1-basics/1-introduction/1-welcome/index.html",
220+
"favicon.svg",
221+
"index.html",
222+
"logo-dark.svg",
223+
"logo.svg",
224+
"template-default.json",
225+
]
226+
`;

integration/cli/create-tutorial.test.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,21 @@ describe('yarn', () => {
106106
});
107107

108108
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-
);
109+
const args = [
110+
cli,
111+
'create',
112+
name,
113+
`--${options.install ? '' : 'no-'}install`,
114+
'--no-git',
115+
'--no-start',
116+
'--package-manager',
117+
packageManager,
118+
'--defaults',
119+
];
120+
121+
console.log(`> node ${args.join(' ')}`);
122+
123+
await execa('node', args, { cwd: options.cwd });
125124
}
126125

127126
function normaliseSlash(filePath: string) {

0 commit comments

Comments
 (0)