refactor: optimize string collection in transforms_json function #1
This file contains hidden or 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: build | |
| on: | |
| push: | |
| tags: | |
| - "v[0-9]+.[0-9]+.[0-9]+" | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| APT_PACKAGES: "build-essential cmake perl pkg-config libclang-dev" | |
| CHOCOLATEY_PACKAGES: "cmake strawberryperl pkgconfiglite llvm nasm" | |
| HOMEBREW_PACKAGES: "llvm" | |
| BIN_NAME: "clewdr" | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-frontend: | |
| name: Build Frontend | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "lts/*" | |
| check-latest: true | |
| cache: pnpm | |
| cache-dependency-path: frontend/pnpm-lock.yaml | |
| - name: Build frontend | |
| run: | | |
| cd frontend | |
| pnpm install | |
| pnpm run build | |
| - name: Upload static directory | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: static-files | |
| path: static/ | |
| retention-days: 1 | |
| build: | |
| name: Build binary | |
| needs: build-frontend | |
| strategy: | |
| matrix: | |
| os: [linux, musllinux, android, windows, macos] | |
| target_arch: [x86_64, aarch64] | |
| variant: [slim, db] | |
| include: | |
| # rust target vendor + system + environment | |
| - os: android | |
| target_vendor_sys_env: linux-android | |
| - os: macos | |
| target_vendor_sys_env: apple-darwin | |
| - os: linux | |
| target_vendor_sys_env: unknown-linux-gnu | |
| - os: musllinux | |
| target_vendor_sys_env: unknown-linux-musl | |
| - os: windows | |
| target_vendor_sys_env: pc-windows-msvc | |
| # runner | |
| - target_arch: x86_64 | |
| runner: ubuntu-latest | |
| - target_arch: aarch64 | |
| runner: ubuntu-24.04-arm | |
| - os: android | |
| runner: ubuntu-latest | |
| - os: windows | |
| runner: windows-latest | |
| - os: macos | |
| runner: macos-latest | |
| # musl packages | |
| - os: musllinux | |
| musl_packages: "clang musl-tools" | |
| exclude: | |
| - os: android | |
| target_arch: x86_64 | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Add Rust target | |
| shell: bash | |
| id: target | |
| run: | | |
| echo "triple=${{ matrix.target_arch }}-${{matrix.target_vendor_sys_env}}" >> $GITHUB_OUTPUT | |
| rustup target add ${{ matrix.target_arch }}-${{matrix.target_vendor_sys_env}} && rustup update | |
| - uses: nttld/setup-ndk@v1.5.0 | |
| if: ${{ matrix.os == 'android' }} | |
| id: setup-ndk | |
| with: | |
| ndk-version: r27c | |
| add-to-path: true | |
| - name: Install APT packages | |
| if: contains(matrix.runner, 'ubuntu') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y ${{ matrix.musl_packages }} ${{ env.APT_PACKAGES }} | |
| - name: Install Chocolatey Packages | |
| if: matrix.os == 'windows' | |
| run: | | |
| choco install -y ${{ env.CHOCOLATEY_PACKAGES }} | |
| - name: Install Homebrew Packages | |
| if: matrix.os == 'macos' | |
| run: | | |
| brew update | |
| brew install ${{ env.HOMEBREW_PACKAGES }} | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ steps.target.outputs.triple }}-${{ matrix.variant }} | |
| - name: Prepare variant env (features and suffix) | |
| shell: bash | |
| run: | | |
| BASE_FEATURES="--no-default-features --features embed-resource,portable" | |
| if [ "${{ matrix.variant }}" = "db" ]; then | |
| echo "FEATURE_ARGS=${BASE_FEATURES},db-sqlite,db-postgres,db-mysql" >> $GITHUB_ENV | |
| echo "ARTIFACT_SUFFIX=-db" >> $GITHUB_ENV | |
| else | |
| echo "FEATURE_ARGS=${BASE_FEATURES}" >> $GITHUB_ENV | |
| echo "ARTIFACT_SUFFIX=" >> $GITHUB_ENV | |
| fi | |
| - name: Download static files | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: static-files | |
| path: static | |
| - name: Build ${{ steps.target.outputs.triple }} (${{ matrix.variant }}) | |
| if: ${{ matrix.os != 'android' }} | |
| shell: bash | |
| run: | | |
| if [ ${{ matrix.os }} == "musllinux" ]; then | |
| export CXX=${{ matrix.target_arch }}-linux-gnu-g++ | |
| export CFLAGS="-D_FORTIFY_SOURCE=0" | |
| export CXXFLAGS="-D_FORTIFY_SOURCE=0" | |
| fi | |
| if [ ${{ matrix.os }} == "windows" ]; then | |
| export RUSTFLAGS="-C target-feature=+crt-static" | |
| fi | |
| cargo build --release --target ${{ steps.target.outputs.triple }} $FEATURE_ARGS | |
| - name: Build with Android NDK (${{ matrix.variant }}) | |
| if: ${{ matrix.os == 'android' }} | |
| run: | | |
| cargo install cargo-ndk | |
| cargo ndk --target ${{ steps.target.outputs.triple }} build --release $FEATURE_ARGS | |
| env: | |
| ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | |
| ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }} | |
| - name: Move artifact to work dir and zip (${{ matrix.variant }}) | |
| shell: bash | |
| run: | | |
| mv target/${{ steps.target.outputs.triple }}/release/${{ env.BIN_NAME }} . | |
| mkdir -p release-package | |
| mv ${{ env.BIN_NAME }} release-package/ | |
| if [ ${{ matrix.os }} == "android" ]; then | |
| mv ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/${{ matrix.target_arch }}-linux-android/libc++_shared.so release-package/ | |
| fi | |
| cd release-package | |
| if [ ${{ matrix.os }} == "windows" ]; then | |
| 7z a -tzip ../${{ env.BIN_NAME }}-${{ matrix.os }}-${{matrix.target_arch}}$ARTIFACT_SUFFIX.zip * | |
| else | |
| zip -r ../${{ env.BIN_NAME }}-${{ matrix.os }}-${{matrix.target_arch}}$ARTIFACT_SUFFIX.zip . | |
| fi | |
| - name: Upload artifact (${{ matrix.variant }}) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.BIN_NAME }}-${{ matrix.os }}-${{matrix.target_arch}}${{ matrix.variant == 'db' && '-db' || '' }} | |
| path: ${{ env.BIN_NAME }}-${{ matrix.os }}-${{matrix.target_arch}}${{ matrix.variant == 'db' && '-db' || '' }}.zip | |
| retention-days: 1 | |
| release: | |
| name: Create Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: master # Ensure we get the latest master with RELEASE_NOTES.md | |
| fetch-depth: 0 # Full history for consistency | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: List downloaded artifacts | |
| run: ls -R artifacts | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: artifacts/**/${{ env.BIN_NAME }}*.zip | |
| name: ${{ github.ref_name }} | |
| body_path: RELEASE_NOTES.md # Use release notes file | |
| draft: false | |
| prerelease: false | |
| fail_on_unmatched_files: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |