Release v0.5.0 (dry run) #28
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 | |
| run-name: "Release ${{ inputs.version }}${{ inputs.dry_run && ' (dry run)' || '' }}" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version to release (e.g. v0.1.0)" | |
| required: true | |
| type: string | |
| dry_run: | |
| description: "Dry run (skip push/publish)" | |
| required: false | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| packages: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| CARGO_INCREMENTAL: 0 | |
| jobs: | |
| validate: | |
| name: "Validate ${{ inputs.version }}" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Verify tag exists | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if ! gh api repos/${{ github.repository }}/git/ref/tags/${{ inputs.version }} &>/dev/null; then | |
| echo "Error: Tag ${{ inputs.version }} does not exist. Run Promote Release first." | |
| exit 1 | |
| fi | |
| build: | |
| name: "Build ${{ matrix.target }} (${{ inputs.version }})" | |
| needs: validate | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.version }} | |
| - name: Install system dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y protobuf-compiler | |
| - name: Install cross-compilation dependencies (Linux aarch64) | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| sudo dpkg --add-architecture arm64 | |
| # Pin all existing sources to amd64 only | |
| sudo sed -i 's/^deb /deb [arch=amd64] /' /etc/apt/sources.list 2>/dev/null || true | |
| sudo sed -i 's/^Types: deb$/Types: deb\nArchitectures: amd64/' /etc/apt/sources.list.d/*.sources 2>/dev/null || true | |
| # Add arm64 sources (only ports.ubuntu.com carries arm64) | |
| CODENAME=$(lsb_release -cs) | |
| cat <<EOF | sudo tee /etc/apt/sources.list.d/arm64.list | |
| deb [arch=arm64] http://ports.ubuntu.com/ ${CODENAME} main restricted universe multiverse | |
| deb [arch=arm64] http://ports.ubuntu.com/ ${CODENAME}-updates main restricted universe multiverse | |
| deb [arch=arm64] http://ports.ubuntu.com/ ${CODENAME}-security main restricted universe multiverse | |
| deb [arch=arm64] http://ports.ubuntu.com/ ${CODENAME}-backports main restricted universe multiverse | |
| EOF | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libssl-dev:arm64 libsqlite3-dev:arm64 | |
| # llama-cpp-sys-4's build script passes the Rust triple as the cmake compiler | |
| # name (aarch64-unknown-linux-gnu-gcc), but Ubuntu ships aarch64-linux-gnu-gcc. | |
| sudo ln -sf /usr/bin/aarch64-linux-gnu-gcc /usr/local/bin/aarch64-unknown-linux-gnu-gcc | |
| sudo ln -sf /usr/bin/aarch64-linux-gnu-g++ /usr/local/bin/aarch64-unknown-linux-gnu-g++ | |
| echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV | |
| echo "PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu" >> $GITHUB_ENV | |
| echo "PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig" >> $GITHUB_ENV | |
| - name: Install system dependencies (macOS) | |
| if: runner.os == 'macOS' | |
| run: brew install protobuf | |
| - name: Free up disk space (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /usr/local/share/boost | |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Install Rust | |
| run: | | |
| rustup toolchain install stable | |
| rustup target add ${{ matrix.target }} | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ matrix.target }} | |
| - name: Build release binary | |
| run: cargo build --release --target ${{ matrix.target }} -p skardi-cli | |
| - name: Package binary (Unix) | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| tar czf ../../../skardi-${{ matrix.target }}.tar.gz skardi | |
| cd ../../.. | |
| shasum -a 256 skardi-${{ matrix.target }}.tar.gz > skardi-${{ matrix.target }}.tar.gz.sha256 | |
| - name: Upload artifact | |
| if: ${{ !inputs.dry_run }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: skardi-${{ matrix.target }} | |
| path: | | |
| skardi-${{ matrix.target }}.tar.gz | |
| skardi-${{ matrix.target }}.tar.gz.sha256 | |
| docker: | |
| name: "Docker ${{ matrix.variant }} (${{ matrix.platform }}, ${{ inputs.version }})" | |
| needs: validate | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - variant: default | |
| features: "" | |
| suffix: "" | |
| platform: linux/amd64 | |
| runner: ubuntu-latest | |
| - variant: default | |
| features: "" | |
| suffix: "" | |
| platform: linux/arm64 | |
| runner: ubuntu-24.04-arm | |
| - variant: rag | |
| features: "rag" | |
| suffix: "-rag" | |
| platform: linux/amd64 | |
| runner: ubuntu-latest | |
| - variant: rag | |
| features: "rag" | |
| suffix: "-rag" | |
| platform: linux/arm64 | |
| runner: ubuntu-24.04-arm | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.version }} | |
| - name: Free up disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /usr/local/share/boost | |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version and repo | |
| id: version | |
| run: | | |
| echo "version=${VERSION#v}" >> $GITHUB_OUTPUT | |
| echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT | |
| PLATFORM="${{ matrix.platform }}" | |
| echo "arch=${PLATFORM#*/}" >> $GITHUB_OUTPUT | |
| env: | |
| VERSION: ${{ inputs.version }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| - name: Build and push Docker image | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: ${{ !inputs.dry_run }} | |
| platforms: ${{ matrix.platform }} | |
| build-args: | | |
| FEATURES=${{ matrix.features }} | |
| provenance: false | |
| tags: | | |
| ghcr.io/${{ steps.version.outputs.repo }}/skardi-server${{ matrix.suffix }}:${{ steps.version.outputs.version }}-${{ steps.version.outputs.arch }} | |
| cache-from: type=gha,scope=${{ matrix.variant }}-${{ steps.version.outputs.arch }} | |
| cache-to: type=gha,mode=max,scope=${{ matrix.variant }}-${{ steps.version.outputs.arch }} | |
| docker-manifest: | |
| name: "Docker Manifest ${{ matrix.variant }} (${{ inputs.version }})" | |
| needs: docker | |
| if: ${{ !inputs.dry_run }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - variant: default | |
| suffix: "" | |
| - variant: rag | |
| suffix: "-rag" | |
| steps: | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version and repo | |
| id: version | |
| run: | | |
| echo "version=${VERSION#v}" >> $GITHUB_OUTPUT | |
| echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT | |
| env: | |
| VERSION: ${{ inputs.version }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| - name: Create and push multi-arch manifest | |
| run: | | |
| IMAGE="ghcr.io/${{ steps.version.outputs.repo }}/skardi-server${{ matrix.suffix }}" | |
| VERSION="${{ steps.version.outputs.version }}" | |
| docker manifest create "${IMAGE}:${VERSION}" \ | |
| "${IMAGE}:${VERSION}-amd64" \ | |
| "${IMAGE}:${VERSION}-arm64" | |
| docker manifest push "${IMAGE}:${VERSION}" | |
| docker manifest create "${IMAGE}:latest" \ | |
| "${IMAGE}:${VERSION}-amd64" \ | |
| "${IMAGE}:${VERSION}-arm64" | |
| docker manifest push "${IMAGE}:latest" | |
| publish: | |
| name: "Publish to crates.io (${{ inputs.version }})" | |
| needs: validate | |
| runs-on: ubuntu-latest | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.version }} | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y protobuf-compiler | |
| - name: Install Rust | |
| run: rustup toolchain install stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Publish skardi | |
| run: cargo publish -p skardi ${{ inputs.dry_run && '--dry-run' || '' }} | |
| # skardi-sources is not published yet: it depends on lance via git which crates.io disallows. | |
| # Once lance v4 is stable on crates.io, replace the git deps in Cargo.toml, add it to | |
| # the skardi facade crate, and publish with: | |
| # cargo publish -p skardi-sources (before cargo publish -p skardi) | |
| release: | |
| name: "Create Release (${{ inputs.version }})" | |
| needs: [build, docker-manifest] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download CLI artifacts | |
| if: ${{ !inputs.dry_run }} | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| pattern: skardi-* | |
| merge-multiple: true | |
| - name: Create GitHub Release | |
| if: ${{ !inputs.dry_run }} | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ inputs.version }} | |
| generate_release_notes: true | |
| files: | | |
| artifacts/* | |
| - name: Dry run summary | |
| if: ${{ inputs.dry_run }} | |
| run: echo "Dry run complete. All build steps passed for ${{ inputs.version }}. No artifacts were pushed or published." |