Skip to content

Commit

Permalink
ci: add freebsd actions (#120)
Browse files Browse the repository at this point in the history
* ci: add freebsd actions

* freebsd

* fix cross

* no number

* clang

* pkg-config

* cargo

* 13

* static

* very static

* remove static

* toolchain

* sysroot

* freebsd no mp3

* build inside vm

* rustup

* env

* git

* zip tar untar

* no tar

* ninja cmake

* pkgconf

* bash

* nasm

* python3

* lang python

* log

* symlink

* python3

* python3.11

* python3.11

* config mak

* remove cross

* gmake

* make

* postgres

* postgres

* sudo

* no ln

* ln

* llvm16

* sshfs

* safe directory

* git commit hash

* llvm

* postgres server

* postgres

* postgres

* service

* one

* full

* matrix

* update readme

* move to run

* no-test

* remove target

* coverage

* remove postgres client
  • Loading branch information
vnghia authored Apr 17, 2024
1 parent 8287489 commit 3b44b00
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ PKG_CONFIG_PATH_aarch64-unknown-linux-gnu = { value = "target/vcpkg/installed/ar
PKG_CONFIG_PATH_x86_64-unknown-linux-musl = { value = "target/vcpkg/installed/x64-linux-musl-release/lib/pkgconfig", relative = true }
PKG_CONFIG_PATH_aarch64-unknown-linux-musl = { value = "target/vcpkg/installed/arm64-linux-musl-release/lib/pkgconfig", relative = true }

PKG_CONFIG_PATH_x86_64-unknown-freebsd = { value = "target/vcpkg/installed/x64-freebsd-release/lib/pkgconfig", relative = true }

PKG_CONFIG_PATH_x86_64-apple-darwin = { value = "target/vcpkg/installed/x64-osx-release/lib/pkgconfig", relative = true }
PKG_CONFIG_PATH_aarch64-apple-darwin = { value = "target/vcpkg/installed/arm64-osx-release/lib/pkgconfig", relative = true }

Expand Down
65 changes: 63 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,66 @@ jobs:
push: true
tags: ${{ steps.meta-musl.outputs.tags }}

build-freebsd:
runs-on: ubuntu-latest
env:
TARGET: x86_64-unknown-freebsd

steps:
- uses: actions/checkout@v4
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Extract build information
id: build
run: |
echo "env=${TARGET##*-}" >> "$GITHUB_OUTPUT"
echo "target=${TARGET}" >> "$GITHUB_OUTPUT"
echo "profile=${{ (github.event_name == 'release' || github.event_name == 'workflow_dispatch') && 'release' || 'dev' }}" >> "$GITHUB_OUTPUT"
echo "output-dir=${{ (github.event_name == 'release' || github.event_name == 'workflow_dispatch') && 'release' || 'debug' }}" >> "$GITHUB_OUTPUT"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ steps.build.outputs.target }}-${{ steps.build.outputs.profile }}
save-if: ${{ github.ref == 'refs/heads/main' }}

- name: Build and test
uses: vmactions/freebsd-vm@v1
with:
envs: "DATABASE_URL ACTIONS_CACHE_URL ACTIONS_RUNTIME_TOKEN"
usesh: true
prepare: |
set -euxo pipefail
pkg install -y git curl zip unzip cmake ninja pkgconf bash python311 nasm gmake llvm16
rm -rf /usr/bin/make
ln -s /usr/local/bin/gmake /usr/bin/make
make --version
ln -s /usr/local/bin/python3.11 /usr/local/bin/python3
python3 --version
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
run: |
set -euxo pipefail
. "$HOME/.cargo/env"
cargo install cargo-vcpkg
cargo vcpkg --verbose build --target ${{ steps.build.outputs.target }}
cargo build --locked --target ${{ steps.build.outputs.target }} --profile ${{ steps.build.outputs.profile }}
mv ${{ github.workspace }}/target/${{ steps.build.outputs.target }}/${{ steps.build.outputs.output-dir }}/nghe ${{ github.workspace }}/nghe
rm -rf target
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: amd64-${{ steps.build.outputs.env }}
path: ${{ github.workspace }}/nghe
retention-days: 1

