-
Notifications
You must be signed in to change notification settings - Fork 7
126 lines (103 loc) · 3.68 KB
/
ci.yml
File metadata and controls
126 lines (103 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "22"
registry-url: https://registry.npmjs.org # Needed to make auth work for publishing
- name: Install dependencies
run: npm ci
- name: Check formatting
run: npm run format:check
- name: Rebuild ReScript code
run: npm run build
- name: Run tests
run: npm test
- name: Build documentation
run: npm run build:docs
- name: Upload documentation
uses: actions/upload-pages-artifact@v4
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
with:
path: ./dist
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1
- name: Get short commit hash
id: vars
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Update workspace versions to -<commit-hash>
env:
PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }}-experimental-${{ env.COMMIT_HASH }}
run: |
node <<'NODE'
const fs = require("node:fs");
const path = require("node:path");
const packagesDir = path.join(process.cwd(), "packages");
const version = process.env.PACKAGE_VERSION;
const packages = fs
.readdirSync(packagesDir)
.filter((dir) => fs.existsSync(path.join(packagesDir, dir, "package.json")))
.map((dir) => {
const packageJsonPath = path.join(packagesDir, dir, "package.json");
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
return { packageJsonPath, packageJson };
});
const workspaceNames = new Set(packages.map(({ packageJson }) => packageJson.name));
for (const { packageJsonPath, packageJson } of packages) {
packageJson.version = version;
for (const field of ["dependencies", "peerDependencies", "devDependencies"]) {
if (!packageJson[field]) continue;
for (const dependencyName of Object.keys(packageJson[field])) {
if (workspaceNames.has(dependencyName)) {
packageJson[field][dependencyName] = version;
}
}
}
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
}
NODE
- name: Package npm workspaces
run: npm pack --workspaces
- name: Upload npm package artifact
uses: actions/upload-artifact@v7
with:
name: npm-packages
path: "*.tgz"
- name: Publish npm packages
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
run: |
for package in packages/*; do
if [ -f "$package/package.json" ]; then
npm publish --workspace "$package" --access public --tag experimental
fi
done
deploy-docs:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5