Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Commit

Permalink
Move to action-rs/toolchain for linux builds
Browse files Browse the repository at this point in the history
Rather than relying on static Docker images for building Linux
binaries, we now use action-rs/toolchain. This makes for much better
upgrade of Rust, without having to rebuild and redeploy images.

Before, deb packages were built with musl as static binaries, but since
musl on arm7 is involved, both debian packages are now dynamicly linked.
The amd64 static binary is built with musl and is statically linked.
  • Loading branch information
Wouter de Bie committed Aug 23, 2021
1 parent e689218 commit 1d45749
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 47 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
strip = { path = "arm-linux-gnueabihf-strip" }
110 changes: 68 additions & 42 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,95 @@ jobs:
runs-on: ubuntu-latest
name: Build .deb (amd64)
steps:
- name: Install musl tools
run: |
sudo apt-get update
sudo apt-get install liblzma-dev
- uses: actions/checkout@v2
- uses: actions/cache@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-amd64deb-${{ hashFiles('**/Cargo.lock') }}
toolchain: stable
profile: minimal
- uses: Swatinem/rust-cache@v1
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Run cargo deb
uses: actions-rs/cargo@v1
id: debbuild
uses: wouterdebie/cargo-deb-amd64-ubuntu@1.2
with:
command: deb
- name: Upload Deb Artifact
uses: actions/upload-artifact@v2
with:
name: amd64deb
path: ./target/x86_64-unknown-linux-musl/debian/*
path: ./target/debian/*

raspbianbuild:
runs-on: ubuntu-latest
name: Build .deb (arm7)
steps:
- name: Install musl and armhf packages
run: |
sudo sed -i s/^deb/deb\ [arch=amd64]/g /etc/apt/sources.list
sudo dpkg --add-architecture armhf
sudo bash -c 'echo "deb [arch=armhf] http://ports.ubuntu.com/ focal main universe" >> /etc/apt/sources.list'
sudo apt-get update
sudo apt-get install musl-dev musl-tools liblzma-dev \
libc6-armhf-cross libc6-dev-armhf-cross \
gcc-arm-linux-gnueabihf
- uses: actions/checkout@v2
- uses: actions/cache@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-arm7deb-${{ hashFiles('**/Cargo.lock') }}
toolchain: stable
profile: minimal
target: armv7-unknown-linux-gnueabihf
- uses: Swatinem/rust-cache@v1
- name: Install cargo-deb and cross
run: cargo install cargo-deb cross
- name: Run cargo deb
uses: actions-rs/cargo@v1
id: debbuild
uses: wouterdebie/cargo-deb-armv7-debian@1.1
with:
command: deb
args: --target armv7-unknown-linux-gnueabihf
- name: Upload Deb Artifact
uses: actions/upload-artifact@v2
with:
name: armv7deb
path: ./target/armv7-unknown-linux-musleabihf/debian/*
path: ./target/armv7-unknown-linux-gnueabihf/debian/*

amd64binaries:
runs-on: ubuntu-latest
name: Build amd64 static binary
steps:
- name: Install musl tools
run: |
sudo apt-get update
sudo apt-get install musl-dev musl-tools
- uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
target: x86_64-unknown-linux-musl
- uses: Swatinem/rust-cache@v1
- name: Build static
uses: actions-rs/cargo@v1
id: amd64staticbuild
with:
command: build
args: --release --target=x86_64-unknown-linux-musl
- name: Strip binary
run: |
strip ./target/x86_64-unknown-linux-musl/release/locast2tuner -o locast2tuner
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: amd64binaries
path: locast2tuner

upload_ppa:
if: startsWith(github.ref, 'refs/tags/')
Expand Down Expand Up @@ -94,32 +146,6 @@ jobs:
repository: wouterdebie/wouterdebie.github.io
branch: main

amd64binaries:
runs-on: ubuntu-latest
name: Build amd64 static binary
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-amd64-${{ hashFiles('**/Cargo.lock') }}
- name: Build static
id: amd64staticbuild
uses: wouterdebie/cargo-deb-amd64-ubuntu@1.2
with:
cmd: cargo build --release --target=x86_64-unknown-linux-musl
- name: Strip binary
run: |
strip ./target/x86_64-unknown-linux-musl/release/locast2tuner -o locast2tuner
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: amd64binaries
path: locast2tuner

linuxamd64dockerbuild:
needs: [amd64binaries]
runs-on: ubuntu-latest
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ copyright = "2021, Wouter de Bie <wouter@evenflow.nl>"
license-file = ["LICENSE", "0"]
extended-description = """\
Locast.org to Plex Media Server/Emby integration server"""
depends = "$auto"
depends = ""
section = "utility"
priority = "optional"
assets = [
Expand Down Expand Up @@ -76,10 +76,10 @@ slog-syslog = "0.12.0"
[build-dependencies]
rustc_version = "0.4.0"

[profile.release]
panic = "abort"
debug = false
lto = true
# [profile.release]
# panic = "abort"
# debug = false
# lto = true

[dev-dependencies]
cargo-bump = "1.1.0"
Expand Down

0 comments on commit 1d45749

Please sign in to comment.