Repository navigation
144 lines (136 loc) · 5.01 KB
/
Copy pathci.yml
File metadata and controls
144 lines (136 loc) · 5.01 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: CI
on:
pull_request:
push:
branches: [main]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14
- uses: actions/cache@v6
with:
path: ~/.bun/install/cache
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
- run: bun install --frozen-lockfile
- run: bun run typecheck
# The npm package's dist/: the compiled plugin, the wallpaper API and its declarations.
- run: bun run build
# Lists the registered wallpapers, so the jobs below run one per wallpaper in parallel and pick up new ones.
wallpapers:
runs-on: ubuntu-latest
outputs:
ids: ${{ steps.list.outputs.ids }}
steps:
- uses: actions/checkout@v7
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14
- id: list
run: echo "ids=$(bun -e 'import { WALLPAPERS } from "./wallpapers"; console.log(JSON.stringify(WALLPAPERS.map((w) => w.id)))')" >> "$GITHUB_OUTPUT"
check:
needs: wallpapers
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
wallpaper: ${{ fromJSON(needs.wallpapers.outputs.ids) }}
steps:
- uses: actions/checkout@v7
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14
- uses: actions/cache@v6
with:
path: ~/.bun/install/cache
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
- run: bun install --frozen-lockfile
# Fails on errors and flicker; the frame budget is generous because CI machines are slower and noisier.
- run: bun dev/check.ts --quiet --max-ms=60 ${{ matrix.wallpaper }}
screenshots:
needs: wallpapers
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
wallpaper: ${{ fromJSON(needs.wallpapers.outputs.ids) }}
steps:
- uses: actions/checkout@v7
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14
- uses: actions/cache@v6
with:
path: ~/.bun/install/cache
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
- run: bun install --frozen-lockfile
# Compares fresh renders with the published ones on the assets branch. A changed scene only warns: its renders
# are uploaded for review, and the publish job below puts them on the assets branch once the change is on main.
- id: compare
continue-on-error: true
run: bun dev/screenshots.ts ${{ matrix.wallpaper }}
- if: steps.compare.outcome == 'failure'
run: echo "::warning title=Screenshots changed::${{ matrix.wallpaper }} renders differently from the README; they publish automatically once on main. See the fresh-screenshots-${{ matrix.wallpaper }} artifact."
- if: steps.compare.outcome == 'failure'
uses: actions/upload-artifact@v7
with:
name: fresh-screenshots-${{ matrix.wallpaper }}
path: dev/out/screenshots/
# Commits the changed screenshots to the assets branch, which the README's images point at.
publish:
needs: screenshots
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
with:
ref: assets
- uses: actions/download-artifact@v8
with:
pattern: fresh-screenshots-*
merge-multiple: true
- run: |
git add -A
git diff --cached --quiet && exit 0
git -c user.name="github-actions[bot]" -c user.email="41898273+github-actions[bot]@users.noreply.github.com" commit -m "Update screenshots for ${GITHUB_SHA::7}"
git push
# Updates the release branch that `opencode plugin add vaprdev/opencode-wallpapers#release` installs: the built plugin
# with a package.json that has no build scripts, so installing doesn't build it, and no sources, dev tools or images.
release:
needs: [build, check]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v7
with:
ref: release
path: release
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14
- uses: actions/cache@v6
with:
path: ~/.bun/install/cache
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
- run: bun install --frozen-lockfile
- run: bun run build
- working-directory: release
run: |
git rm -rq --ignore-unmatch .
cp -R ../dist ../README.md ../LICENSE ../CHANGELOG.md .
jq 'del(.scripts, .devDependencies)' ../package.json > package.json
git add -A
git diff --cached --quiet && exit 0
git -c user.name="github-actions[bot]" -c user.email="41898273+github-actions[bot]@users.noreply.github.com" commit -m "Release ${GITHUB_SHA::7}"
git push