|
| 1 | +name: Build Mago with Language Server |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Check for a new upstream release every day at 06:00 UTC |
| 6 | + - cron: '0 6 * * *' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: 'Mago version tag to build (e.g. 1.29.0). Leave empty to use latest.' |
| 11 | + required: false |
| 12 | + default: '' |
| 13 | + |
| 14 | +jobs: |
| 15 | + # ─── Phase 1: decide whether anything needs building ───────────────────────── |
| 16 | + check: |
| 17 | + name: Check upstream release |
| 18 | + runs-on: ubuntu-latest |
| 19 | + outputs: |
| 20 | + version: ${{ steps.resolve.outputs.version }} |
| 21 | + should_build: ${{ steps.compare.outputs.should_build }} |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Resolve target version |
| 25 | + id: resolve |
| 26 | + env: |
| 27 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 28 | + run: | |
| 29 | + if [[ -n "${{ inputs.version }}" ]]; then |
| 30 | + VERSION="${{ inputs.version }}" |
| 31 | + else |
| 32 | + VERSION=$(gh api repos/carthage-software/mago/releases/latest --jq '.tag_name') |
| 33 | + fi |
| 34 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 35 | + echo "Targeting mago ${VERSION}" |
| 36 | +
|
| 37 | + - name: Check if this version is already released here |
| 38 | + id: compare |
| 39 | + env: |
| 40 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + run: | |
| 42 | + VERSION="${{ steps.resolve.outputs.version }}" |
| 43 | + STATUS=$(gh api \ |
| 44 | + "repos/${{ github.repository }}/releases/tags/${VERSION}" \ |
| 45 | + --silent 2>&1 && echo "exists" || echo "missing") |
| 46 | + if [[ "$STATUS" == "exists" ]]; then |
| 47 | + echo "Release ${VERSION} already exists — skipping build." |
| 48 | + echo "should_build=false" >> "$GITHUB_OUTPUT" |
| 49 | + else |
| 50 | + echo "Release ${VERSION} not found — will build." |
| 51 | + echo "should_build=true" >> "$GITHUB_OUTPUT" |
| 52 | + fi |
| 53 | +
|
| 54 | + # ─── Phase 2: compile for every target ─────────────────────────────────────── |
| 55 | + build: |
| 56 | + name: ${{ matrix.job.target }} |
| 57 | + runs-on: ${{ matrix.job.os }} |
| 58 | + needs: check |
| 59 | + if: needs.check.outputs.should_build == 'true' |
| 60 | + |
| 61 | + env: |
| 62 | + VERSION: ${{ needs.check.outputs.version }} |
| 63 | + BUILD_CMD: cargo |
| 64 | + |
| 65 | + strategy: |
| 66 | + fail-fast: false |
| 67 | + matrix: |
| 68 | + job: |
| 69 | + # Tier 1 — native runners, no cross-compilation needed |
| 70 | + - { target: x86_64-pc-windows-msvc, os: windows-latest } |
| 71 | + - { target: aarch64-apple-darwin, os: macos-latest } |
| 72 | + - { target: x86_64-apple-darwin, os: macos-latest } |
| 73 | + |
| 74 | + # Linux — cross-compiled via cross-rs (pure-Rust feature, no extra syslibs needed) |
| 75 | + - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest, use_cross: true } |
| 76 | + - { target: x86_64-unknown-linux-musl, os: ubuntu-latest, use_cross: true } |
| 77 | + - { target: aarch64-unknown-linux-gnu, os: ubuntu-latest, use_cross: true } |
| 78 | + - { target: aarch64-unknown-linux-musl, os: ubuntu-latest, use_cross: true } |
| 79 | + - { target: arm-unknown-linux-gnueabi, os: ubuntu-latest, use_cross: true } |
| 80 | + - { target: arm-unknown-linux-gnueabihf, os: ubuntu-latest, use_cross: true } |
| 81 | + - { target: arm-unknown-linux-musleabi, os: ubuntu-latest, use_cross: true } |
| 82 | + - { target: arm-unknown-linux-musleabihf, os: ubuntu-latest, use_cross: true } |
| 83 | + - { target: armv7-unknown-linux-gnueabihf, os: ubuntu-latest, use_cross: true } |
| 84 | + - { target: armv7-unknown-linux-musleabihf, os: ubuntu-latest, use_cross: true } |
| 85 | + |
| 86 | + # Tier 2 |
| 87 | + - { target: x86_64-pc-windows-gnu, os: windows-latest } |
| 88 | + - { target: x86_64-unknown-freebsd, os: ubuntu-latest, use_cross: true } |
| 89 | + |
| 90 | + steps: |
| 91 | + - name: Checkout mago ${{ env.VERSION }} |
| 92 | + uses: actions/checkout@v4 |
| 93 | + with: |
| 94 | + repository: carthage-software/mago |
| 95 | + ref: ${{ env.VERSION }} |
| 96 | + |
| 97 | + - name: Install Rust toolchain |
| 98 | + uses: dtolnay/rust-toolchain@stable |
| 99 | + with: |
| 100 | + targets: ${{ matrix.job.target }} |
| 101 | + |
| 102 | + - name: Cache Rust dependencies |
| 103 | + uses: Swatinem/rust-cache@v2 |
| 104 | + with: |
| 105 | + # Version in key so each mago release gets a warm-but-isolated cache |
| 106 | + key: lsp-${{ matrix.job.target }}-${{ env.VERSION }} |
| 107 | + cache-on-failure: true |
| 108 | + |
| 109 | + - name: Install cross |
| 110 | + if: matrix.job.use_cross |
| 111 | + uses: taiki-e/install-action@v2 |
| 112 | + with: |
| 113 | + tool: cross |
| 114 | + |
| 115 | + - name: Switch build command to cross |
| 116 | + if: matrix.job.use_cross |
| 117 | + shell: bash |
| 118 | + run: echo "BUILD_CMD=cross" >> "$GITHUB_ENV" |
| 119 | + |
| 120 | + - name: Build with language-server feature |
| 121 | + shell: bash |
| 122 | + run: | |
| 123 | + $BUILD_CMD build \ |
| 124 | + --locked \ |
| 125 | + --release \ |
| 126 | + --target ${{ matrix.job.target }} \ |
| 127 | + --features language-server |
| 128 | +
|
| 129 | + - name: Package binary |
| 130 | + id: package |
| 131 | + shell: bash |
| 132 | + run: | |
| 133 | + TARGET="${{ matrix.job.target }}" |
| 134 | + EXE="" |
| 135 | + PKG_EXT=".tar.gz" |
| 136 | + case "$TARGET" in |
| 137 | + *-pc-windows-msvc) EXE=".exe"; PKG_EXT=".zip" ;; |
| 138 | + *-pc-windows-*) EXE=".exe" ;; |
| 139 | + esac |
| 140 | +
|
| 141 | + BIN="target/${TARGET}/release/mago${EXE}" |
| 142 | + PKG_NAME="mago-lsp-${VERSION}-${TARGET}${PKG_EXT}" |
| 143 | +
|
| 144 | + mkdir -p staging |
| 145 | + cp "$BIN" "staging/mago${EXE}" |
| 146 | +
|
| 147 | + pushd staging |
| 148 | + case "$PKG_EXT" in |
| 149 | + .zip) 7z a "$PKG_NAME" "mago${EXE}" ;; |
| 150 | + .tar.gz) tar czf "$PKG_NAME" "mago${EXE}" ;; |
| 151 | + esac |
| 152 | + popd |
| 153 | +
|
| 154 | + echo "PKG_NAME=${PKG_NAME}" >> "$GITHUB_OUTPUT" |
| 155 | + echo "PKG_PATH=staging/${PKG_NAME}" >> "$GITHUB_OUTPUT" |
| 156 | +
|
| 157 | + - name: Upload artifact |
| 158 | + uses: actions/upload-artifact@v4 |
| 159 | + with: |
| 160 | + name: ${{ steps.package.outputs.PKG_NAME }} |
| 161 | + path: ${{ steps.package.outputs.PKG_PATH }} |
| 162 | + |
| 163 | + # ─── Phase 3: publish a release with all binaries ──────────────────────────── |
| 164 | + release: |
| 165 | + name: Publish GitHub release |
| 166 | + runs-on: ubuntu-latest |
| 167 | + needs: [check, build] |
| 168 | + if: needs.check.outputs.should_build == 'true' |
| 169 | + permissions: |
| 170 | + contents: write |
| 171 | + |
| 172 | + steps: |
| 173 | + - name: Download all build artifacts |
| 174 | + uses: actions/download-artifact@v4 |
| 175 | + with: |
| 176 | + path: artifacts/ |
| 177 | + merge-multiple: true |
| 178 | + |
| 179 | + - name: Create release |
| 180 | + uses: softprops/action-gh-release@v2 |
| 181 | + with: |
| 182 | + tag_name: ${{ needs.check.outputs.version }} |
| 183 | + name: "mago ${{ needs.check.outputs.version }} (language-server)" |
| 184 | + # Mark pre-release: the LSP feature has no stability guarantees before mago 2.0 |
| 185 | + prerelease: true |
| 186 | + body: | |
| 187 | + Mago `${{ needs.check.outputs.version }}` compiled with `--features language-server`. |
| 188 | +
|
| 189 | + > **Stability notice:** The Mago language server is an unstable, feature-gated preview. Its |
| 190 | + > advertised capabilities, wire protocol, and CLI flags may change or be removed without |
| 191 | + > notice before Mago 2.0. There are no compatibility guarantees until that release. |
| 192 | +
|
| 193 | + ## Installation |
| 194 | +
|
| 195 | + 1. Download the archive for your platform and extract the `mago` binary. |
| 196 | + 2. Place it somewhere on your `PATH` (or note its full path). |
| 197 | + 3. In VS Code, set `mago.executablePath` to the path of this binary. |
| 198 | +
|
| 199 | + ## Platforms |
| 200 | +
|
| 201 | + | Archive | Platform | |
| 202 | + |---|---| |
| 203 | + | `mago-lsp-*-x86_64-pc-windows-msvc.zip` | Windows x64 (MSVC) | |
| 204 | + | `mago-lsp-*-x86_64-pc-windows-gnu.tar.gz` | Windows x64 (MinGW) | |
| 205 | + | `mago-lsp-*-aarch64-apple-darwin.tar.gz` | macOS Apple Silicon | |
| 206 | + | `mago-lsp-*-x86_64-apple-darwin.tar.gz` | macOS Intel | |
| 207 | + | `mago-lsp-*-x86_64-unknown-linux-gnu.tar.gz` | Linux x64 (glibc) | |
| 208 | + | `mago-lsp-*-x86_64-unknown-linux-musl.tar.gz` | Linux x64 (musl, static) | |
| 209 | + | `mago-lsp-*-aarch64-unknown-linux-gnu.tar.gz` | Linux ARM64 (glibc) | |
| 210 | + | `mago-lsp-*-aarch64-unknown-linux-musl.tar.gz` | Linux ARM64 (musl, static) | |
| 211 | + | `mago-lsp-*-x86_64-unknown-freebsd.tar.gz` | FreeBSD x64 | |
| 212 | + | *(arm/armv7 archives)* | Raspberry Pi / embedded Linux | |
| 213 | +
|
| 214 | + ## Upstream |
| 215 | +
|
| 216 | + Full changelog and release notes: [carthage-software/mago@${{ needs.check.outputs.version }}](https://github.com/carthage-software/mago/releases/tag/${{ needs.check.outputs.version }}) |
| 217 | + files: artifacts/* |
| 218 | + env: |
| 219 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments