Repository navigation
129 lines (124 loc) · 5.14 KB
/
Copy pathwww.yml
File metadata and controls
129 lines (124 loc) · 5.14 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
name: www
# The public page in www/ is the Rune app in www/app. CI builds it to wasm, has the native build write its static
# HTML (`--html`), and deploys: dev to https://dev.anoma.ly/rune, production to https://anoma.ly/rune. Rune itself is
# the page, so a push that changes crates/ deploys it too. Pull requests build the dev page and deploy nothing, and
# only for a change to the page's own files: a change to crates/ merges straight after its pull request, and the
# push to dev builds it then, so building it twice told nothing. A newer push to dev replaces a dev deploy still
# running; production always finishes.
on:
push:
branches: [dev, production]
paths:
- "www/**"
- "crates/**"
- "scripts/web-build.sh"
- "Cargo.toml"
- "Cargo.lock"
- "rust-toolchain.toml"
- ".github/workflows/www.yml"
pull_request:
paths:
- "www/**"
- "scripts/web-build.sh"
- "rust-toolchain.toml"
- ".github/workflows/www.yml"
concurrency:
group: www-${{ github.head_ref || github.ref_name }}
cancel-in-progress: ${{ github.ref_name != 'production' }}
permissions:
contents: read
env:
BINARYEN_VERSION: "133"
MODE: ${{ github.ref_name == 'production' && 'production' || 'dev' }}
CARGO_INCREMENTAL: "0"
jobs:
build:
runs-on: ubuntu-latest
environment: ${{ github.ref_name == 'dev' && 'dev' || 'release' }}
permissions:
id-token: write
contents: read
defaults:
run:
working-directory: www
steps:
- uses: actions/checkout@v5
# Pull requests build and deploy nothing, so they never assume the role.
- name: Configure AWS credentials
if: github.event_name == 'push'
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: arn:aws:iam::604439173067:role/github/rune-${{ github.ref_name == 'dev' && 'dev' || 'release' }}
role-session-name: www-${{ github.run_id }}
aws-region: us-east-1
# rust-toolchain.toml picks the toolchain. rust-src is installed up front: otherwise rustup fetches it mid-build
# from parallel rustc calls, which race and fail.
- name: Rust toolchain
working-directory: .
run: |
rustup toolchain install
rustup target add wasm32-unknown-unknown
rustup component add rust-src
- uses: Swatinem/rust-cache@v2
with:
shared-key: www
save-if: ${{ github.event_name == 'push' }}
- name: wasm-bindgen version from Cargo.lock
id: bindgen
working-directory: .
run: echo "version=$(grep -A1 '^name = "wasm-bindgen"$' Cargo.lock | sed -n 's/^version = "\(.*\)"/\1/p')" >> "$GITHUB_OUTPUT"
- uses: taiki-e/install-action@v2
with:
tool: wasm-bindgen@${{ steps.bindgen.outputs.version }}
- uses: actions/cache@v4
id: binaryen
with:
path: ~/.binaryen
key: binaryen-${{ env.BINARYEN_VERSION }}
- name: Install binaryen
if: steps.binaryen.outputs.cache-hit != 'true'
run: |
mkdir -p ~/.binaryen
curl -fsSL "https://github.com/WebAssembly/binaryen/releases/download/version_$BINARYEN_VERSION/binaryen-version_$BINARYEN_VERSION-x86_64-linux.tar.gz" \
| tar -xz -C ~/.binaryen --strip-components=1
- run: echo "$HOME/.binaryen/bin" >> "$GITHUB_PATH"
- uses: oven-sh/setup-bun@v2
- run: bun install --frozen-lockfile
# The native app (tests and the `--html` export) links winit's keyboard library. Its packages are cached, so a
# run doesn't need the Ubuntu mirrors (on 2026-11-11 the runners couldn't resolve them for over an hour, and
# every run failed here); a run that must fetch them retries.
- uses: actions/cache@v4
id: debs
with:
path: ~/.debs
key: debs-libxkbcommon-${{ runner.os }}-${{ runner.arch }}-${{ env.ImageOS }}
- name: Native libraries
run: |
if [ "${{ steps.debs.outputs.cache-hit }}" != true ]; then
mkdir -p ~/.debs
for attempt in 1 2 3; do
sudo apt-get -o Acquire::Retries=3 update &&
(cd ~/.debs && apt-get -o Acquire::Retries=3 download libxkbcommon-dev libxkbcommon0) && break
[ "$attempt" = 3 ] && exit 1
sleep $((attempt * 20))
done
fi
sudo dpkg -i ~/.debs/*.deb
- name: Test the page
working-directory: .
run: cargo test -p rune-www
- name: Build
run: bun run build --mode "$MODE"
- name: Cloudflare token
id: cloudflare-token
if: github.event_name == 'push'
run: bash "$GITHUB_WORKSPACE/.github/release/cloudflare-token.sh"
env:
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
- name: Deploy
if: github.event_name == 'push'
run: bunx cf deploy --prebuilt --mode "$MODE"
env:
CLOUDFLARE_API_TOKEN: ${{ steps.cloudflare-token.outputs.token }}
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}