-
-
Notifications
You must be signed in to change notification settings - Fork 5
159 lines (132 loc) · 4.28 KB
/
Copy pathbuild.yml
File metadata and controls
159 lines (132 loc) · 4.28 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Build and Package
on:
push:
branches:
- main
jobs:
build-and-package:
name: Build and Package
strategy:
matrix:
include:
- arch: amd64
runner: ubuntu-24.04
target: x86_64-unknown-linux-musl
cross: false
- arch: arm64
runner: ubuntu-24.04
target: aarch64-unknown-linux-musl
cross: true
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 10
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install frontend dependencies
run: |
cd ./frontend
pnpm install
- name: Build frontend
run: |
cd ./frontend
pnpm build
- name: Install stable Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y musl-tools pkg-config libssl-dev
- name: Install Sentry CLI
run: |
npm install -g @sentry/cli
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: ${{ runner.os }}-${{ matrix.target }}
- name: Build release binary
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
command: build
args: --release --target ${{ matrix.target }}
- name: Process release binary
run: |
sentry-cli --url ${{ secrets.SENTRY_URL }} debug-files upload --include-sources --org ${{ secrets.SENTRY_ORG }} --project ${{ secrets.SENTRY_PROJECT }} --auth-token ${{ secrets.SENTRY_AUTH_TOKEN }} target/${{ matrix.target }}/release/api
mkdir -p dist/${{ matrix.arch }}
cp target/${{ matrix.target }}/release/api dist/${{ matrix.arch }}/api
- name: Strip release binary (x86_64 only)
if: matrix.arch == 'amd64'
run: |
strip dist/${{ matrix.arch }}/api
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: api-${{ matrix.arch }}
path: dist/${{ matrix.arch }}/api
retention-days: 1
create-multiarch-image:
name: Create multi-arch Docker image
needs: build-and-package
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all binary artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare binaries
run: |
chmod +x dist/api-amd64/api
chmod +x dist/api-arm64/api
mkdir -p .docker/amd64 .docker/arm64
cp dist/api-amd64/api .docker/amd64/api
cp dist/api-arm64/api .docker/arm64/api
cp entrypoint.sh .docker/
- name: Build and push multi-arch Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/mcjars/www:latest
cache-from: type=gha
cache-to: type=gha,mode=max