-
Notifications
You must be signed in to change notification settings - Fork 3
139 lines (123 loc) · 4.14 KB
/
deploy.yml
File metadata and controls
139 lines (123 loc) · 4.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
130
131
132
133
134
135
136
137
138
139
name: Deploy
on:
push:
branches:
- main
workflow_dispatch:
jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
source: ${{ steps.filter.outputs.source }}
timestamp: ${{ steps.timestamp.outputs.value }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Detect source changes
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
source:
- 'crates/**'
- 'lua/**'
- 'Cargo.toml'
- 'Cargo.lock'
- name: Generate build timestamp
id: timestamp
run: echo "value=$(date -u '+%Y-%m-%d %H:%M UTC')" >> "$GITHUB_OUTPUT"
build:
name: Build (${{ matrix.name }})
needs: changes
if: needs.changes.outputs.source == 'true'
strategy:
matrix:
include:
- name: linux-x86_64
target: x86_64-unknown-linux-gnu
- name: linux-aarch64
target: aarch64-unknown-linux-gnu
- name: macos-aarch64
target: aarch64-apple-darwin
- name: macos-x86_64
target: x86_64-apple-darwin
runs-on: ${{ contains(matrix.target, 'apple') && 'macos-latest' || 'ubuntu-latest' }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-${{ matrix.target }}-${{ hashFiles('Cargo.lock') }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CXX_aarch64_unknown_linux_gnu: aarch64-linux-gnu-g++
RB_BUILD_TIMESTAMP: ${{ needs.changes.outputs.timestamp }}
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: rb-${{ matrix.name }}
path: target/${{ matrix.target }}/release/rb
deploy:
name: Deploy
needs: [changes, build]
if: always() && !failure() && !cancelled()
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install mise
uses: jdx/mise-action@v2
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build site
run: pnpm build
- name: Download artifacts
if: needs.changes.outputs.source == 'true'
uses: actions/download-artifact@v6
with:
path: artifacts
- name: Package nightly binaries
if: needs.changes.outputs.source == 'true'
run: |
mkdir -p .vitepress/dist/nightly
for name in linux-x86_64 linux-aarch64 macos-aarch64 macos-x86_64; do
(cd "artifacts/rb-${name}" && zip "../../.vitepress/dist/nightly/rb-${name}.zip" rb)
done
echo '${{ needs.changes.outputs.timestamp }}' > .vitepress/dist/nightly/version.txt
- name: Preserve existing nightly binaries
if: needs.changes.outputs.source != 'true'
run: |
mkdir -p .vitepress/dist/nightly
for name in linux-x86_64 linux-aarch64 macos-aarch64 macos-x86_64; do
curl -fsSL "https://rootbeer.tale.me/nightly/rb-${name}.zip" \
-o ".vitepress/dist/nightly/rb-${name}.zip" || true
done
curl -fsSL "https://rootbeer.tale.me/nightly/version.txt" \
-o ".vitepress/dist/nightly/version.txt" || true
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: .vitepress/dist
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4