Skip to content

Commit e155ee9

Browse files
Merge pull request #4 from no-witness-labs/fix/release-ci
fix/release ci
2 parents 7a4acf4 + 4c6d97f commit e155ee9

File tree

15 files changed

+485
-437
lines changed

15 files changed

+485
-437
lines changed

.github/workflows/ci.yml

Lines changed: 75 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -12,108 +12,100 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15-
lint:
16-
name: ⬣ ESLint
15+
setup:
16+
name: Setup
1717
runs-on: ubuntu-latest
18+
outputs:
19+
cache-hit: ${{ steps.cache-node-modules.outputs.cache-hit }}
1820
steps:
19-
- name: ⬇️ Checkout repo
20-
uses: actions/checkout@v4
21-
22-
- name: 📦 Install pnpm
23-
uses: pnpm/action-setup@v4
24-
25-
- name: ⎔ Setup Node.js
26-
uses: actions/setup-node@v4
21+
- uses: actions/checkout@v4
2722
with:
28-
node-version: 20
29-
cache: 'pnpm'
30-
31-
- name: 📦 Install dependencies
32-
run: pnpm install --frozen-lockfile
33-
34-
- name: 🔬 Lint
35-
run: pnpm turbo run lint --affected
36-
37-
typecheck:
38-
name: ʦ TypeScript
39-
runs-on: ubuntu-latest
40-
steps:
41-
- name: ⬇️ Checkout repo
42-
uses: actions/checkout@v4
23+
fetch-depth: 2
4324

44-
- name: 📦 Install pnpm
45-
uses: pnpm/action-setup@v4
25+
- uses: pnpm/action-setup@v4
4626

47-
- name: ⎔ Setup Node.js
48-
uses: actions/setup-node@v4
27+
- uses: actions/setup-node@v4
4928
with:
5029
node-version: 20
5130
cache: 'pnpm'
5231

53-
- name: 📦 Install dependencies
54-
run: pnpm install --frozen-lockfile
55-
56-
- name: 🔎 Type check
57-
run: pnpm turbo run type-check --affected
58-
59-
test:
60-
name: 🧪 Test
32+
- id: cache-node-modules
33+
uses: actions/cache@v4
34+
with:
35+
path: |
36+
node_modules
37+
packages/*/node_modules
38+
docs/node_modules
39+
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
40+
restore-keys: |
41+
${{ runner.os }}-modules-
42+
43+
- id: cache-turbo
44+
uses: actions/cache@v4
45+
with:
46+
path: .turbo
47+
key: ${{ runner.os }}-turbo-${{ github.sha }}
48+
restore-keys: |
49+
${{ runner.os }}-turbo-
50+
51+
# Always run install to ensure all dependencies are available
52+
# This ensures workspace packages like docs have their dependencies
53+
- run: pnpm install --frozen-lockfile
54+
55+
validate:
56+
name: Validate
57+
needs: setup
6158
runs-on: ubuntu-latest
6259
steps:
63-
- name: ⬇️ Checkout repo
64-
uses: actions/checkout@v4
60+
- uses: actions/checkout@v4
61+
with:
62+
fetch-depth: 2
6563

66-
- name: 📦 Install pnpm
67-
uses: pnpm/action-setup@v4
64+
- uses: pnpm/action-setup@v4
6865

69-
- name: ⎔ Setup Node.js
70-
uses: actions/setup-node@v4
66+
- uses: actions/setup-node@v4
7167
with:
7268
node-version: 20
7369
cache: 'pnpm'
7470

75-
- name: 📦 Install dependencies
76-
run: pnpm install --frozen-lockfile
77-
78-
- name: 🧪 Run tests
79-
run: pnpm turbo run test --affected
71+
- uses: actions/cache@v4
72+
with:
73+
path: |
74+
node_modules
75+
packages/*/node_modules
76+
docs/node_modules
77+
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
78+
restore-keys: |
79+
${{ runner.os }}-modules-
80+
81+
- uses: actions/cache@v4
82+
with:
83+
path: .turbo
84+
key: ${{ runner.os }}-turbo-${{ github.sha }}
85+
restore-keys: |
86+
${{ runner.os }}-turbo-
87+
88+
- run: pnpm turbo run lint --affected
89+
- run: pnpm turbo run type-check --affected
90+
- run: pnpm turbo run build --affected
91+
- run: pnpm turbo run test --affected
92+
93+
- uses: actions/upload-artifact@v4
94+
with:
95+
name: build-artifacts
96+
path: packages/*/dist
8097

81-
build:
82-
name: 🏗 Build
98+
cache-build:
99+
name: Cache Artifacts
100+
needs: validate
83101
runs-on: ubuntu-latest
84102
steps:
85-
- name: ⬇️ Checkout repo
86-
uses: actions/checkout@v4
87-
88-
- name: 📦 Install pnpm
89-
uses: pnpm/action-setup@v4
90-
91-
- name: ⎔ Setup Node.js
92-
uses: actions/setup-node@v4
103+
- uses: actions/download-artifact@v4
93104
with:
94-
node-version: 20
95-
cache: 'pnpm'
96-
97-
- name: 📦 Install dependencies
98-
run: pnpm install --frozen-lockfile
99-
100-
- name: 🏗 Build packages
101-
run: pnpm turbo run build --affected
102-
103-
- name: 📄 Generate docs (validate examples)
104-
run: pnpm turbo run docgen --affected || echo "No docgen script found, skipping"
105+
name: build-artifacts
106+
path: packages
105107

106-
# All jobs must pass
107-
ci:
108-
name: ✅ CI
109-
runs-on: ubuntu-latest
110-
if: always()
111-
needs: [lint, typecheck, test, build]
112-
steps:
113-
- name: ✅ All jobs passed
114-
if: ${{ !(contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }}
115-
run: exit 0
116-
117-
- name: ❌ Some jobs failed
118-
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
119-
run: exit 1
108+
- uses: actions/cache@v4
109+
with:
110+
path: packages/*/dist
111+
key: build-artifacts-${{ github.sha }}