build-windows:
runs-on: windows-latest

Expand Down Expand Up @@ -381,7 +441,8 @@ jobs:

upload-release:
runs-on: ubuntu-latest
needs: [build-frontend, build-linux, build-windows, build-macos]
needs:
[build-frontend, build-linux, build-freebsd, build-windows, build-macos]
if: ${{ github.event_name == 'release' }}
permissions:
contents: write
Expand All @@ -397,4 +458,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
find artifact/ -mindepth 1 -maxdepth 1 -type d -exec zip -r --move --test {}.zip {} \;
gh release upload ${{ github.ref_name }} artifact/amd64-gnu.zip artifact/arm64-gnu.zip artifact/amd64-musl.zip artifact/arm64-musl.zip artifact/amd64-darwin.zip artifact/arm64-darwin.zip artifact/amd64-windows.zip artifact/frontend.zip
gh release upload ${{ github.ref_name }} artifact/amd64-gnu.zip artifact/arm64-gnu.zip artifact/amd64-musl.zip artifact/arm64-musl.zip artifact/amd64-freebsd.zip artifact/amd64-darwin.zip artifact/arm64-darwin.zip artifact/amd64-windows.zip artifact/frontend.zip
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ aarch64-unknown-linux-gnu = { triplet = "arm64-linux-release" }
x86_64-unknown-linux-musl = { triplet = "x64-linux-musl-release" }
aarch64-unknown-linux-musl = { triplet = "arm64-linux-musl-release" }

x86_64-unknown-freebsd = { triplet = "x64-freebsd-release" }

x86_64-apple-darwin = { triplet = "x64-osx-release" }
aarch64-apple-darwin = { triplet = "arm64-osx-release" }

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ An implementation of OpenSubsonic API in Rust
- All tags are multiple by default (artists, album artists, languages, etc).
- Well-tested and highly customizable.
- Well-defined permission model with music folders.
- Multi-platform, runs on macOS, Linux and Windows. Docker images are also provided.
- Multi-platform, runs on Linux, FreeBSD, MacOS and Windows. Docker images with two variants GNU or MUSL are also provided.
- Bridging with `ffmpeg c api` for in-memory transcoding and smooth stream experience. Most common formats (opus, mp3, acc, wav, etc) are supported. Does not required any manual configuration beforehand, just `maxBitRate` and `format` in the request parameters are enough.
- Synchoronized lyrics from external `lrc` files.

Expand Down
16 changes: 10 additions & 6 deletions types/src/common/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

const fn git_commit_hash_short() -> &'static str {
if built_info::GIT_COMMIT_HASH_SHORT.is_some() {
built_info::GIT_COMMIT_HASH_SHORT.unwrap()
} else {
"0"
}
}

pub const OPEN_SUBSONIC_VERSION: &str = "1.16.1";
pub const SERVER_NAME: &str = "nghe";
pub const SERVER_VERSION: &str = constcat::concat!(
built_info::PKG_VERSION,
" (",
built_info::GIT_COMMIT_HASH_SHORT.unwrap(),
")"
);
pub const SERVER_VERSION: &str =
constcat::concat!(built_info::PKG_VERSION, " (", git_commit_hash_short(), ")");
6 changes: 6 additions & 0 deletions vcpkg/triplets/x64-freebsd-release.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set(VCPKG_TARGET_ARCHITECTURE "x64")
set(VCPKG_CRT_LINKAGE "dynamic")
set(VCPKG_LIBRARY_LINKAGE "static")
set(VCPKG_BUILD_TYPE "release")

set(VCPKG_CMAKE_SYSTEM_NAME "FreeBSD")

0 comments on commit 3b44b00

Please sign in to comment.