|
| 1 | +name: Build Noviq for All Platforms |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, Rust-reimpl ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, Rust-reimpl ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +env: |
| 11 | + CARGO_TERM_COLOR: always |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + name: Build on ${{ matrix.os }} |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - os: ubuntu-latest |
| 21 | + target: x86_64-unknown-linux-gnu |
| 22 | + artifact_name: noviq |
| 23 | + asset_extension: '' |
| 24 | + - os: windows-latest |
| 25 | + target: x86_64-pc-windows-msvc |
| 26 | + artifact_name: noviq.exe |
| 27 | + asset_extension: .exe |
| 28 | + - os: macos-latest |
| 29 | + target: x86_64-apple-darwin |
| 30 | + artifact_name: noviq |
| 31 | + asset_extension: '' |
| 32 | + - os: macos-latest |
| 33 | + target: aarch64-apple-darwin |
| 34 | + artifact_name: noviq |
| 35 | + asset_extension: '' |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Checkout code |
| 39 | + uses: actions/checkout@v4 |
| 40 | + |
| 41 | + - name: Install Rust toolchain |
| 42 | + uses: dtolnay/rust-toolchain@stable |
| 43 | + with: |
| 44 | + targets: ${{ matrix.target }} |
| 45 | + |
| 46 | + - name: Cache cargo registry |
| 47 | + uses: actions/cache@v4 |
| 48 | + with: |
| 49 | + path: ~/.cargo/registry |
| 50 | + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
| 51 | + restore-keys: | |
| 52 | + ${{ runner.os }}-cargo-registry- |
| 53 | +
|
| 54 | + - name: Cache cargo index |
| 55 | + uses: actions/cache@v4 |
| 56 | + with: |
| 57 | + path: ~/.cargo/git |
| 58 | + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |
| 59 | + restore-keys: | |
| 60 | + ${{ runner.os }}-cargo-index- |
| 61 | +
|
| 62 | + - name: Cache target directory |
| 63 | + uses: actions/cache@v4 |
| 64 | + with: |
| 65 | + path: target |
| 66 | + key: ${{ runner.os }}-${{ matrix.target }}-target-${{ hashFiles('**/Cargo.lock') }} |
| 67 | + restore-keys: | |
| 68 | + ${{ runner.os }}-${{ matrix.target }}-target- |
| 69 | +
|
| 70 | + - name: Build snapshot (optimized) |
| 71 | + run: | |
| 72 | + cargo build --profile snapshot --target ${{ matrix.target }} |
| 73 | + env: |
| 74 | + SNAPSHOT: 1 |
| 75 | + |
| 76 | + - name: Get version |
| 77 | + id: version |
| 78 | + shell: bash |
| 79 | + run: | |
| 80 | + if [ "${{ runner.os }}" = "Windows" ]; then |
| 81 | + VERSION=$(./target/${{ matrix.target }}/snapshot/noviq.exe | grep "Version:" | awk '{print $2}') |
| 82 | + else |
| 83 | + VERSION=$(./target/${{ matrix.target }}/snapshot/noviq | grep "Version:" | awk '{print $2}') |
| 84 | + fi |
| 85 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 86 | + echo "Version: $VERSION" |
| 87 | +
|
| 88 | + - name: Prepare artifact name |
| 89 | + id: artifact |
| 90 | + shell: bash |
| 91 | + run: | |
| 92 | + OS_NAME="${{ runner.os }}" |
| 93 | + OS_LOWER=$(echo "$OS_NAME" | tr '[:upper:]' '[:lower:]') |
| 94 | + TARGET="${{ matrix.target }}" |
| 95 | + ARCH=$(echo "$TARGET" | cut -d'-' -f1) |
| 96 | + VERSION="${{ steps.version.outputs.version }}" |
| 97 | + ARTIFACT_NAME="noviq-${VERSION}-${OS_LOWER}-${ARCH}${{ matrix.asset_extension }}" |
| 98 | + echo "name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT |
| 99 | + echo "Artifact name: $ARTIFACT_NAME" |
| 100 | +
|
| 101 | + - name: Rename and prepare artifact |
| 102 | + shell: bash |
| 103 | + run: | |
| 104 | + mkdir -p artifacts |
| 105 | + cp target/${{ matrix.target }}/snapshot/${{ matrix.artifact_name }} artifacts/${{ steps.artifact.outputs.name }} |
| 106 | +
|
| 107 | + - name: Upload artifact |
| 108 | + uses: actions/upload-artifact@v4 |
| 109 | + with: |
| 110 | + name: ${{ steps.artifact.outputs.name }} |
| 111 | + path: artifacts/${{ steps.artifact.outputs.name }} |
| 112 | + if-no-files-found: error |
| 113 | + |
| 114 | + - name: Display artifact info |
| 115 | + shell: bash |
| 116 | + run: | |
| 117 | + ls -lh artifacts/ |
| 118 | + file artifacts/${{ steps.artifact.outputs.name }} || true |
| 119 | +
|
| 120 | + release: |
| 121 | + name: Create Release |
| 122 | + needs: build |
| 123 | + runs-on: ubuntu-latest |
| 124 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/Rust-reimpl') |
| 125 | + |
| 126 | + steps: |
| 127 | + - name: Download all artifacts |
| 128 | + uses: actions/download-artifact@v4 |
| 129 | + with: |
| 130 | + path: artifacts |
| 131 | + |
| 132 | + - name: Display downloaded artifacts |
| 133 | + run: | |
| 134 | + ls -R artifacts/ |
| 135 | +
|
| 136 | + - name: Get current date |
| 137 | + id: date |
| 138 | + run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT |
0 commit comments