Skip to content

Commit

Permalink
Cargo dist
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkleeman committed Jan 22, 2025
1 parent 82c0da8 commit 21d9261
Show file tree
Hide file tree
Showing 13 changed files with 655 additions and 368 deletions.
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ RUST_TEST_THREADS = "1"
xtask = "run --package xtask --"

[build]
# when changing these please also change .github/workflows/steps/release-build-setup.yml
rustflags = [
"-C", "force-unwind-tables", # Include full unwind tables when aborting on panic
"-C" , "debug-assertions", # Enable debug assertions in release builds to have more safeguards in place
Expand Down
212 changes: 0 additions & 212 deletions .github/workflows/binaries.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: CI

on:
pull_request:
# pull_request is not needed because cargo-dist's plan steps will run on pull_request and that calls ci.yml
workflow_call:
workflow_dispatch:
push:
Expand Down
96 changes: 96 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Build release Docker images

on:
workflow_call:
inputs:
# comes from cargo-dist workflow call
plan:
required: true
type: string

env:
PLAN: ${{ inputs.plan }}

jobs:
build-docker-image:
name: Build server Docker image
uses: ./.github/workflows/docker.yml
secrets: inherit
with:
pushToDockerHub: true
parca: true

docker-cli:
name: Push CLI Docker image
runs-on: ubuntu-latest
env:
REPOSITORY_OWNER: ${{ github.repository_owner }}
GHCR_REGISTRY: "ghcr.io"
GHCR_REGISTRY_USERNAME: ${{ github.actor }}
GHCR_REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IMAGE_NAME: "restate-cli"
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log into GitHub container registry
uses: docker/login-action@v3
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ env.GHCR_REGISTRY_USERNAME }}
password: ${{ env.GHCR_REGISTRY_TOKEN }}

- name: Log into DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Download linux binaries
uses: actions/download-artifact@v4
with:
pattern: artifacts-*-unknown-linux-musl-*
merge-multiple: true

- name: Write release version
id: version
run: |
VERSION="$(echo "$PLAN" | jq -r '[.releases[] | select(.app_name == "restate-cli")][0].app_version')"
echo Version: ${VERSION}
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.GHCR_REGISTRY }}/${{ env.REPOSITORY_OWNER }}/${{ env.IMAGE_NAME }}
${{ format('docker.io/{0}/{1}', env.REPOSITORY_OWNER, env.IMAGE_NAME) }}
tags: |
type=semver,pattern={{version}},value=${{ steps.version.outputs.VERSION }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.version.outputs.VERSION }}
- name: Create Dockerfile
run: |
cat > Dockerfile << 'EOF'
FROM --platform=${BUILDPLATFORM} alpine as builder
ADD restate-cli-aarch64-unknown-linux-musl.tar.xz /restate-arm64
ADD restate-cli-x86_64-unknown-linux-musl.tar.xz /restate-amd64
# keep output image small by removing the server binary
RUN rm /restate-*/restate-server
FROM alpine
ARG TARGETARCH
COPY --from=builder /restate-${TARGETARCH} /
ENTRYPOINT [ "/restate" ]
EOF
- name: Build and push multiplatform image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/arm64,linux/amd64
23 changes: 12 additions & 11 deletions .github/workflows/helm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@ name: Release helm chart
on:
workflow_call:
inputs:
ref:
description: 'ref to build eg v0.8.0'
required: false
type: string
version:
description: 'push helm chart with this version, eg v0.8.0'
# comes from cargo-dist workflow call
plan:
required: true
type: string
workflow_dispatch:
inputs:
ref:
description: 'ref to build eg v0.8.0'
description: "ref to build eg v0.8.0"
required: false
type: string
version:
description: 'push helm chart with this version, eg v0.8.0'
description: "push helm chart with this version, eg 0.8.0"
required: true
type: string

env:
PLAN: '${{ inputs.plan || ''{"releases": [{"app_name": "restate-server", "app_version": "${{ inputs.version }}"}]}'' }}'

jobs:
release-helm-chart:
runs-on: ubuntu-latest
Expand All @@ -31,9 +32,9 @@ jobs:
- name: Write release version
id: version
run: |
VERSION=${{ inputs.version }}
echo Version: ${VERSION#v}
echo "VERSION=${VERSION#v}" >> "$GITHUB_OUTPUT"
VERSION="$(echo "$PLAN" | jq -r '[.releases[] | select(.app_name == "restate-server")][0].app_version')"
echo Version: ${VERSION}
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Check helm versions
run: |
grep -qF 'version: "${{ steps.version.outputs.VERSION }}"' charts/restate-helm/Chart.yaml
Expand Down
Loading

0 comments on commit 21d9261

Please sign in to comment.