.github/workflows/docs.yml

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,53 +22,62 @@ jobs:
2222
runs-on: ubuntu-latest
2323

2424
steps:
25-
- name: ⬇️ Checkout
26-
uses: actions/checkout@v4
25+
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 2
28+
29+
- uses: pnpm/action-setup@v4
2730

28-
- name: ⎔ Install Node.js
29-
uses: actions/setup-node@v4
31+
- uses: actions/setup-node@v4
3032
with:
3133
node-version: 20
34+
cache: 'pnpm'
3235

33-
- name: 📦 Install pnpm
34-
uses: pnpm/action-setup@v4
36+
- id: cached-build-artifacts
37+
uses: actions/cache@v4
3538
with:
36-
run_install: false
39+
path: packages/*/dist
40+
key: build-artifacts-${{ github.sha }}
3741

38-
- name: Get pnpm store directory
39-
shell: bash
40-
run: |
41-
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
42+
- id: cache-node-modules
43+
uses: actions/cache@v4
44+
with:
45+
path: |
46+
node_modules
47+
packages/*/node_modules
48+
docs/node_modules
49+
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
50+
restore-keys: |
51+
${{ runner.os }}-modules-
4252
43-
- name: Setup pnpm cache
53+
- id: cache-turbo
4454
uses: actions/cache@v4
4555
with:
46-
path: ${{ env.STORE_PATH }}
47-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
56+
path: .turbo
57+
key: ${{ runner.os }}-turbo-${{ github.sha }}
4858
restore-keys: |
49-
${{ runner.os }}-pnpm-store-
59+
${{ runner.os }}-turbo-
5060
51-
- name: 📦 Install dependencies
52-
run: pnpm install
61+
# Always run install to ensure all dependencies are available
62+
# This ensures workspace packages like docs have their dependencies
63+
- run: pnpm install --frozen-lockfile
5364

54-
- name: 🏗 Build packages (required for docs)
55-
run: pnpm turbo run build
65+
- run: pnpm turbo run build
66+
if: steps.cached-build-artifacts.outputs.cache-hit != 'true'
5667

57-
- name: 📄 Generate Evolution SDK docs
58-
run: pnpm turbo run docgen
59-
working-directory: packages/evolution
68+
- run: pnpm turbo run docgen --filter=evolution
6069

