-
-
Notifications
You must be signed in to change notification settings - Fork 11
160 lines (155 loc) · 4.67 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: Continuous Integration
on:
push:
branches: main
pull_request:
branches: main
paths-ignore:
- '**/*.md'
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.packages.outputs.packages }}
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
- name: List packages
id: packages
run: |
echo "packages=$(deno eval 'console.log(JSON.stringify([...Deno.readDirSync(`.`)].filter(({name}) => { try { return Deno.openSync(`${name}/deno.jsonc`) } catch { return false } }).map(({name}) => name)))')" >> $GITHUB_OUTPUT
package:
name: Package
needs: setup
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.setup.outputs.packages) }}
permissions:
id-token: write
contents: write
packages: write
security-events: write
uses: lowlighter/libs/.github/workflows/ci_package.yml@main
with:
ref: ${{ github.ref }}
event: ${{ github.event_name }}
package: ${{ matrix.package }}
publish: ${{ github.event_name == 'push' }}
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
coverage:
name: Coverage
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
needs:
- setup
- package
environment:
name: github-pages
url: ${{ steps.pages.outputs.page_url }}
permissions:
id-token: write
pages: write
steps:
- uses: actions/checkout@v4
with:
ref: main
- uses: actions/configure-pages@v5
- uses: denoland/setup-deno@v1
with:
deno-version: 1.x
- uses: actions/setup-node@v4
with:
node-version: 22.x
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Run deno task coverage
run: |
PACKAGES=$(echo '${{ needs.setup.outputs.packages }}' | jq -cr '.[]')
for PACKAGE in $PACKAGES; do
pushd $PACKAGE
deno task ci:coverage
popd
done
deno run --allow-read --allow-write=coverage --allow-net jsr:@libs/bundle/ts/cli/coverage --root=coverage
mv coverage _site
- uses: actions/upload-pages-artifact@v3
- id: pages
uses: actions/deploy-pages@v4
autogen:
name: Auto-generate files
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
needs:
- setup
- package
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: main
- uses: denoland/setup-deno@v1
- name: Configure git
run: git config user.name 'github-actions[bot]' && git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
- name: Run deno task config
run: |
deno task config
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m 'chore: update `deno.jsonc`'
git pull --rebase
git push
fi
- name: Run deno task readme
run: |
deno task readme
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m 'doc: update `README.md`'
git pull --rebase
git push
fi
codeql:
name: Code quality (global)
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
needs: package
permissions:
security-events: write
steps:
- uses: actions/checkout@v4
with:
ref: main
- uses: github/codeql-action/init@v3
with:
languages: typescript
- uses: github/codeql-action/analyze@v3
publish:
name: Publish
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
needs:
- autogen
- codeql
permissions:
id-token: write
contents: write
steps:
# Setup
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: denoland/setup-deno@v1
- name: Configure git
run: git config user.name 'github-actions[bot]' && git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
# Publish
- name: Run deno.land/x publish
run: deno run --allow-all jsr:@libs/bundle/ts/cli/publish deno.jsonc --loglevel debug --x.repository '${{ github.repository }}' --x.token '${{ secrets.GH_TOKEN }}' --x.version "$(date '+%Y.%m.%d')" --x.map deno.jsonc --x.reactive --x.remove