Skip to content

Commit

Permalink
add workflow for git to release
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncan-tree-zhou committed Feb 6, 2023
1 parent 8bb19a4 commit 4d3d178
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 43 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/docker-image.yml

This file was deleted.

65 changes: 65 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Create the release

on:
push:
tags:
- v*
workflow_dispatch:

env:
IMAGE_NAME: nano-pod-operator-controller

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: "Log in to GitHub Container repo registry"
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: "Build & Push image"
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
make docker-build docker-push IMG=$IMAGE_ID:$VERSION
- name: "Generate nano pod operator related manifests(yaml)"
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo $IMAGE_ID
echo $VERSION
make release-artifacts IMG=$IMAGE_ID:$VERSION
- name: "Create the release in GitHub"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
gh config set prompt disabled
gh release create \
-t "Release ${VERSION}" \
"${VERSION}" \
'dist/nano-pod-operator.yaml'
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,18 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: deploy
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
deploy: manifests kustomize set-image-controller ## Deploy controller to the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/default | kubectl apply -f -

.PHONY: undeploy
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: release-artifacts
release-artifacts: set-image-controller
mkdir -p dist
$(KUSTOMIZE) build config/default -o dist/nano-pod-operator.yaml

##@ Build Dependencies

## Location to install dependencies to
Expand Down
4 changes: 2 additions & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: treezh-docker.pkg.coding.net/demo03/opentelemetry-public/nano-pod-controller
newTag: "20230116.1"
newName: controller
newTag: latest
12 changes: 12 additions & 0 deletions hack/install-kubebuilder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -x

os=$(go env GOOS)
arch=$(go env GOARCH)
kubebuilder_exec=kubebuilder_${os}_${arch}

curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v3.6.0/${kubebuilder_exec} --output ${kubebuilder_exec}
sudo mv /tmp/${kubebuilder_exec} /usr/local/kubebuilder/bin/kubebuilder
export PATH=$PATH:/usr/local/kubebuilder/bin

7 changes: 7 additions & 0 deletions hack/install-kustomize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

os=$(go env GOOS)
arch=$(go env GOARCH)

sudo curl -sL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv4.5.4/kustomize_v4.5.4_${os}_${arch}.tar.gz | tar xvz -C /usr/local/bin/
export PATH=$PATH:/usr/local/bin

0 comments on commit 4d3d178

Please sign in to comment.