61-
- name: 📚 Copy Evolution docs to website
62-
run: node scripts/copy-evolution-docs.mjs
63-
working-directory: docs
70+
- run: pnpm turbo run build --filter=docs
6471

65-
- name: 🏗 Build documentation
66-
run: |
67-
cd docs
68-
pnpm build
72+
- id: cache-docs-output
73+
uses: actions/cache@v4
74+
with:
75+
path: docs/out
76+
key: docs-output-${{ github.sha }}
77+
restore-keys: |
78+
docs-output-
6979
70-
- name: 📤 Upload artifact
71-
uses: actions/upload-pages-artifact@v3
80+
- uses: actions/upload-pages-artifact@v3
7281
with:
7382
path: docs/out
7483

@@ -80,6 +89,5 @@ jobs:
8089
runs-on: ubuntu-latest
8190
needs: build
8291
steps:
83-
- name: 🚀 Deploy to GitHub Pages
84-
id: deployment
92+
- id: deployment
8593
uses: actions/deploy-pages@v4

.github/workflows/release.yml

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,70 @@ on:
44
push:
55
branches:
66
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
id-token: write
713

814
concurrency: ${{ github.workflow }}-${{ github.ref }}
915

1016
jobs:
1117
release:
12-
name: 🚀 Release
18+
name: Release
1319
runs-on: ubuntu-latest
1420
steps:
15-
- name: ⬇️ Checkout repo
16-
uses: actions/checkout@v4
21+
- uses: actions/checkout@v4
1722
with:
18-
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
1923
fetch-depth: 0
2024

21-
- name: 📦 Install pnpm
22-
uses: pnpm/action-setup@v4
25+
- uses: pnpm/action-setup@v4
2326

24-
- name: ⎔ Setup Node.js
25-
uses: actions/setup-node@v4
27+
- uses: actions/setup-node@v4
2628
with:
2729
node-version: 20
2830
cache: 'pnpm'
2931
registry-url: 'https://registry.npmjs.org/'
3032

31-
- name: 📦 Install dependencies
32-
run: pnpm install --frozen-lockfile
33+
- id: cached-build-artifacts
34+
uses: actions/cache@v4
35+
with:
36+
path: packages/*/dist
37+
key: build-artifacts-${{ github.sha }}
3338

34-
- name: 🏗 Build packages
35-
run: pnpm turbo run build
39+
- id: cache-node-modules
40+
uses: actions/cache@v4
41+
with:
42+
path: |
43+
node_modules
44+
packages/*/node_modules
45+
docs/node_modules
46+
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
47+
restore-keys: |
48+
${{ runner.os }}-modules-
49+
50+
- uses: actions/cache@v4
51+
with:
52+
path: .turbo
53+
key: ${{ runner.os }}-turbo-${{ github.sha }}
54+
restore-keys: |
55+
${{ runner.os }}-turbo-
3656
37-
- name: 🧪 Run tests
38-
run: pnpm turbo run test
57+
# Always run install to ensure all dependencies are available
58+
# This ensures workspace packages like docs have their dependencies
59+
- run: pnpm install --frozen-lockfile
3960

40-
- name: 📄 Generate docs
41-
run: pnpm turbo run docgen || echo "No docgen script found, skipping"
61+
- run: pnpm turbo run build
62+
if: steps.cached-build-artifacts.outputs.cache-hit != 'true'
4263

43-
- name: 🦋 Create Release Pull Request or Publish to npm
44-
id: changesets
64+
- id: changesets
4565
uses: changesets/action@v1
4666
with:
47-
# This uses our custom publish script that builds before publishing
4867
publish: pnpm changeset-publish
4968
title: "ci(changesets): version packages"
5069
commit: "ci(changesets): version packages"
5170
createGithubReleases: true
5271
env:
5372
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55-
56-
- name: 📢 Send a Slack notification if a publish happened
57-
if: steps.changesets.outputs.published == 'true'
58-
# You can do something when a publish happens.
59-
run: echo "A new version of Evolution SDK was published!"
73+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ dist
66
.DS_Store
77
.direnv
88
docs/out
9-
docs/.next
9+
docs/.next
10+
# TypeScript incremental compilation cache
11+
*.tsbuildinfo
12+
.tsbuildinfo/

0 commit comments

Comments
 (0)