|
| 1 | +name: Build and Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'adl-lsp-*' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + name: Build ${{ matrix.target }} |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - target: x86_64-unknown-linux-gnu |
| 21 | + os: ubuntu-latest |
| 22 | + artifact_name: adl-lsp-linux-x64 |
| 23 | + - target: x86_64-apple-darwin |
| 24 | + os: macos-latest |
| 25 | + artifact_name: adl-lsp-macos-x64 |
| 26 | + - target: aarch64-apple-darwin |
| 27 | + os: macos-latest |
| 28 | + artifact_name: adl-lsp-macos-arm64 |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout code |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Install Rust toolchain |
| 35 | + uses: dtolnay/rust-toolchain@1.85.1 |
| 36 | + with: |
| 37 | + targets: ${{ matrix.target }} |
| 38 | + |
| 39 | + - name: Install target |
| 40 | + run: rustup target add ${{ matrix.target }} |
| 41 | + |
| 42 | + - name: Cache dependencies |
| 43 | + uses: actions/cache@v4 |
| 44 | + with: |
| 45 | + path: | |
| 46 | + ~/.cargo/registry |
| 47 | + ~/.cargo/git |
| 48 | + target |
| 49 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 50 | + |
| 51 | + - name: Build binary |
| 52 | + run: | |
| 53 | + cd rust/adl-lsp |
| 54 | + cargo build --release --target ${{ matrix.target }} |
| 55 | + env: |
| 56 | + CARGO_TARGET_DIR: ${{ github.workspace }}/rust/adl-lsp/target |
| 57 | + |
| 58 | + - name: Prepare binary for release |
| 59 | + run: | |
| 60 | + cd rust/adl-lsp |
| 61 | + cp target/${{ matrix.target }}/release/adl-lsp ${{ matrix.artifact_name }} |
| 62 | +
|
| 63 | + - name: Upload binary artifact |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + with: |
| 66 | + name: ${{ matrix.artifact_name }} |
| 67 | + path: rust/adl-lsp/${{ matrix.artifact_name }} |
| 68 | + |
| 69 | + release: |
| 70 | + name: Create Release |
| 71 | + needs: build |
| 72 | + runs-on: ubuntu-latest |
| 73 | + if: startsWith(github.ref, 'refs/tags/adl-lsp-') |
| 74 | + |
| 75 | + steps: |
| 76 | + - name: Checkout code |
| 77 | + uses: actions/checkout@v4 |
| 78 | + |
| 79 | + - name: Extract version from tag |
| 80 | + id: extract_version |
| 81 | + run: | |
| 82 | + # Extract version from tag (e.g., adl-lsp-0.8.2 -> 0.8.2) |
| 83 | + VERSION=${GITHUB_REF#refs/tags/adl-lsp-} |
| 84 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 85 | + echo "Extracted version: $VERSION" |
| 86 | +
|
| 87 | + - name: Download all artifacts |
| 88 | + uses: actions/download-artifact@v4 |
| 89 | + with: |
| 90 | + path: artifacts |
| 91 | + |
| 92 | + - name: Create release |
| 93 | + uses: softprops/action-gh-release@v2 |
| 94 | + with: |
| 95 | + tag_name: ${{ github.ref_name }} |
| 96 | + name: "adl-lsp ${{ steps.extract_version.outputs.version }}" |
| 97 | + files: | |
| 98 | + artifacts/adl-lsp-linux-x64 |
| 99 | + artifacts/adl-lsp-linux-arm64 |
| 100 | + artifacts/adl-lsp-macos-x64 |
| 101 | + artifacts/adl-lsp-macos-arm64 |
| 102 | + generate_release_notes: true |
| 103 | + draft: false |
| 104 | + prerelease: false |
| 105 | + env: |
| 106 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments