|
| 1 | +name: Release Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' # Triggers on tags like v2.0.0, v2.1.0, etc. |
| 7 | + |
| 8 | +env: |
| 9 | + CARGO_TERM_COLOR: always |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build ${{ matrix.target }} |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + # Linux x86_64 |
| 20 | + - os: ubuntu-latest |
| 21 | + target: x86_64-unknown-linux-gnu |
| 22 | + artifact_name: loki-linux-x86_64 |
| 23 | + binary_name: loki |
| 24 | + archive_format: tar.gz |
| 25 | + |
| 26 | + # Linux ARM64 |
| 27 | + - os: ubuntu-latest |
| 28 | + target: aarch64-unknown-linux-gnu |
| 29 | + artifact_name: loki-linux-aarch64 |
| 30 | + binary_name: loki |
| 31 | + archive_format: tar.gz |
| 32 | + |
| 33 | + # Windows x86_64 |
| 34 | + - os: windows-latest |
| 35 | + target: x86_64-pc-windows-msvc |
| 36 | + artifact_name: loki-windows-x86_64 |
| 37 | + binary_name: loki.exe |
| 38 | + archive_format: zip |
| 39 | + |
| 40 | + # macOS x86_64 |
| 41 | + - os: macos-latest |
| 42 | + target: x86_64-apple-darwin |
| 43 | + artifact_name: loki-macos-x86_64 |
| 44 | + binary_name: loki |
| 45 | + archive_format: tar.gz |
| 46 | + |
| 47 | + # macOS ARM64 (Apple Silicon) |
| 48 | + - os: macos-latest |
| 49 | + target: aarch64-apple-darwin |
| 50 | + artifact_name: loki-macos-aarch64 |
| 51 | + binary_name: loki |
| 52 | + archive_format: tar.gz |
| 53 | + |
| 54 | + steps: |
| 55 | + - name: Checkout code |
| 56 | + uses: actions/checkout@v4 |
| 57 | + with: |
| 58 | + submodules: recursive |
| 59 | + |
| 60 | + - name: Install Rust |
| 61 | + uses: dtolnay/rust-toolchain@stable |
| 62 | + with: |
| 63 | + targets: ${{ matrix.target }} |
| 64 | + |
| 65 | + - name: Cache Cargo registry |
| 66 | + uses: actions/cache@v4 |
| 67 | + with: |
| 68 | + path: | |
| 69 | + ~/.cargo/bin/ |
| 70 | + ~/.cargo/registry/index/ |
| 71 | + ~/.cargo/registry/cache/ |
| 72 | + ~/.cargo/git/db/ |
| 73 | + target/ |
| 74 | + key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} |
| 75 | + restore-keys: | |
| 76 | + ${{ runner.os }}-cargo-${{ matrix.target }}- |
| 77 | +
|
| 78 | + - name: Install cross-compilation dependencies (Linux ARM64) |
| 79 | + if: matrix.target == 'aarch64-unknown-linux-gnu' |
| 80 | + run: | |
| 81 | + sudo apt-get update |
| 82 | + sudo apt-get install -y gcc-aarch64-linux-gnu |
| 83 | +
|
| 84 | + - name: Configure Cargo for cross-compilation (Linux ARM64) |
| 85 | + if: matrix.target == 'aarch64-unknown-linux-gnu' |
| 86 | + run: | |
| 87 | + mkdir -p .cargo |
| 88 | + echo '[target.aarch64-unknown-linux-gnu]' >> .cargo/config.toml |
| 89 | + echo 'linker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml |
| 90 | +
|
| 91 | + - name: Build release binary |
| 92 | + run: cargo build --release --target ${{ matrix.target }} |
| 93 | + |
| 94 | + - name: Strip binary (Linux/macOS) |
| 95 | + if: runner.os != 'Windows' |
| 96 | + run: | |
| 97 | + strip target/${{ matrix.target }}/release/${{ matrix.binary_name }} |
| 98 | +
|
| 99 | + - name: Create release archive |
| 100 | + shell: bash |
| 101 | + run: | |
| 102 | + VERSION=${GITHUB_REF#refs/tags/} |
| 103 | + ARCHIVE_NAME="${{ matrix.artifact_name }}-${VERSION}.${{ matrix.archive_format }}" |
| 104 | + |
| 105 | + if [ "${{ matrix.archive_format }}" = "tar.gz" ]; then |
| 106 | + tar czf "${ARCHIVE_NAME}" -C target/${{ matrix.target }}/release ${{ matrix.binary_name }} |
| 107 | + else |
| 108 | + cd target/${{ matrix.target }}/release |
| 109 | + zip -r "../../../${ARCHIVE_NAME}" ${{ matrix.binary_name }} |
| 110 | + cd ../../.. |
| 111 | + fi |
| 112 | + |
| 113 | + echo "ARCHIVE_NAME=${ARCHIVE_NAME}" >> $GITHUB_ENV |
| 114 | + echo "BINARY_NAME=${{ matrix.binary_name }}" >> $GITHUB_ENV |
| 115 | +
|
| 116 | + - name: Generate checksums (Linux/macOS) |
| 117 | + if: runner.os != 'Windows' |
| 118 | + shell: bash |
| 119 | + run: | |
| 120 | + sha256sum "${ARCHIVE_NAME}" > "${ARCHIVE_NAME}.sha256" |
| 121 | + echo "CHECKSUM_FILE=${ARCHIVE_NAME}.sha256" >> $GITHUB_ENV |
| 122 | +
|
| 123 | + - name: Generate checksums (Windows) |
| 124 | + if: runner.os == 'Windows' |
| 125 | + shell: pwsh |
| 126 | + run: | |
| 127 | + $hash = Get-FileHash -Path "${ARCHIVE_NAME}" -Algorithm SHA256 |
| 128 | + $hash.Hash | Out-File -FilePath "${ARCHIVE_NAME}.sha256" -Encoding ASCII |
| 129 | + echo "CHECKSUM_FILE=${ARCHIVE_NAME}.sha256" >> $env:GITHUB_ENV |
| 130 | +
|
| 131 | + - name: Upload artifacts |
| 132 | + uses: actions/upload-artifact@v4 |
| 133 | + with: |
| 134 | + name: ${{ matrix.artifact_name }} |
| 135 | + path: | |
| 136 | + ${{ env.ARCHIVE_NAME }} |
| 137 | + ${{ env.CHECKSUM_FILE }} |
| 138 | +
|
| 139 | + release: |
| 140 | + name: Create Release |
| 141 | + needs: build |
| 142 | + runs-on: ubuntu-latest |
| 143 | + permissions: |
| 144 | + contents: write |
| 145 | + |
| 146 | + steps: |
| 147 | + - name: Checkout code |
| 148 | + uses: actions/checkout@v4 |
| 149 | + |
| 150 | + - name: Download all artifacts |
| 151 | + uses: actions/download-artifact@v4 |
| 152 | + with: |
| 153 | + path: artifacts |
| 154 | + |
| 155 | + - name: Extract version from tag |
| 156 | + id: version |
| 157 | + run: | |
| 158 | + VERSION=${GITHUB_REF#refs/tags/} |
| 159 | + echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT |
| 160 | + echo "Tag version: ${VERSION}" |
| 161 | +
|
| 162 | + - name: Create Release |
| 163 | + uses: softprops/action-gh-release@v1 |
| 164 | + with: |
| 165 | + name: Release ${{ steps.version.outputs.VERSION }} |
| 166 | + body: | |
| 167 | + ## Loki2 ${{ steps.version.outputs.VERSION }} |
| 168 | + |
| 169 | + ### Downloads |
| 170 | + |
| 171 | + **Linux (x86_64)** |
| 172 | + - Binary: `loki-linux-x86_64-${{ steps.version.outputs.VERSION }}.tar.gz` |
| 173 | + - Checksum: `loki-linux-x86_64-${{ steps.version.outputs.VERSION }}.tar.gz.sha256` |
| 174 | + |
| 175 | + **Linux (ARM64)** |
| 176 | + - Binary: `loki-linux-aarch64-${{ steps.version.outputs.VERSION }}.tar.gz` |
| 177 | + - Checksum: `loki-linux-aarch64-${{ steps.version.outputs.VERSION }}.tar.gz.sha256` |
| 178 | + |
| 179 | + **Windows (x86_64)** |
| 180 | + - Binary: `loki-windows-x86_64-${{ steps.version.outputs.VERSION }}.zip` |
| 181 | + - Checksum: `loki-windows-x86_64-${{ steps.version.outputs.VERSION }}.zip.sha256` |
| 182 | + |
| 183 | + **macOS (x86_64)** |
| 184 | + - Binary: `loki-macos-x86_64-${{ steps.version.outputs.VERSION }}.tar.gz` |
| 185 | + - Checksum: `loki-macos-x86_64-${{ steps.version.outputs.VERSION }}.tar.gz.sha256` |
| 186 | + |
| 187 | + **macOS (ARM64/Apple Silicon)** |
| 188 | + - Binary: `loki-macos-aarch64-${{ steps.version.outputs.VERSION }}.tar.gz` |
| 189 | + - Checksum: `loki-macos-aarch64-${{ steps.version.outputs.VERSION }}.tar.gz.sha256` |
| 190 | + |
| 191 | + ### Installation |
| 192 | + |
| 193 | + 1. Download the appropriate binary for your platform |
| 194 | + 2. Extract the archive |
| 195 | + 3. Make binary executable (Linux/macOS): `chmod +x loki` |
| 196 | + 4. Run: `./loki --help` |
| 197 | + |
| 198 | + ### Signature Base |
| 199 | + |
| 200 | + You'll need to link or clone the signature-base repository: |
| 201 | + ```bash |
| 202 | + git clone https://github.com/Neo23x0/signature-base.git signatures |
| 203 | + ``` |
| 204 | + files: | |
| 205 | + artifacts/**/* |
| 206 | + draft: false |
| 207 | + prerelease: ${{ contains(steps.version.outputs.VERSION, '-') }} |
| 208 | + tag_name: ${{ steps.version.outputs.VERSION }} |
| 209 | + |
| 210 | + |
0 commit comments