.github/workflows/linux.yml #7
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
| on: | |
| workflow_dispatch: | |
| workflow_call: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build-linux: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: | |
| - target: x86_64-unknown-linux-gnu | |
| name: x86_64 | |
| linker: "" | |
| - target: aarch64-unknown-linux-gnu | |
| name: aarch64 | |
| linker: gcc-aarch64-linux-gnu | |
| - target: armv7-unknown-linux-gnueabihf | |
| name: armv7 | |
| linker: gcc-arm-linux-gnueabihf | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust target | |
| run: rustup target add ${{ matrix.target.target }} | |
| - name: Install cross-compilation tools | |
| if: matrix.target.linker != '' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y ${{ matrix.target.linker }} | |
| - name: Build for ${{ matrix.target.name }} | |
| run: cargo build --release --target ${{ matrix.target.target }} | |
| env: | |
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
| CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc | |
| - name: Install packaging tools | |
| run: | | |
| cargo install cargo-deb cargo-generate-rpm | |
| - name: Generate Packages | |
| run: | | |
| cargo deb --target ${{ matrix.target.target }} --no-build | |
| cargo generate-rpm --target ${{ matrix.target.target }} | |
| - name: Get version | |
| id: get_version | |
| run: echo "version=$(./target/${{ matrix.target.target }}/release/cim -v)" >> $GITHUB_ENV | |
| - name: Prepare Binary for upload | |
| run: | | |
| TARGET="target/${{ matrix.target.target }}/release" | |
| ls -al "$TARGET" | |
| mv "$TARGET/cim" "$TARGET/cim-${{ matrix.target.name }}-v${{ env.version }}" | |
| - name: Upload release assets | |
| uses: AButler/upload-release-assets@v3.0 | |
| with: | |
| files: | | |
| target/${{ matrix.target.target }}/debian/*.deb | |
| target/${{ matrix.target.target }}/generate-rpm/*.rpm | |
| target/${{ matrix.target.target }}/release/cim-* | |
| repo-token: ${{ github.token }} | |
| release-tag: "v${{ env.version }}" |