Skip to content

Commit

Permalink
ci: linux build
Browse files Browse the repository at this point in the history
  • Loading branch information
oomeow committed Oct 31, 2024
1 parent 5ff2034 commit e716298
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 16 deletions.
76 changes: 62 additions & 14 deletions .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ jobs:
with:
node-version: "20"

- uses: pnpm/action-setup@v3
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false

- name: Pnpm install and check
Expand Down Expand Up @@ -94,26 +93,75 @@ jobs:
target: x86_64-unknown-linux-gnu
- os: ubuntu-22.04
target: i686-unknown-linux-gnu
# TODO: arm install packages failed
# - os: ubuntu-22.04
# target: aarch64-unknown-linux-gnu
# - os: ubuntu-22.04
# target: armv7-unknown-linux-gnueabihf
- os: ubuntu-22.04
target: aarch64-unknown-linux-gnu
- os: ubuntu-22.04
target: armv7-unknown-linux-gnueabihf
outputs:
VERSION: ${{ steps.get_version.outputs.VERSION }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Build for Linux
uses: ./.github/build-for-linux
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
- name: Install Rust Stable
uses: dtolnay/rust-toolchain@stable

- name: Add Rust Target
run: rustup target add ${{ matrix.target }}

- name: Rust Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2
with:
target: ${{ matrix.target }}
alpha: true
workspaces: src-tauri

- name: Install Packages (x86_64)
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: Install Binstall
if: matrix.target != 'x86_64-unknown-linux-gnu'
uses: cargo-bins/cargo-binstall@main

- name: Install Cross
if: matrix.target != 'x86_64-unknown-linux-gnu'
run: cargo binstall -y cross

- name: Install Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
with:
node-version: "20"

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false

- name: Pnpm install and check
run: |
pnpm i
pnpm check ${{ matrix.target }} --alpha
- name: Tauri build (x86_64)
if: startsWith(matrix.target, 'x86_64')
run: |
pnpm build --target ${{ matrix.target }}
- name: Tauri build (other)
if: matrix.target != 'x86_64-unknown-linux-gnu'
run: |
pnpm build -r cross --target ${{ matrix.target }} -b "deb,rpm"
# - name: Build for Linux
# uses: ./.github/build-for-linux
# env:
# TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
# TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
# with:
# target: ${{ matrix.target }}
# alpha: true

- name: Get Version
id: get_version
Expand Down
37 changes: 37 additions & 0 deletions cross_dockerfile/debian/i686/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM debian:trixie

RUN rm -f /etc/apt/sources.list.d/debian.sources && \
rm -f /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian/ trixie main contrib non-free non-free-firmware" | tee -a /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian/ trixie-updates main contrib non-free non-free-firmware" | tee -a /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian/ trixie-backports main contrib non-free non-free-firmware" | tee -a /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian-security/ trixie-security main contrib non-free non-free-firmware" | tee -a /etc/apt/sources.list

RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
gnupg \
build-essential \
pkg-config && \
rm -rf /var/lib/apt/lists/*

RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y --no-install-recommends \
gcc-multilib \
g++-multilib \
libgtk-3-dev:i386 \
libwebkit2gtk-4.1-dev:i386 \
libappindicator3-dev:i386 \
librsvg2-dev:i386 \
patchelf:i386 && \
rm -rf /var/lib/apt/lists/*

# Install Rust
RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable --profile minimal
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup target add i686-unknown-linux-gnu
ENV PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig:$PKG_CONFIG_PATH

WORKDIR /app
39 changes: 39 additions & 0 deletions cross_dockerfile/ubuntu/aarch64/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM ubuntu:22.04

# change the sources list and install dependencies
RUN rm -f /etc/apt/sources.list && \
echo "deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy main multiverse universe restricted" | tee -a /etc/apt/sources.list && \
echo "deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy-security main multiverse universe restricted" | tee -a /etc/apt/sources.list && \
echo "deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy-updates main multiverse universe restricted" | tee -a /etc/apt/sources.list && \
echo "deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy-backports main multiverse universe restricted" | tee -a /etc/apt/sources.list && \
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main multiverse universe restricted" | tee -a /etc/apt/sources.list && \
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main multiverse universe restricted" | tee -a /etc/apt/sources.list && \
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main multiverse universe restricted" | tee -a /etc/apt/sources.list && \
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main multiverse universe restricted" | tee -a /etc/apt/sources.list
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates curl wget gnupg build-essential pkg-config tar xz-utils && \
rm -rf /var/lib/apt/lists/*

RUN dpkg --add-architecture arm64 && \
apt-get update && \
apt-get autoremove -y && \
apt-get install -y --no-install-recommends \
g++-aarch64-linux-gnu \
libc6-dev-arm64-cross \
libgtk-3-dev:arm64 \
libwebkit2gtk-4.1-dev:arm64 \
libappindicator3-dev:arm64 \
librsvg2-dev:arm64 \
patchelf:arm64

# Install Rust
RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable --profile minimal
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup target add aarch64-unknown-linux-gnu
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \
CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ \
PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH \
PKG_CONFIG_ALLOW_CROSS=1

WORKDIR /app
39 changes: 39 additions & 0 deletions cross_dockerfile/ubuntu/armhf/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM ubuntu:22.04

# change the sources list and install dependencies
RUN rm -f /etc/apt/sources.list && \
echo "deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy main multiverse universe restricted" | tee -a /etc/apt/sources.list && \
echo "deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy-security main multiverse universe restricted" | tee -a /etc/apt/sources.list && \
echo "deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy-updates main multiverse universe restricted" | tee -a /etc/apt/sources.list && \
echo "deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy-backports main multiverse universe restricted" | tee -a /etc/apt/sources.list && \
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main multiverse universe restricted" | tee -a /etc/apt/sources.list && \
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main multiverse universe restricted" | tee -a /etc/apt/sources.list && \
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main multiverse universe restricted" | tee -a /etc/apt/sources.list && \
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main multiverse universe restricted" | tee -a /etc/apt/sources.list
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates curl wget gnupg build-essential pkg-config tar xz-utils && \
rm -rf /var/lib/apt/lists/*

RUN dpkg --add-architecture armhf && \
apt-get update && \
apt-get autoremove -y && \
apt-get install -y --no-install-recommends \
g++-arm-linux-gnueabihf \
libc6-dev-armhf-cross \
libgtk-3-dev:armhf \
libwebkit2gtk-4.1-dev:armhf \
libappindicator3-dev:armhf \
librsvg2-dev:armhf \
patchelf:armhf

# Install Rust
RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable --profile minimal
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup target add armv7-unknown-linux-gnueabihf
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \
CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \
CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ \
PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig:$PKG_CONFIG_PATH \
PKG_CONFIG_ALLOW_CROSS=1

WORKDIR /app
8 changes: 8 additions & 0 deletions src-tauri/Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[target.i686-unknown-linux-gnu]
dockerfile = "../cross_dockerfile/debian/i686/Dockerfile"

[target.aarch64-unknown-linux-gnu]
dockerfile = "../cross_dockerfile/ubuntu/aarch64/Dockerfile"

[target.armv7-unknown-linux-gnueabihf]
dockerfile = "../cross_dockerfile/ubuntu/armhf/Dockerfile"
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"build": {
"beforeBuildCommand": "pnpm run web:build",
"frontendDist": "../dist",
"frontendDist": "./frontend/dist",
"beforeDevCommand": "pnpm run web:dev",
"devUrl": "http://localhost:3000/"
},
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default defineConfig({
!!process.env.TAURI_ENV_DEBUG && devtools(),
],
build: {
outDir: "../dist",
outDir: "../src-tauri/frontend/dist",
emptyOutDir: true,
rollupOptions: {
input: {
Expand Down

0 comments on commit e716298

Please sign in to comment.