ci(release): upgrade Ubuntu runner from 20.04 to 22.04 #9
Workflow file for this run
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 | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: '版本号 (例如: v1.0.0)' | |
| required: true | |
| type: string | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| include: | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| artifact: llbot.exe | |
| npm_pkg: llbot-cli-win-x64 | |
| - os: ubuntu-22.04 | |
| target: x86_64-unknown-linux-gnu | |
| artifact: llbot | |
| npm_pkg: llbot-cli-linux-x64 | |
| - os: ubuntu-22.04 | |
| target: aarch64-unknown-linux-gnu | |
| artifact: llbot | |
| npm_pkg: llbot-cli-linux-arm64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install cross-compilation tools | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu | |
| - name: Build | |
| run: cargo build --release --target ${{ matrix.target }} | |
| env: | |
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
| - name: Prepare artifact | |
| shell: bash | |
| run: | | |
| mkdir -p dist | |
| cp target/${{ matrix.target }}/release/${{ matrix.artifact }} dist/ | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.npm_pkg }} | |
| path: dist/${{ matrix.artifact }} | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Prepare release files | |
| run: | | |
| mkdir -p release | |
| cp artifacts/llbot-cli-win-x64/llbot.exe release/llbot-win-x64.exe | |
| cp artifacts/llbot-cli-linux-x64/llbot release/llbot-linux-x64 | |
| cp artifacts/llbot-cli-linux-arm64/llbot release/llbot-linux-arm64 | |
| chmod +x release/llbot-linux-x64 release/llbot-linux-arm64 | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ inputs.tag || github.ref_name }} | |
| name: LLBot CLI ${{ inputs.tag || github.ref_name }} | |
| generate_release_notes: true | |
| draft: true | |
| files: release/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Node.js | |
| if: github.event_name == 'push' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Update npm | |
| if: github.event_name == 'push' | |
| run: npm install -g npm@latest | |
| - name: Publish npm packages | |
| if: github.event_name == 'push' | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| REPO='{"type":"git","url":"https://github.com/LLOneBot/LuckyLillia.CLI"}' | |
| # win-x64 | |
| mkdir -p package | |
| cp artifacts/llbot-cli-win-x64/llbot.exe package/ | |
| echo '{"name":"llbot-cli-win-x64","version":"'$VERSION'","description":"LLBot CLI for Windows x64","repository":'"$REPO"'}' > package/package.json | |
| tar -czf llbot-cli-win-x64.tgz package | |
| npm publish llbot-cli-win-x64.tgz --provenance --access public | |
| rm -rf package | |
| # linux-x64 | |
| mkdir -p package | |
| cp artifacts/llbot-cli-linux-x64/llbot package/ | |
| echo '{"name":"llbot-cli-linux-x64","version":"'$VERSION'","description":"LLBot CLI for Linux x64","repository":'"$REPO"'}' > package/package.json | |
| tar -czf llbot-cli-linux-x64.tgz package | |
| npm publish llbot-cli-linux-x64.tgz --provenance --access public | |
| rm -rf package | |
| # linux-arm64 | |
| mkdir -p package | |
| cp artifacts/llbot-cli-linux-arm64/llbot package/ | |
| echo '{"name":"llbot-cli-linux-arm64","version":"'$VERSION'","description":"LLBot CLI for Linux arm64","repository":'"$REPO"'}' > package/package.json | |
| tar -czf llbot-cli-linux-arm64.tgz package | |
| npm publish llbot-cli-linux-arm64.tgz --provenance --access public |