diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..22db3a4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,101 @@ +name: Release + +on: + push: + tags: + - 'v*.*.*' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.24' + + - name: Set environment variables + run: | + # Strip 'v' prefix from tag name for version + VERSION=${GITHUB_REF#refs/tags/v} + echo "VERSION=${VERSION}" >> $GITHUB_ENV + echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: ./kubechain + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + platforms: linux/amd64,linux/arm64 + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Install Kustomize + run: | + cd kubechain + make kustomize + + - name: Generate release manifests + run: | + cd kubechain + mkdir -p config/release + + # Set the image to the versioned image + cd config/manager && ../../bin/kustomize edit set image controller=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} + cd ../.. + + # Generate the full installation manifest + bin/kustomize build config/default > config/release/v${{ env.VERSION }}.yaml + + # Generate CRD-only manifest + bin/kustomize build config/crd > config/release/v${{ env.VERSION }}-crd.yaml + + # Also update the latest manifests + cp config/release/v${{ env.VERSION }}.yaml config/release/latest.yaml + cp config/release/v${{ env.VERSION }}-crd.yaml config/release/latest-crd.yaml + + - name: Create Release + id: create_release + uses: softprops/action-gh-release@v1 + with: + name: Release ${{ env.TAG }} + draft: false + prerelease: false + files: | + kubechain/config/release/v${{ env.VERSION }}.yaml + kubechain/config/release/v${{ env.VERSION }}-crd.yaml + + - name: Commit updated release manifests + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add kubechain/config/release/v${{ env.VERSION }}.yaml + git add kubechain/config/release/v${{ env.VERSION }}-crd.yaml + git add kubechain/config/release/latest.yaml + git add kubechain/config/release/latest-crd.yaml + git commit -m "chore: update release manifests for ${{ env.TAG }}" + git push \ No newline at end of file diff --git a/Makefile b/Makefile index bc3c90b..d5feda8 100644 --- a/Makefile +++ b/Makefile @@ -99,5 +99,5 @@ clean-all: undeploy-samples undeploy-operator undeploy-otel cluster-down ## Clea .PHONY: githooks githooks: - ln -s hack/git_pre_push.sh .git/hooks/pre-push + ln -s ${PWD}/hack/git_pre_push.sh ${PWD}/.git/hooks/pre-push