Skip to content

Release

Release #3

Workflow file for this run

name: Release
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: write
packages: write
env:
REGISTRY: ghcr.io
jobs:
release:
name: Build and publish release assets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Derive metadata
id: meta
run: |
if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
else
echo "version=0.0.0-dev.$GITHUB_SHA" >> "$GITHUB_OUTPUT"
echo "tag=dev" >> "$GITHUB_OUTPUT"
fi
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push operator image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/${{ github.repository }}:${{ steps.meta.outputs.tag }}
${{ env.REGISTRY }}/${{ github.repository }}:latest
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.version=${{ steps.meta.outputs.version }}
- name: Build and push deployer image
uses: docker/build-push-action@v6
with:
context: .
file: deployer.Dockerfile
push: true
tags: |
${{ env.REGISTRY }}/${{ github.repository }}-deployer:${{ steps.meta.outputs.tag }}
${{ env.REGISTRY }}/${{ github.repository }}-deployer:latest
- name: Build plugin for all platforms
run: |
mkdir -p dist
for target in \
linux/amd64 linux/arm64 \
darwin/amd64 darwin/arm64; do
os="${target%/*}"; arch="${target#*/}"
CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" \
go build -trimpath -ldflags "-s -w -X github.com/anthaathi/celld-deploy/internal/cli.version=${{ steps.meta.outputs.version }}" \
-o "dist/kubectl-celld_${os}_${arch}" \
./cmd/kubectl-celld
(cd dist && sha256sum "kubectl-celld_${os}_${arch}" > "kubectl-celld_${os}_${arch}.sha256")
done
ls -la dist/
- name: Generate versioned install manifest
run: |
VERSION="${{ steps.meta.outputs.tag }}"
mkdir -p dist
sed "s|image: celld-operator:poc|image: ${REGISTRY}/${GITHUB_REPOSITORY}:${VERSION}|" \
config/manager/manager.yaml > dist/install-operator.yaml.example
# Also verify the operator image is digest-pinnable in the manifest
grep -q "image: " dist/install-operator.yaml.example
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
dist/*