Merge pull request #22 from KonghaYao/perf/history-copy #49
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 Agent | |
| on: | |
| push: | |
| tags: | |
| - "agent-v*" | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| name: Build (${{ matrix.target }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| platform: linux-x86_64 | |
| ext: "" | |
| - os: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| platform: linux-aarch64 | |
| ext: "" | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| platform: macos-x86_64 | |
| ext: "" | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| platform: macos-aarch64 | |
| ext: "" | |
| - os: ubuntu-latest | |
| target: riscv64gc-unknown-linux-gnu | |
| platform: linux-riscv64 | |
| ext: "" | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| platform: windows-x86_64 | |
| ext: ".exe" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set version from tag | |
| shell: bash | |
| run: | | |
| VERSION="${GITHUB_REF_NAME#agent-v}" | |
| echo "Setting version to ${VERSION}" | |
| sed -i.bak -e "s/^version = \".*\"/version = \"${VERSION}\"/" Cargo.toml | |
| rm -f Cargo.toml.bak | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry/index | |
| ~/.cargo/registry/cache | |
| ~/.cargo/git/db | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: ${{ runner.os }}-cargo- | |
| - name: Cache build artifacts | |
| uses: actions/cache@v4 | |
| with: | |
| path: target | |
| key: ${{ runner.os }}-${{ matrix.target }}-build-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ matrix.target }}-build- | |
| ${{ runner.os }}-${{ matrix.target }}- | |
| - name: Install cross | |
| if: runner.os == 'Linux' | |
| run: cargo install cross | |
| - name: Build agent-tui (Linux) | |
| if: runner.os == 'Linux' | |
| run: cross build -p peri-tui --release --target ${{ matrix.target }} | |
| - name: Build agent-tui (non-Linux) | |
| if: runner.os != 'Linux' | |
| run: cargo build -p peri-tui --release --target ${{ matrix.target }} | |
| - name: Package binaries (Unix) | |
| if: matrix.ext == '' | |
| run: | | |
| mkdir -p dist | |
| cp target/${{ matrix.target }}/release/peri dist/peri-${{ matrix.platform }} | |
| chmod +x dist/peri-${{ matrix.platform }} | |
| tar -czf dist/peri-${{ matrix.platform }}.tar.gz -C dist peri-${{ matrix.platform }} | |
| rm dist/peri-${{ matrix.platform }} | |
| - name: Package binaries (Windows) | |
| if: matrix.ext == '.exe' | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force -Path dist | |
| Copy-Item "target/${{ matrix.target }}/release/peri.exe" "dist/peri-${{ matrix.platform }}.exe" | |
| Compress-Archive -Path "dist/peri-${{ matrix.platform }}.exe" -DestinationPath "dist/peri-${{ matrix.platform }}.zip" | |
| Remove-Item "dist/peri-${{ matrix.platform }}.exe" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries-${{ matrix.platform }} | |
| path: dist/ | |
| retention-days: 7 | |
| release: | |
| name: Create GitHub Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts/ | |
| merge-multiple: true | |
| - name: List artifacts | |
| run: ls -lR artifacts/ | |
| - name: Generate checksums | |
| run: | | |
| cd artifacts | |
| sha256sum * > checksums.txt | |
| cat checksums.txt | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| artifacts/* | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: ${{ contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-rc') }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |