|
| 1 | +name: Rust |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - "*" |
| 9 | + pull_request: |
| 10 | + types: [opened, synchronize, reopened] |
| 11 | + branches: |
| 12 | + - main |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu, platform: linux-x64, cross: general } |
| 21 | + - { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu, platform: linux-x64, cross: zigbuild, glibc: 2.17 } |
| 22 | + - { os: ubuntu-22.04, target: aarch64-unknown-linux-gnu, platform: linux-arm64, cross: zigbuild, glibc: 2.17 } |
| 23 | + - { os: ubuntu-22.04, target: riscv64gc-unknown-linux-gnu, platform: linux-riscv64,cross: cross } |
| 24 | + - { os: ubuntu-22.04, target: x86_64-unknown-linux-musl, platform: linux-musl, cross: cross } |
| 25 | + - { os: macos-latest, target: x86_64-apple-darwin, platform: darwin-x64, cross: general-macos-intel } |
| 26 | + - { os: macos-latest, target: aarch64-apple-darwin, platform: darwin-arm64, cross: general } |
| 27 | + - { os: windows-latest, target: x86_64-pc-windows-msvc, platform: win32-x64, cross: general } |
| 28 | + - { os: windows-latest, target: i686-pc-windows-msvc, platform: win32-ia32, cross: general } |
| 29 | + - { os: windows-latest, target: aarch64-pc-windows-msvc, platform: win32-arm64, cross: general } |
| 30 | + runs-on: ${{ matrix.os }} |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + submodules: recursive |
| 35 | + - name: Install Rust toolchain |
| 36 | + uses: dtolnay/rust-toolchain@stable |
| 37 | + - name: edit version |
| 38 | + if: startsWith(github.ref, 'refs/tags/') |
| 39 | + run: | |
| 40 | + echo "current ref ${{ github.ref }}" |
| 41 | + cargo run -p edit_version -- ${{ github.ref }} |
| 42 | + - name: Build - General |
| 43 | + if: ${{ matrix.cross == 'general' }} |
| 44 | + run: | |
| 45 | + rustup target add ${{ matrix.target }} |
| 46 | + cargo build --release --target ${{ matrix.target }} |
| 47 | + - name: Build - cross |
| 48 | + if: ${{ matrix.cross == 'cross' }} |
| 49 | + run: | |
| 50 | + cargo install cross |
| 51 | + cross build --release --target ${{ matrix.target }} |
| 52 | + - name: Build -zigbuild |
| 53 | + if: ${{ matrix.cross == 'zigbuild' }} |
| 54 | + run: | |
| 55 | + rustup target add ${{ matrix.target }} |
| 56 | + cargo install --locked cargo-zigbuild |
| 57 | + pip3 install ziglang |
| 58 | + cargo zigbuild --release --target ${{ matrix.target }}.${{ matrix.glibc }} |
| 59 | + - name: Build - general macos-intel |
| 60 | + if: ${{ matrix.cross == 'general-macos-intel' }} |
| 61 | + run: | |
| 62 | + rustup target add ${{ matrix.target }} |
| 63 | + cargo build --release --target ${{ matrix.target }} |
| 64 | + otool -l ./target/${{ matrix.target }}/release/emmylua_dap | grep -A4 "LC_BUILD_VERSION\|LC_VERSION_MIN_MACOSX" |
| 65 | + - name: copy-binary |
| 66 | + if: ${{ matrix.os != 'windows-latest' }} |
| 67 | + run: | |
| 68 | + mkdir -p ${{ github.workspace }}/artifact/ |
| 69 | + cp ${{ github.workspace }}/target/${{ matrix.target }}/release/emmylua_dap ${{ github.workspace }}/artifact/ |
| 70 | + - name: copy-binary-windows |
| 71 | + if: ${{ matrix.os == 'windows-latest' }} |
| 72 | + run: | |
| 73 | + mkdir -p ${{ github.workspace }}/artifact/ |
| 74 | + cp ${{ github.workspace }}/target/${{ matrix.target }}/release/emmylua_dap.exe ${{ github.workspace }}/artifact/ |
| 75 | + shell: pwsh |
| 76 | + - name: Upload |
| 77 | + if: ${{ matrix.cross != 'zigbuild' }} |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: emmylua_dap-${{ matrix.platform }} |
| 81 | + path: ${{ github.workspace }}/artifact/ |
| 82 | + - name: Upload zigbuild |
| 83 | + if: ${{ matrix.cross == 'zigbuild' }} |
| 84 | + uses: actions/upload-artifact@v4 |
| 85 | + with: |
| 86 | + name: emmylua_dap-${{ matrix.platform }}-glibc.${{ matrix.glibc }} |
| 87 | + path: ${{ github.workspace }}/artifact/ |
| 88 | + release: |
| 89 | + needs: build |
| 90 | + runs-on: ubuntu-latest |
| 91 | + if: startsWith(github.ref, 'refs/tags/') |
| 92 | + steps: |
| 93 | + - name: Download |
| 94 | + uses: actions/download-artifact@v4 |
| 95 | + - name: add execute permission and compress |
| 96 | + run: | |
| 97 | + chmod +x emmylua_dap-linux-x64/emmylua_dap |
| 98 | + chmod +x emmylua_dap-linux-x64-glibc.2.17/emmylua_dap |
| 99 | + chmod +x emmylua_dap-linux-arm64-glibc.2.17/emmylua_dap |
| 100 | + chmod +x emmylua_dap-linux-musl/emmylua_dap |
| 101 | + chmod +x emmylua_dap-linux-riscv64/emmylua_dap |
| 102 | + chmod +x emmylua_dap-darwin-x64/emmylua_dap |
| 103 | + chmod +x emmylua_dap-darwin-arm64/emmylua_dap |
| 104 | +
|
| 105 | + tar -zcvf emmylua_dap-linux-x64.tar.gz -C emmylua_dap-linux-x64 emmylua_dap |
| 106 | + tar -zcvf emmylua_dap-linux-x64-glibc.2.17.tar.gz -C emmylua_dap-linux-x64-glibc.2.17 emmylua_dap |
| 107 | + tar -zcvf emmylua_dap-linux-aarch64-glibc.2.17.tar.gz -C emmylua_dap-linux-arm64-glibc.2.17 emmylua_dap |
| 108 | + tar -zcvf emmylua_dap-linux-musl.tar.gz -C emmylua_dap-linux-musl emmylua_dap |
| 109 | + tar -zcvf emmylua_dap-linux-riscv64.tar.gz -C emmylua_dap-linux-riscv64 emmylua_dap |
| 110 | + tar -zcvf emmylua_dap-darwin-x64.tar.gz -C emmylua_dap-darwin-x64 emmylua_dap |
| 111 | + tar -zcvf emmylua_dap-darwin-arm64.tar.gz -C emmylua_dap-darwin-arm64 emmylua_dap |
| 112 | + - name: windows compress |
| 113 | + run: | |
| 114 | + cd emmylua_dap-win32-x64 |
| 115 | + 7z a emmylua_dap-win32-x64.zip emmylua_dap.exe |
| 116 | + cd ../emmylua_dap-win32-ia32 |
| 117 | + 7z a emmylua_dap-win32-ia32.zip emmylua_dap.exe |
| 118 | + cd ../emmylua_dap-win32-arm64 |
| 119 | + 7z a emmylua_dap-win32-arm64.zip emmylua_dap.exe |
| 120 | + - name: Release |
| 121 | + uses: softprops/action-gh-release@v2 |
| 122 | + with: |
| 123 | + name: emmylua_dap |
| 124 | + draft: false |
| 125 | + generate_release_notes: true |
| 126 | + files: | |
| 127 | + emmylua_dap-win32-x64/emmylua_dap-win32-x64.zip |
| 128 | + emmylua_dap-win32-ia32/emmylua_dap-win32-ia32.zip |
| 129 | + emmylua_dap-win32-arm64/emmylua_dap-win32-arm64.zip |
| 130 | + emmylua_dap-linux-x64.tar.gz |
| 131 | + emmylua_dap-linux-x64-glibc.2.17.tar.gz |
| 132 | + emmylua_dap-linux-aarch64-glibc.2.17.tar.gz |
| 133 | + emmylua_dap-linux-musl.tar.gz |
| 134 | + emmylua_dap-linux-riscv64.tar.gz |
| 135 | + emmylua_dap-darwin-x64.tar.gz |
| 136 | + emmylua_dap-darwin-arm64.tar.gz |
| 137 | + token: ${{ secrets.RELEASE }} |
0 commit comments