|
| 1 | +name: Release LSP |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + name: Release LSP - ${{ matrix.os }} (${{ matrix.arch }}) |
| 11 | + runs-on: ${{ matrix.runner }} |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - os: linux |
| 16 | + arch: x64 |
| 17 | + runner: ubuntu-latest |
| 18 | + target: x86_64-unknown-linux-gnu |
| 19 | + binary_name: ci |
| 20 | + asset_name: ci-lsp-linux-x64 |
| 21 | + - os: linux |
| 22 | + arch: arm64 |
| 23 | + runner: ubuntu-latest |
| 24 | + target: aarch64-unknown-linux-gnu |
| 25 | + binary_name: ci |
| 26 | + asset_name: ci-lsp-linux-arm64 |
| 27 | + - os: windows |
| 28 | + arch: x64 |
| 29 | + runner: windows-latest |
| 30 | + target: x86_64-pc-windows-msvc |
| 31 | + binary_name: ci.exe |
| 32 | + asset_name: ci-lsp-windows-x64.exe |
| 33 | + - os: windows |
| 34 | + arch: arm64 |
| 35 | + runner: windows-latest |
| 36 | + target: aarch64-pc-windows-msvc |
| 37 | + binary_name: ci.exe |
| 38 | + asset_name: ci-lsp-windows-arm64.exe |
| 39 | + - os: darwin |
| 40 | + arch: x64 |
| 41 | + runner: macos-latest |
| 42 | + target: x86_64-apple-darwin |
| 43 | + binary_name: ci |
| 44 | + asset_name: ci-lsp-darwin-x64 |
| 45 | + - os: darwin |
| 46 | + arch: arm64 |
| 47 | + runner: macos-latest |
| 48 | + target: aarch64-apple-darwin |
| 49 | + binary_name: ci |
| 50 | + asset_name: ci-lsp-darwin-arm64 |
| 51 | + |
| 52 | + steps: |
| 53 | + - name: Checkout Source |
| 54 | + uses: actions/checkout@v4 |
| 55 | + |
| 56 | + - name: Set variables |
| 57 | + id: vars |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + echo "package_name=$(sed -En 's/name[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.toml | head -1)" >> $GITHUB_OUTPUT |
| 61 | + echo "package_version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 62 | +
|
| 63 | + - name: Install Rust toolchain |
| 64 | + uses: dtolnay/rust-toolchain@stable |
| 65 | + with: |
| 66 | + targets: ${{ matrix.target }} |
| 67 | + |
| 68 | + - name: Install cross-compilation tools (Linux ARM64) |
| 69 | + if: matrix.target == 'aarch64-unknown-linux-gnu' |
| 70 | + run: | |
| 71 | + sudo apt-get update |
| 72 | + sudo apt-get install -y gcc-aarch64-linux-gnu |
| 73 | +
|
| 74 | + - name: Configure cross-compilation (Linux ARM64) |
| 75 | + if: matrix.target == 'aarch64-unknown-linux-gnu' |
| 76 | + run: | |
| 77 | + echo "[target.aarch64-unknown-linux-gnu]" >> ~/.cargo/config.toml |
| 78 | + echo "linker = \"aarch64-linux-gnu-gcc\"" >> ~/.cargo/config.toml |
| 79 | +
|
| 80 | + - name: Cache cargo registry and build |
| 81 | + uses: actions/cache@v4 |
| 82 | + with: |
| 83 | + path: | |
| 84 | + ~/.cargo/registry |
| 85 | + ~/.cargo/git |
| 86 | + target |
| 87 | + key: ${{ runner.os }}-${{ matrix.target }}-cargo-lsp-${{ hashFiles('**/Cargo.lock') }} |
| 88 | + restore-keys: | |
| 89 | + ${{ runner.os }}-${{ matrix.target }}-cargo-lsp- |
| 90 | +
|
| 91 | + - name: Build release binary with LSP feature |
| 92 | + run: cargo build --release --features lsp --target ${{ matrix.target }} |
| 93 | + |
| 94 | + - name: Upload binary as artifact |
| 95 | + uses: actions/upload-artifact@v4 |
| 96 | + with: |
| 97 | + name: ${{ matrix.asset_name }} |
| 98 | + path: target/${{ matrix.target }}/release/${{ matrix.binary_name }} |
| 99 | + |
| 100 | + create-release: |
| 101 | + name: Create LSP Release |
| 102 | + runs-on: ubuntu-latest |
| 103 | + needs: release |
| 104 | + steps: |
| 105 | + - name: Checkout Source |
| 106 | + uses: actions/checkout@v4 |
| 107 | + |
| 108 | + - name: Set variables |
| 109 | + id: vars |
| 110 | + run: | |
| 111 | + echo "package_name=$(sed -En 's/name[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.toml | head -1)" >> $GITHUB_OUTPUT |
| 112 | + echo "package_version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 113 | +
|
| 114 | + - name: Download all artifacts |
| 115 | + uses: actions/download-artifact@v4 |
| 116 | + with: |
| 117 | + path: artifacts |
| 118 | + |
| 119 | + - name: Remove Same Release |
| 120 | + uses: omarabid-forks/action-rollback@stable |
| 121 | + continue-on-error: true |
| 122 | + with: |
| 123 | + tag: ${{ steps.vars.outputs.package_version }} |
| 124 | + env: |
| 125 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 126 | + |
| 127 | + - name: Create Release |
| 128 | + id: create-release |
| 129 | + uses: actions/create-release@latest |
| 130 | + env: |
| 131 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 132 | + with: |
| 133 | + tag_name: ${{ steps.vars.outputs.package_version }} |
| 134 | + release_name: LSP Server ${{ steps.vars.outputs.package_version }} |
| 135 | + body: ${{ steps.vars.outputs.package_name }} LSP Server - ${{ steps.vars.outputs.package_version }} |
| 136 | + draft: false |
| 137 | + prerelease: false |
| 138 | + |
| 139 | + - name: Upload Linux x64 binary |
| 140 | + uses: actions/upload-release-asset@v1 |
| 141 | + env: |
| 142 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 143 | + with: |
| 144 | + upload_url: ${{ steps.create-release.outputs.upload_url }} |
| 145 | + asset_path: artifacts/ci-lsp-linux-x64/ci |
| 146 | + asset_name: ci-lsp-linux-x64 |
| 147 | + asset_content_type: application/octet-stream |
| 148 | + |
| 149 | + - name: Upload Linux arm64 binary |
| 150 | + uses: actions/upload-release-asset@v1 |
| 151 | + env: |
| 152 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 153 | + with: |
| 154 | + upload_url: ${{ steps.create-release.outputs.upload_url }} |
| 155 | + asset_path: artifacts/ci-lsp-linux-arm64/ci |
| 156 | + asset_name: ci-lsp-linux-arm64 |
| 157 | + asset_content_type: application/octet-stream |
| 158 | + |
| 159 | + - name: Upload Windows x64 binary |
| 160 | + uses: actions/upload-release-asset@v1 |
| 161 | + env: |
| 162 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 163 | + with: |
| 164 | + upload_url: ${{ steps.create-release.outputs.upload_url }} |
| 165 | + asset_path: artifacts/ci-lsp-windows-x64.exe/ci.exe |
| 166 | + asset_name: ci-lsp-windows-x64.exe |
| 167 | + asset_content_type: application/octet-stream |
| 168 | + |
| 169 | + - name: Upload Windows arm64 binary |
| 170 | + uses: actions/upload-release-asset@v1 |
| 171 | + env: |
| 172 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 173 | + with: |
| 174 | + upload_url: ${{ steps.create-release.outputs.upload_url }} |
| 175 | + asset_path: artifacts/ci-lsp-windows-arm64.exe/ci.exe |
| 176 | + asset_name: ci-lsp-windows-arm64.exe |
| 177 | + asset_content_type: application/octet-stream |
| 178 | + |
| 179 | + - name: Upload macOS x64 binary |
| 180 | + uses: actions/upload-release-asset@v1 |
| 181 | + env: |
| 182 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 183 | + with: |
| 184 | + upload_url: ${{ steps.create-release.outputs.upload_url }} |
| 185 | + asset_path: artifacts/ci-lsp-darwin-x64/ci |
| 186 | + asset_name: ci-lsp-darwin-x64 |
| 187 | + asset_content_type: application/octet-stream |
| 188 | + |
| 189 | + - name: Upload macOS arm64 binary |
| 190 | + uses: actions/upload-release-asset@v1 |
| 191 | + env: |
| 192 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 193 | + with: |
| 194 | + upload_url: ${{ steps.create-release.outputs.upload_url }} |
| 195 | + asset_path: artifacts/ci-lsp-darwin-arm64/ci |
| 196 | + asset_name: ci-lsp-darwin-arm64 |
| 197 | + asset_content_type: application/octet-stream |
| 198 | + |
| 199 | + - name: Purge artifacts |
| 200 | + uses: omarabid-forks/purge-artifacts@v1 |
| 201 | + with: |
| 202 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 203 | + expire-in: 0 |
0 commit comments