-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (109 loc) · 3.79 KB
/
ci.yml
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
127
128
129
130
131
132
name: CI/CD
on:
push:
jobs:
test:
name: test 🧪
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Setup node
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65
with:
node-version: "20"
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test --workspace @braingoat/compiler
build:
name: build ⚙️
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Setup node
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65
with:
node-version: "20"
- name: Install dependencies
run: npm ci
- name: Build react-app
run: |
npm run build --workspace @braingoat/compiler
npm run build --workspace @braingoat/web -- --base=/braingoat/
- name: Upload build
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
with:
name: react-build
path: packages/web/dist/
deploy-page:
name: deploy web 🚀
runs-on: ubuntu-latest
needs: [build]
if: ${{ github.ref == 'refs/heads/main' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Download build
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: react-build
path: dist/
- name: Setup Pages
uses: actions/configure-pages@1f0c5cde4bc74cd7e1254d0cb4de8d49e9068c7d
- name: Upload artifact
uses: actions/upload-pages-artifact@84bb4cd4b733d5c320c9c9cfbc354937524f4d64
with:
# Upload dist repository
path: "./dist"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@13b55b33dd8996121833dbc1db458c793a334630
deploy-npm:
name: deploy npm 🚀
if: ${{ github.ref == 'refs/heads/main' }}
needs: [build]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
concurrency:
group: "npm"
cancel-in-progress: true
steps:
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Setup node
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65
with:
node-version: "20"
registry-url: 'https://npm.pkg.github.com'
scope: '@wolflu05'
- name: Install dependencies
run: npm ci
- name: Build compiler
run: npm run build -w @braingoat/compiler
- name: Check for existing version
id: check
run: |
version=$(node -e "const fs = require('fs'); const path = require('path'); const p = path.resolve('packages', 'compiler', 'package.json'); const currentPackageJSON = fs.readFileSync(p , {encoding: 'utf-8'}); fs.writeFileSync(p, currentPackageJSON.replace('@braingoat/compiler', '@wolflu05/braingoat'), {encoding: 'utf-8'}); console.log(JSON.parse(currentPackageJSON).version)")
if [[ $(npm search wolflu05/braingoat@$version) == *"No matches"* ]]; then
echo "publish=true" >> $GITHUB_OUTPUT
fi
- name: Publish to gh npm pkg registry
run: npm publish -w @wolflu05/braingoat || true
if: ${{ steps.check.outputs.publish }}
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}