fix(deps): update rust crate syn to v2.0.90 (#530) #1835
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 | |
RUST_BACKTRACE: full | |
RUST_LOG: debug | |
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" | |
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/postgres" | |
AWS_ACCESS_KEY_ID: minioadmin | |
AWS_SECRET_ACCESS_KEY: minioadmin | |
AWS_REGION: us-east-1 | |
AWS_ENDPOINT_URL: http://localhost:9000 | |
AWS_USE_PATH_STYLE_ENDPOINT: true | |
MINIO_ROOT_USER: minioadmin | |
MINIO_ROOT_PASSWORD: minioadmin | |
jobs: | |
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:17 | |
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 | |
s3: | |
image: bitnami/minio:2024.11.7 | |
env: | |
MINIO_ROOT_USER: ${{ env.MINIO_ROOT_USER }} | |
MINIO_ROOT_PASSWORD: ${{ env.MINIO_ROOT_PASSWORD }} | |
ports: | |
- 9000:9000 | |
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 | |
env: | |
TARGET: ${{ matrix.platform.target }} | |
run: | | |
echo "env=${TARGET##*-}" >> "$GITHUB_OUTPUT" | |
echo "arch=$(echo $TARGET | cut -d '-' -f1)" >> "$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" | |
- name: Extract rust toolchain | |
id: toolchain | |
run: | | |
echo "channel=$(grep channel rust-toolchain.toml | awk -F' = ' '{printf $2}' | tr -d '\"')" >> "$GITHUB_OUTPUT" | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ steps.toolchain.outputs.channel }} | |
- 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 postgres psql -U postgres -d postgres -c "ALTER SYSTEM SET max_connections = '1000'"; | |
docker exec postgres psql -U postgres -d postgres -c "ALTER SYSTEM SET shared_buffers = '2048MB'"; | |
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 musl environment | |
run: | | |
wget -c https://github.com/xmake-mirror/musl.cc/releases/download/20210202/${{ steps.build.outputs.arch }}-linux-musl-cross.linux.tgz -O - | tar -xz | |
sudo ln -s ${{ github.workspace }}/${{ steps.build.outputs.arch }}-linux-musl-cross/bin/${{ steps.build.outputs.arch }}-linux-musl-g++ /usr/bin/${{ steps.build.outputs.arch }}-linux-musl-g++ | |
sudo ln -s ${{ github.workspace }}/${{ steps.build.outputs.arch }}-linux-musl-cross/bin/${{ steps.build.outputs.arch }}-linux-musl-gcc /usr/bin/${{ steps.build.outputs.arch }}-linux-musl-gcc | |
${{ steps.build.outputs.arch }}-linux-musl-gcc --version | |
${{ steps.build.outputs.arch }}-linux-musl-g++ --version | |
sudo ln -s ${{ github.workspace }}/vcpkg/cross-pkg-config /usr/bin/${{ steps.build.outputs.arch }}-linux-musl-pkg-config | |
${{ steps.build.outputs.arch }}-linux-musl-pkg-config --version | |
if: ${{ steps.build.outputs.env == '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@v2 | |
with: | |
tool: cargo-vcpkg | |
- name: Build vcpkg dependencies | |
run: | | |
cargo vcpkg --verbose build --manifest-path nghe-backend/Cargo.toml --target ${{ matrix.platform.target }} | |
- name: Install cross | |
if: ${{ matrix.platform.command == 'cross' }} | |
uses: taiki-e/cache-cargo-install-action@v2 | |
with: | |
tool: cross | |
git: https://github.com/cross-rs/cross | |
rev: 19be83481fd3e50ea103d800d72e0f8eddb1c90c | |
locked: false | |
- 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 }} --workspace --exclude nghe-frontend | |
env: | |
LASTFM_KEY: ${{ steps.build.outputs.docker-arch == 'amd64' && secrets.LASTFM_KEY || '' }} | |
SPOTIFY_ID: ${{ steps.build.outputs.docker-arch == 'amd64' && secrets.SPOTIFY_ID || '' }} | |
SPOTIFY_SECRET: ${{ steps.build.outputs.docker-arch == 'amd64' && secrets.SPOTIFY_SECRET || '' }} | |
- 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_backend | |
retention-days: 1 | |
build-docker: | |
runs-on: ubuntu-latest | |
needs: [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@v6 | |
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@v6 | |
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-freebsd: | |
strategy: | |
fail-fast: false | |
matrix: | |
version: | |
- "14.0" | |
- "13.2" | |
runs-on: ubuntu-latest | |
env: | |
TARGET: x86_64-unknown-freebsd | |
services: | |
postgres: | |
image: postgres:17 | |
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 | |
s3: | |
image: bitnami/minio:2024.11.7 | |
env: | |
MINIO_ROOT_USER: ${{ env.MINIO_ROOT_USER }} | |
MINIO_ROOT_PASSWORD: ${{ env.MINIO_ROOT_PASSWORD }} | |
ports: | |
- 9000:9000 | |
steps: | |
- name: Remove unused packages | |
run: | | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /usr/local/lib/android | |
sudo rm -rf /opt/ghc | |
sudo rm -rf /opt/hostedtoolcache | |
sudo rm -rf /usr/local/share/edge_driver | |
sudo rm -rf /usr/local/share/gecko_driver | |
sudo rm -rf /usr/local/share/chromium | |
sudo rm -rf /usr/local/share/chromedriver-linux64 | |
sudo rm -rf /usr/local/share/vcpkg | |
sudo rm -rf /usr/local/lib/python* | |
sudo rm -rf /usr/local/lib/node_modules | |
sudo rm -rf /usr/local/julia* | |
sudo rm -rf /usr/share/vim | |
sudo rm -rf /usr/share/postgresql | |
sudo rm -rf /usr/share/man | |
sudo rm -rf /usr/share/apache-maven-* | |
sudo rm -rf /usr/share/R | |
sudo rm -rf /usr/share/alsa | |
sudo rm -rf /usr/share/miniconda | |
sudo rm -rf /usr/share/grub | |
sudo rm -rf /usr/share/gradle-* | |
sudo rm -rf /usr/share/locale | |
sudo rm -rf /usr/share/texinfo | |
sudo rm -rf /usr/share/kotlinc | |
sudo rm -rf /usr/share/swift | |
sudo rm -rf /usr/share/doc | |
sudo rm -rf /usr/share/az_9.3.0 | |
sudo rm -rf /usr/share/sbt | |
sudo rm -rf /usr/share/ri | |
sudo rm -rf /usr/share/icons | |
sudo rm -rf /usr/share/java | |
sudo rm -rf /usr/share/fonts | |
sudo rm -rf /usr/lib/google-cloud-sdk | |
sudo rm -rf /usr/lib/jvm | |
sudo rm -rf /usr/lib/mono | |
sudo rm -rf /usr/lib/R | |
sudo rm -rf /usr/lib/postgresql | |
sudo rm -rf /usr/lib/heroku | |
sudo rm -rf /usr/lib/gcc | |
sudo docker image prune --all --force | |
- 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" | |
- name: Extract rust toolchain | |
id: toolchain | |
run: | | |
echo "channel=$(grep channel rust-toolchain.toml | awk -F' = ' '{printf $2}' | tr -d '\"')" >> "$GITHUB_OUTPUT" | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ steps.toolchain.outputs.channel }} | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
key: ${{ steps.build.outputs.target }}-${{ matrix.version }}-${{ steps.build.outputs.profile }} | |
save-if: ${{ github.ref == 'refs/heads/main' }} | |
- name: Increase postgres max connection | |
run: | | |
docker exec postgres psql -U postgres -d postgres -c "ALTER SYSTEM SET max_connections = '1000'"; | |
docker exec postgres psql -U postgres -d postgres -c "ALTER SYSTEM SET shared_buffers = '2048MB'"; | |
docker restart postgres | |
- name: Build and test | |
uses: cross-platform-actions/[email protected] | |
env: | |
DATABASE_URL: "postgres://postgres:[email protected]:5432/postgres" | |
AWS_ENDPOINT_URL: "http://10.0.2.2:9000" | |
with: | |
operating_system: freebsd | |
version: ${{ matrix.version }} | |
environment_variables: "CARGO_TERM_COLOR RUST_BACKTRACE RUST_LOG DATABASE_URL AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_REGION AWS_ENDPOINT_URL AWS_USE_PATH_STYLE_ENDPOINT" | |
shell: "bash" | |
cpu_count: 4 | |
image_url: https://github.com/vnghia/nghe-freebsd-builder/releases/download/v0.0.12/freebsd-${{ matrix.version }}-x86-64.qcow2 | |
run: | | |
sudo chown -R $(id -u):$(id -g) /root/ | |
export PATH="/root/.cargo/bin/:$PATH" | |
mkdir -p target/vcpkg-archives | |
mkdir -p ~/.cache/vcpkg/ | |
ln -s target/vcpkg-archives ~/.cache/vcpkg/archives | |
cargo install cargo-vcpkg | |
cargo vcpkg --verbose build --manifest-path nghe-backend/Cargo.toml --target ${{ steps.build.outputs.target }} | |
cargo build --locked --target ${{ steps.build.outputs.target }} --profile ${{ steps.build.outputs.profile }} | |
cargo test --locked --target ${{ steps.build.outputs.target }} --profile ${{ steps.build.outputs.profile }} --workspace --exclude nghe-frontend | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: amd64-${{ steps.build.outputs.env }}-${{ matrix.version }} | |
path: ${{ github.workspace }}/target/${{ steps.build.outputs.target }}/${{ steps.build.outputs.output-dir }}/nghe_backend | |
retention-days: 1 | |
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 || ''); | |
- 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 | |
- name: Extract rust toolchain | |
id: toolchain | |
shell: bash | |
run: | | |
echo "channel=$(grep channel rust-toolchain.toml | awk -F' = ' '{printf $2}' | tr -d '\"')" >> "$GITHUB_OUTPUT" | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ steps.toolchain.outputs.channel }} | |
- 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 = '2048MB'" | |
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 and setup minio | |
run: | | |
curl https://dl.min.io/server/minio/release/windows-amd64/minio.exe --output minio.exe | |
- name: Install cargo-vcpkg | |
uses: taiki-e/cache-cargo-install-action@v2 | |
with: | |
tool: cargo-vcpkg | |
- name: Build vcpkg dependencies | |
run: | | |
cargo vcpkg --verbose build --manifest-path nghe-backend\Cargo.toml --target x86_64-pc-windows-msvc | |
- name: Build and test | |
run: | | |
.\minio.exe server data & | |
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 }} --workspace --exclude nghe-frontend | |
env: | |
LASTFM_KEY: ${{ secrets.LASTFM_KEY }} | |
SPOTIFY_ID: ${{ secrets.SPOTIFY_ID }} | |
SPOTIFY_SECRET: ${{ secrets.SPOTIFY_SECRET }} | |
- 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 || ''); | |
- 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" | |
- name: Extract rust toolchain | |
id: toolchain | |
run: | | |
echo "channel=$(grep channel rust-toolchain.toml | awk -F' = ' '{printf $2}' | tr -d '\"')" >> "$GITHUB_OUTPUT" | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ steps.toolchain.outputs.channel }} | |
- 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 = '2048MB'" | |
pg_ctl restart | |
- name: Install and setup minio | |
run: | | |
brew install minio/stable/minio | |
minio server data & | |
- name: Install vcpkg build deps | |
run: brew install nasm | |
- name: Install cargo-vcpkg | |
uses: taiki-e/cache-cargo-install-action@v2 | |
with: | |
tool: cargo-vcpkg | |
- name: Build vcpkg dependencies | |
run: | | |
cargo vcpkg --verbose build --manifest-path nghe-backend/Cargo.toml --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 }} --workspace --exclude nghe-frontend | |
env: | |
LASTFM_KEY: ${{ steps.build.outputs.docker-arch == 'arm64' && secrets.LASTFM_KEY || '' }} | |
SPOTIFY_ID: ${{ steps.build.outputs.docker-arch == 'arm64' && secrets.SPOTIFY_ID || '' }} | |
SPOTIFY_SECRET: ${{ steps.build.outputs.docker-arch == 'arm64' && secrets.SPOTIFY_SECRET || '' }} | |
- 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_backend | |
retention-days: 1 | |
upload-release: | |
runs-on: ubuntu-latest | |
needs: [build-linux, build-freebsd, 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-freebsd-14.0.zip artifact/amd64-freebsd-13.2.zip artifact/amd64-darwin.zip artifact/arm64-darwin.zip artifact/amd64-windows.zip artifact/frontend.zip |