Release Ci #26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Ci | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ windows-2025 ] | |
| rust: [ stable ] | |
| steps: | |
| - name: 拉取代码 | |
| uses: actions/checkout@v4 | |
| - name: 设置 Wix 环境 | |
| if: ${{ runner.os == 'Windows' }} | |
| shell: pwsh | |
| run: | | |
| $url = "https://github.com/lingting/wix/releases/download/6.0.1/WixV6.tar.gz" | |
| $path = "${{ runner.temp }}\wix.tar.gz" | |
| Invoke-WebRequest -Uri $url -OutFile $path -UseBasicParsing | |
| tar zxf $path | |
| $wixBinPath = "$(pwd)\WixV6\bin" | |
| $env:Path += ";$wixBinPath" | |
| echo "添加WiX路径到环境变量: $wixBinPath" | |
| wix -version | |
| - name: 缓存 Rust | |
| uses: actions/cache@v4 | |
| id: cache-rust | |
| with: | |
| path: | | |
| ~/.cargo | |
| target | |
| key: rust-${{ runner.os }}-1.88.0 | |
| restore-keys: rust-${{ runner.os }} | |
| - name: 安装 Rust | |
| uses: dtolnay/rust-toolchain@master | |
| if: steps.cache-rust.outputs.cache-hit != 'true' | |
| with: | |
| toolchain: ${{ matrix.rust }} | |
| - name: 安装 Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ~1.24 | |
| cache-dependency-path: | | |
| crates/library-sing-box/go.sum | |
| - name: 拉取UI代码 | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: lingting-projects/rust-nc-ui | |
| path: ui | |
| - name: 安装 Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18.20.3 | |
| cache: 'yarn' | |
| cache-dependency-path: | | |
| ui/yarn.lock | |
| - name: 缓存 Node | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ui/node_modules | |
| key: node-${{ runner.os }}-18.20.3 | |
| restore-keys: node-${{ runner.os }} | |
| - name: 构建项目 | |
| shell: bash | |
| run: | | |
| npm install -g tyarn | |
| if [ -d ui ]; then | |
| cd ui | |
| tyarn install | |
| cd .. | |
| fi | |
| $wixBinPath = "$(pwd)\WixV6\bin" | |
| echo "添加WiX路径到环境变量: $wixBinPath" | |
| $env:Path += ";$wixBinPath" | |
| sh scripts/package.sh -b -t -i -s | |
| mkdir -p artifacts | |
| cp -f target/lingting-nc.tar.gz artifacts/${{ runner.os }}-lingting-nc.tar.gz | |
| if [ -f target/lingting-nc.msi ]; then | |
| cp -f target/lingting-nc.msi artifacts/${{ runner.os }}-lingting-nc.msi | |
| fi | |
| - name: 上传 | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: BUILD | |
| path: artifacts/* | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: 拉取代码 | |
| uses: actions/checkout@v4 | |
| - name: 设置参数 | |
| run: | | |
| VERSION=$(grep "version =" Cargo.toml | head -n 1 | cut -d '"' -f 2) | |
| echo "TAG_NAME=$VERSION" >> $GITHUB_ENV | |
| echo "RELEASE_NAME=$VERSION" >> $GITHUB_ENV | |
| - name: 下载 | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: BUILD | |
| path: artifacts | |
| - name: 发布 | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ env.TAG_NAME }} | |
| name: ${{ env.RELEASE_NAME }} | |
| body: "" | |
| draft: false | |
| prerelease: false | |
| files: | | |
| artifacts/* |