|
| 1 | +name: lsp-release |
| 2 | + |
| 3 | +# Builds prebuilt `sqlshield-lsp` binaries and attaches them to the |
| 4 | +# matching `sqlshield-lsp-vX.Y.Z` GitHub Release. The Zed extension's |
| 5 | +# download fallback expects asset names of the form |
| 6 | +# `sqlshield-lsp-{rust-target}.{tar.gz|zip}`. |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + tags: ['sqlshield-lsp-v*'] |
| 11 | + workflow_dispatch: |
| 12 | + inputs: |
| 13 | + tag: |
| 14 | + description: 'Existing tag to attach assets to (e.g. sqlshield-lsp-v0.0.2)' |
| 15 | + required: true |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: write |
| 19 | + |
| 20 | +jobs: |
| 21 | + build: |
| 22 | + name: build (${{ matrix.target.rust }}) |
| 23 | + runs-on: ${{ matrix.target.runner }} |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + target: |
| 28 | + - { runner: ubuntu-latest, rust: x86_64-unknown-linux-gnu, use_cross: false } |
| 29 | + - { runner: ubuntu-latest, rust: aarch64-unknown-linux-gnu, use_cross: true } |
| 30 | + - { runner: macos-14, rust: aarch64-apple-darwin, use_cross: false } |
| 31 | + - { runner: macos-14, rust: x86_64-apple-darwin, use_cross: false } |
| 32 | + - { runner: windows-latest, rust: x86_64-pc-windows-msvc, use_cross: false } |
| 33 | + - { runner: windows-latest, rust: aarch64-pc-windows-msvc, use_cross: false } |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v4 |
| 36 | + |
| 37 | + - uses: dtolnay/rust-toolchain@stable |
| 38 | + |
| 39 | + - name: Add rust target |
| 40 | + shell: bash |
| 41 | + run: rustup target add ${{ matrix.target.rust }} |
| 42 | + |
| 43 | + - uses: Swatinem/rust-cache@v2 |
| 44 | + with: |
| 45 | + key: lsp-release-${{ matrix.target.rust }} |
| 46 | + |
| 47 | + - name: Install cross |
| 48 | + if: matrix.target.use_cross |
| 49 | + run: cargo install cross --locked |
| 50 | + |
| 51 | + - name: Build (cross) |
| 52 | + if: matrix.target.use_cross |
| 53 | + run: cross build -p sqlshield-lsp --release --target ${{ matrix.target.rust }} |
| 54 | + |
| 55 | + - name: Build (native) |
| 56 | + if: ${{ !matrix.target.use_cross }} |
| 57 | + run: cargo build -p sqlshield-lsp --release --target ${{ matrix.target.rust }} |
| 58 | + |
| 59 | + - name: Package |
| 60 | + shell: bash |
| 61 | + run: | |
| 62 | + mkdir -p dist |
| 63 | + target=${{ matrix.target.rust }} |
| 64 | + if [[ "${{ runner.os }}" == "Windows" ]]; then |
| 65 | + cp target/$target/release/sqlshield-lsp.exe sqlshield-lsp.exe |
| 66 | + 7z a -tzip dist/sqlshield-lsp-$target.zip sqlshield-lsp.exe |
| 67 | + else |
| 68 | + cp target/$target/release/sqlshield-lsp sqlshield-lsp |
| 69 | + chmod +x sqlshield-lsp |
| 70 | + tar -czf dist/sqlshield-lsp-$target.tar.gz sqlshield-lsp |
| 71 | + fi |
| 72 | +
|
| 73 | + - uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: sqlshield-lsp-${{ matrix.target.rust }} |
| 76 | + path: dist/* |
| 77 | + if-no-files-found: error |
| 78 | + |
| 79 | + upload: |
| 80 | + name: upload assets |
| 81 | + needs: build |
| 82 | + runs-on: ubuntu-latest |
| 83 | + steps: |
| 84 | + - uses: actions/download-artifact@v4 |
| 85 | + with: |
| 86 | + path: dist |
| 87 | + pattern: sqlshield-lsp-* |
| 88 | + merge-multiple: true |
| 89 | + |
| 90 | + - name: Compute release tag |
| 91 | + id: tag |
| 92 | + run: | |
| 93 | + if [[ -n "${{ inputs.tag }}" ]]; then |
| 94 | + echo "ref=${{ inputs.tag }}" >> "$GITHUB_OUTPUT" |
| 95 | + else |
| 96 | + echo "ref=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" |
| 97 | + fi |
| 98 | +
|
| 99 | + - uses: softprops/action-gh-release@v2 |
| 100 | + with: |
| 101 | + tag_name: ${{ steps.tag.outputs.ref }} |
| 102 | + files: dist/* |
| 103 | + fail_on_unmatched_files: true |
0 commit comments