Fixed Formatting Issues #26
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - development | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # macOS native builds | |
| - os: macos-13 | |
| target: x86_64-apple-darwin | |
| name: macos-x64 | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| name: macos-arm64 | |
| # Linux native builds | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| name: linux-x64 | |
| - os: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| name: linux-arm64 | |
| use_cross: true | |
| # Windows native build | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| name: windows-x64 | |
| # ARM Linux build (Raspberry Pi) | |
| - os: ubuntu-latest | |
| target: armv7-unknown-linux-gnueabihf | |
| name: pi-armv7 | |
| use_cross: true | |
| # Embedded build (only embedded crate) | |
| - os: ubuntu-latest | |
| target: thumbv7m-none-eabi | |
| name: embedded-arm | |
| use_cross: true | |
| embedded_only: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Read version from VERSION file | |
| id: version | |
| run: | | |
| if [ -f VERSION ]; then | |
| VERSION=$(cat VERSION | tr -d '\n\r') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=0.1.0" >> $GITHUB_OUTPUT | |
| fi | |
| shell: bash | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install dependencies (macOS) | |
| if: matrix.os == 'macos-latest' || matrix.os == 'macos-13' | |
| run: brew install protobuf pkg-config | |
| - name: Install dependencies (Linux x64 with D-Bus BLE) | |
| if: matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-gnu' | |
| run: | | |
| sudo apt update | |
| sudo apt install -y \ | |
| build-essential \ | |
| pkg-config \ | |
| protobuf-compiler \ | |
| libbluetooth-dev \ | |
| libdbus-1-dev \ | |
| libdbus-glib-1-dev \ | |
| libudev-dev | |
| - name: Install dependencies (ARM Linux with direct HCI BLE) | |
| if: matrix.os == 'ubuntu-latest' && matrix.use_cross == true && matrix.embedded_only != true | |
| run: | | |
| sudo apt update | |
| sudo apt install -y \ | |
| build-essential \ | |
| pkg-config \ | |
| protobuf-compiler | |
| - name: Install basic dependencies (Embedded) | |
| if: matrix.embedded_only == true | |
| run: | | |
| sudo apt update | |
| sudo apt install -y build-essential | |
| - name: Install dependencies (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: choco install protoc | |
| - name: Install cross | |
| if: matrix.use_cross == true | |
| run: cargo install cross --git https://github.com/cross-rs/cross | |
| - name: Set up environment for cross-compilation | |
| if: matrix.use_cross == true && matrix.embedded_only != true | |
| run: | | |
| # Download and install protoc for cross-compilation | |
| PROTOC_VERSION=21.12 | |
| curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip | |
| unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d protoc | |
| sudo cp protoc/bin/protoc /usr/local/bin/ | |
| sudo chmod +x /usr/local/bin/protoc | |
| # Set environment variables for cross-compilation | |
| echo "PROTOC=/usr/local/bin/protoc" >> $GITHUB_ENV | |
| echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV | |
| - name: Build embedded only | |
| if: matrix.embedded_only == true | |
| run: cross build --release --target ${{ matrix.target }} -p metamesh-embedded | |
| - name: Build with cross | |
| if: matrix.use_cross == true && matrix.embedded_only != true | |
| env: | |
| PROTOC: /usr/local/bin/protoc | |
| PKG_CONFIG_ALLOW_CROSS: 1 | |
| run: cross build --release --target ${{ matrix.target }} | |
| - name: Build with cargo | |
| if: matrix.use_cross != true | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Package (Unix) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| mkdir -p dist | |
| if [ "${{ matrix.embedded_only }}" = "true" ]; then | |
| cp target/${{ matrix.target }}/release/libmetamesh_embedded.rlib dist/ 2>/dev/null || echo "embedded lib not found" | |
| echo "Embedded library for ${{ matrix.target }}" > dist/README.txt | |
| else | |
| cp target/${{ matrix.target }}/release/metamesh-daemon dist/ 2>/dev/null || echo "daemon not found" | |
| cp target/${{ matrix.target }}/release/metamesh-client dist/ 2>/dev/null || echo "client not found" | |
| fi | |
| tar -czf metamesh-${{ matrix.name }}-v${{ steps.version.outputs.version }}.tar.gz -C dist . | |
| - name: Package (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| mkdir dist | |
| copy target\${{ matrix.target }}\release\metamesh-daemon.exe dist\ 2>nul || echo "daemon not found" | |
| copy target\${{ matrix.target }}\release\metamesh-client.exe dist\ 2>nul || echo "client not found" | |
| Compress-Archive -Path dist\* -DestinationPath metamesh-${{ matrix.name }}-v${{ steps.version.outputs.version }}.zip | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: metamesh-${{ matrix.name }}-v${{ steps.version.outputs.version }} | |
| path: metamesh-${{ matrix.name }}-v${{ steps.version.outputs.version }}.* | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: ${{ !contains(needs.build.result, 'failure') }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Read version from VERSION file | |
| id: version | |
| run: | | |
| if [ -f VERSION ]; then | |
| VERSION=$(cat VERSION | tr -d '\n\r') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=0.1.0" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: Delete existing release (if exists) | |
| run: | | |
| gh release delete v${{ steps.version.outputs.version }} --yes || echo "Release doesn't exist" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| name: MetaMesh v${{ steps.version.outputs.version }} | |
| files: | | |
| metamesh-macos-x64-v${{ steps.version.outputs.version }}/metamesh-macos-x64-v${{ steps.version.outputs.version }}.tar.gz | |
| metamesh-macos-arm64-v${{ steps.version.outputs.version }}/metamesh-macos-arm64-v${{ steps.version.outputs.version }}.tar.gz | |
| metamesh-linux-x64-v${{ steps.version.outputs.version }}/metamesh-linux-x64-v${{ steps.version.outputs.version }}.tar.gz | |
| metamesh-linux-arm64-v${{ steps.version.outputs.version }}/metamesh-linux-arm64-v${{ steps.version.outputs.version }}.tar.gz | |
| metamesh-windows-x64-v${{ steps.version.outputs.version }}/metamesh-windows-x64-v${{ steps.version.outputs.version }}.zip | |
| metamesh-pi-armv7-v${{ steps.version.outputs.version }}/metamesh-pi-armv7-v${{ steps.version.outputs.version }}.tar.gz | |
| metamesh-embedded-arm-v${{ steps.version.outputs.version }}/metamesh-embedded-arm-v${{ steps.version.outputs.version }}.tar.gz | |
| generate_release_notes: true | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |