refactor(music-folder): move music folder related endpoint to another… #737
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Main | |
permissions: | |
contents: read | |
packages: write | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
release: | |
types: [published] | |
workflow_dispatch: | |
env: | |
CARGO_TERM_COLOR: always | |
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" | |
RUST_TOOLCHAIN: nightly-2024-03-22 | |
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/postgres" | |
jobs: | |
build-frontend: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.RUST_TOOLCHAIN }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "npm" | |
cache-dependency-path: ${{ github.workspace }}/frontend/package-lock.json | |
- name: Build tailwindcss | |
working-directory: ${{ github.workspace }}/frontend | |
run: | | |
npm ci | |
npm run build | |
- name: Install dioxus-cli | |
uses: taiki-e/cache-cargo-install-action@v1 | |
with: | |
tool: dioxus-cli | |
- name: Build frontend | |
run: | | |
dx build --verbose --profile ${{ (github.event_name == 'release' || github.event_name == 'workflow_dispatch') && 'release' || 'dev' }} | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: frontend | |
path: ${{ github.workspace }}/frontend/dist/ | |
retention-days: 1 | |
build-linux: | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- target: x86_64-unknown-linux-gnu | |
command: cargo | |
- target: aarch64-unknown-linux-gnu | |
command: cross | |
- target: x86_64-unknown-linux-musl | |
command: cross | |
- target: aarch64-unknown-linux-musl | |
command: cross | |
runs-on: ubuntu-latest | |
env: | |
CROSS_CONTAINER_OPTS: "--network=host" | |
services: | |
postgres: | |
image: postgres:16 | |
env: | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_HOST_AUTH_METHOD: md5 | |
POSTGRES_INITDB_ARGS: --auth-host=md5 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
--name postgres | |
ports: | |
- 5432:5432 | |
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 || ''); | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.RUST_TOOLCHAIN }} | |
- name: Extract build information | |
id: build | |
env: | |
TARGET: ${{ matrix.platform.target }} | |
run: | | |
echo "env=${TARGET##*-}" >> "$GITHUB_OUTPUT" | |
echo "arch=$(echo $TARGET | awk '{print $1}')" >> "$GITHUB_OUTPUT" | |
echo "docker-arch=${{ startsWith(matrix.platform.target, 'x86_64') && 'amd64' || 'arm64' }}" >> "$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: Swatinem/rust-cache@v2 | |
with: | |
key: ${{ matrix.platform.target }}-${{ steps.build.outputs.profile }} | |
save-if: ${{ github.ref == 'refs/heads/main' }} | |
- name: Increase postgres max connection | |
run: | | |
docker exec -i postgres bash << EOF | |
sed -i -e 's/max_connections = 100/max_connections = 1000/' /var/lib/postgresql/data/postgresql.conf | |
sed -i -e 's/shared_buffers = 128MB/shared_buffers = 2GB/' /var/lib/postgresql/data/postgresql.conf | |
EOF | |
docker restart postgres | |
- name: Setup arm64 environment | |
run: | | |
sudo apt install --assume-yes gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
sudo ln -s ${{ github.workspace }}/vcpkg/cross-pkg-config /usr/bin/aarch64-linux-gnu-pkg-config | |
aarch64-linux-gnu-pkg-config --version | |
if: ${{ matrix.platform.target == 'aarch64-unknown-linux-gnu' }} | |
- name: Setup x64 musl environment | |
run: | | |
sudo apt install --assume-yes musl-tools | |
sudo ln -s ${{ github.workspace }}/vcpkg/cross-pkg-config /usr/bin/x86_64-linux-musl-pkg-config | |
x86_64-linux-musl-pkg-config --version | |
if: ${{ matrix.platform.target == 'x86_64-unknown-linux-musl' }} | |
# TODO: Rename binary after https://github.com/microsoft/vcpkg/issues/36094 is fixed | |
- name: Setup arm64 musl environment | |
run: | | |
wget -c https://github.com/xmake-mirror/musl.cc/releases/download/20210202/aarch64-linux-musl-cross.linux.tgz -O - | tar -xz | |
sudo ln -s ${{ github.workspace }}/aarch64-linux-musl-cross/bin/aarch64-linux-musl-g++ /usr/bin/aarch64-linux-gnu-g++ | |
sudo ln -s ${{ github.workspace }}/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc /usr/bin/aarch64-linux-gnu-gcc | |
aarch64-linux-gnu-gcc --version | |
aarch64-linux-gnu-g++ --version | |
sudo ln -s ${{ github.workspace }}/vcpkg/cross-pkg-config /usr/bin/aarch64-linux-gnu-pkg-config | |
aarch64-linux-gnu-pkg-config --version | |
if: ${{ matrix.platform.target == 'aarch64-unknown-linux-musl' }} | |
- name: Install vcpkg build deps | |
run: sudo apt-get --assume-yes install nasm | |
- name: Install cargo-vcpkg | |
uses: taiki-e/cache-cargo-install-action@v1 | |
with: | |
tool: cargo-vcpkg | |
- name: Build vcpkg dependencies | |
run: | | |
cargo vcpkg --verbose build --target ${{ matrix.platform.target }} | |
- name: Install cross | |
if: ${{ matrix.platform.command == 'cross' }} | |
uses: taiki-e/cache-cargo-install-action@v1 | |
with: | |
tool: cross | |
git: https://github.com/cross-rs/cross | |
rev: 085092c | |
- name: Build and test | |
run: | | |
${{ matrix.platform.command }} build --locked --target ${{ matrix.platform.target }} --profile ${{ steps.build.outputs.profile }} | |
${{ matrix.platform.command }} test --locked --target ${{ matrix.platform.target }} --profile ${{ steps.build.outputs.profile }} -p nghe -p nghe-types | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.build.outputs.docker-arch }}-${{ steps.build.outputs.env }} | |
path: ${{ github.workspace }}/target/${{ matrix.platform.target }}/${{ steps.build.outputs.output-dir }}/nghe | |
retention-days: 1 | |
build-docker: | |
runs-on: ubuntu-latest | |
needs: [build-frontend, build-linux] | |
if: ${{ vars.BUILD_DOCKER != '' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download build artifact for docker | |
uses: actions/download-artifact@v4 | |
with: | |
path: ${{ github.workspace }}/artifact/ | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
# GNU | |
- name: Extract metadata for Docker gnu | |
id: meta-gnu | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
name=ghcr.io/${{ github.repository }}-gnu | |
tags: | | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=raw,value=develop,enable={{is_default_branch}} | |
- name: Build and push gnu | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ci/docker/Dockerfile | |
build-args: | | |
BASE_IMAGE=debian:12.5-slim | |
TARGET_ENV=gnu | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta-gnu.outputs.tags }} | |
# Musl | |
- name: Extract metadata for Docker musl | |
id: meta-musl | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
name=ghcr.io/${{ github.repository }}-musl | |
tags: | | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=raw,value=develop,enable={{is_default_branch}} | |
- name: Build and push musl | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ci/docker/Dockerfile | |
build-args: | | |
BASE_IMAGE=alpine:3.19.1 | |
TARGET_ENV=musl | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta-musl.outputs.tags }} | |
build-windows: | |
runs-on: windows-latest | |
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 || ''); | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.RUST_TOOLCHAIN }} | |
- name: Extract build information | |
id: build | |
run: | | |
echo "profile=${{ (github.event_name == 'release' || github.event_name == 'workflow_dispatch') && 'release' || 'dev' }}" >> $env:GITHUB_OUTPUT | |
echo "output-dir=${{ (github.event_name == 'release' || github.event_name == 'workflow_dispatch') && 'release' || 'debug' }}" >> $env:GITHUB_OUTPUT | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
key: x86_64-pc-windows-msvc-${{ steps.build.outputs.profile }} | |
save-if: ${{ github.ref == 'refs/heads/main' }} | |
- name: Install and setup postgres | |
run: | | |
curl https://get.enterprisedb.com/postgresql/postgresql-16.2-1-windows-x64-binaries.zip --output postgresql.zip | |
7z x postgresql.zip | |
$env:PGDATA = "$PWD\pgsql\data" | |
$env:PGPASSWORD = "postgres" | |
echo $env:PGPASSWORD > pwfile | |
pgsql\bin\initdb --username=postgres --encoding="UTF-8" --locale="en_US.UTF-8" --pwfile=pwfile | |
pgsql\bin\pg_ctl start | |
pgsql\bin\psql -U postgres -d postgres -c "ALTER SYSTEM SET max_connections = 1000" | |
pgsql\bin\psql -U postgres -d postgres -c "ALTER SYSTEM SET shared_buffers = '2GB'" | |
pgsql\bin\pg_ctl restart | |
echo "$PWD\pgsql\bin" >> $env:GITHUB_PATH | |
echo "$PWD\pgsql\lib" >> $env:GITHUB_PATH | |
echo "PQ_LIB_DIR=$PWD\pgsql\lib" >> $env:GITHUB_ENV | |
- name: Install cargo-vcpkg | |
uses: taiki-e/cache-cargo-install-action@v1 | |
with: | |
tool: cargo-vcpkg | |
- name: Build vcpkg dependencies | |
run: | | |
cargo vcpkg --verbose build --target x86_64-pc-windows-msvc | |
- name: Build and test | |
run: | | |
cargo build --locked --target x86_64-pc-windows-msvc --profile ${{ steps.build.outputs.profile }} | |
cargo test --locked --target x86_64-pc-windows-msvc --profile ${{ steps.build.outputs.profile }} -p nghe -p nghe-types | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: amd64-windows | |
path: ${{ github.workspace }}\target\x86_64-pc-windows-msvc\${{ steps.build.outputs.output-dir }}\nghe.exe | |
retention-days: 1 | |
build-macos: | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- target: x86_64-apple-darwin | |
os: macos-13 | |
vcpkg-target: x64-osx-release | |
- target: aarch64-apple-darwin | |
os: macos-14 | |
vcpkg-target: arm64-osx-release | |
runs-on: ${{ matrix.platform.os }} | |
env: | |
HOMEBREW_NO_AUTO_UPDATE: 1 | |
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 | |
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 || ''); | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.RUST_TOOLCHAIN }} | |
- name: Extract build information | |
id: build | |
env: | |
TARGET: ${{ matrix.platform.target }} | |
run: | | |
echo "env=${TARGET##*-}" >> "$GITHUB_OUTPUT" | |
echo "docker-arch=${{ startsWith(matrix.platform.target, 'x86_64') && 'amd64' || 'arm64' }}" >> "$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: Swatinem/rust-cache@v2 | |
with: | |
key: ${{ matrix.platform.target }}-${{ steps.build.outputs.profile }} | |
save-if: ${{ github.ref == 'refs/heads/main' }} | |
- name: Install and setup postgres | |
run: | | |
brew uninstall --force postgresql | |
brew uninstall --force postgresql@14 | |
brew install postgresql@16 | |
brew link postgresql@16 | |
export PGDATA="$RUNNER_TEMP/pgdata" | |
initdb --username=postgres --encoding="UTF-8" --locale="en_US.UTF-8" --pwfile=<(echo postgres) | |
pg_ctl start | |
psql -U postgres -d postgres -c "ALTER SYSTEM SET max_connections = 1000" | |
psql -U postgres -d postgres -c "ALTER SYSTEM SET shared_buffers = '2GB'" | |
pg_ctl restart | |
- name: Install vcpkg build deps | |
run: brew install nasm | |
- name: Install cargo-vcpkg | |
uses: taiki-e/cache-cargo-install-action@v1 | |
with: | |
tool: cargo-vcpkg | |
- name: Build vcpkg dependencies | |
run: | | |
cargo vcpkg --verbose build --target ${{ matrix.platform.target }} | |
- name: Build and test | |
run: | | |
cargo build --locked --target ${{ matrix.platform.target }} --profile ${{ steps.build.outputs.profile }} | |
cargo test --locked --target ${{ matrix.platform.target }} --profile ${{ steps.build.outputs.profile }} -p nghe -p nghe-types | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.build.outputs.docker-arch }}-${{ steps.build.outputs.env }} | |
path: ${{ github.workspace }}/target/${{ matrix.platform.target }}/${{ steps.build.outputs.output-dir }}/nghe | |
retention-days: 1 | |
upload-release: | |
runs-on: ubuntu-latest | |
needs: [build-frontend, build-linux, build-windows, build-macos] | |
if: ${{ github.event_name == 'release' }} | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download build artifact for release | |
uses: actions/download-artifact@v4 | |
with: | |
path: ${{ github.workspace }}/artifact/ | |
- name: Upload artifact | |
env: | |
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 |