Skip to content

Commit

Permalink
Merge pull request #20 from peng9808/main
Browse files Browse the repository at this point in the history
Add release process
  • Loading branch information
peng9808 authored Jun 12, 2024
2 parents b83216c + ea2f81b commit 7975b6b
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 125 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/period-check.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/pr.yml

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/release-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release Builder

on:
workflow_dispatch:

jobs:
release-image:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}
- name: Login registry
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Set env
run: |
echo "RELEASE_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV
echo "PROJECT_SOURCE_CODE_DIR=`echo ${GITHUB_WORKSPACE}`" >> $GITHUB_ENV
echo "IMAGE_REGISTRY=`echo ghcr.io/$(echo ${{ github.repository_owner }} | tr 'A-Z' 'a-z')`" >> $GITHUB_ENV
- name: Release builder
run: |
PROJECT_SOURCE_CODE_DIR=${PROJECT_SOURCE_CODE_DIR} IMAGE_REGISTRY=${IMAGE_REGISTRY} RELEASE_TAG=${RELEASE_TAG} make builder
36 changes: 4 additions & 32 deletions .github/workflows/release-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ name: Release Datastore

on:
push:
branches:
- main
paths:
- "helm/operator/Chart.yaml"
tags:
- 'v*'
workflow_dispatch:
inputs:
release_tag:
Expand All @@ -16,36 +14,9 @@ on:
type: string

jobs:
release-chart:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.7.1
- name: Set env
run: echo "GIT_ORG=$( echo ${{ github.repository_owner }} | tr 'A-Z' 'a-z' )" >> $GITHUB_ENV
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.3.0
with:
charts_dir: helm
charts_repo_url: https://${GIT_ORG}.github.io/datastore
config: helm/.cr/config.yaml
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

release-image:
runs-on: ubuntu-latest
needs:
- release-chart
permissions:
packages: write
steps:
Expand All @@ -70,6 +41,7 @@ jobs:
echo "RELEASE_TAG=`[ "${{ inputs.release_tag }}" != "" ] && echo ${{ inputs.release_tag }} || echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV
echo "PROJECT_SOURCE_CODE_DIR=`echo ${GITHUB_WORKSPACE}`" >> $GITHUB_ENV
echo "IMAGE_REGISTRY=`echo ghcr.io/$(echo ${{ github.repository_owner }} | tr 'A-Z' 'a-z')`" >> $GITHUB_ENV
echo "SCAN_IMAGES=true" >> $GITHUB_ENV
- name: Release image
run: |
PROJECT_SOURCE_CODE_DIR=${PROJECT_SOURCE_CODE_DIR} IMAGE_REGISTRY=${IMAGE_REGISTRY} RELEASE_TAG=${RELEASE_TAG} make release
PROJECT_SOURCE_CODE_DIR=${PROJECT_SOURCE_CODE_DIR} IMAGE_REGISTRY=${IMAGE_REGISTRY} RELEASE_TAG=${RELEASE_TAG} SCAN_IMAGES=${SCAN_IMAGES} make release
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -238,5 +238,5 @@ _gen-apis:
GOPROXY=https://goproxy.cn,direct /code-generator/generate-groups.sh all github.com/hwameistor/datastore/pkg/apis/client github.com/hwameistor/datastore/pkg/apis "datastore:v1alpha1" --go-header-file /go/src/github.com/hwameistor/datastore/build/boilerplate.go.txt

.PHONY: release
release: release_dataload_init release_dataload_manager
release: release_dataload_init release_dataload_manager release_ds_accl

2 changes: 1 addition & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM golang:alpine
FROM golang:1.21.5-alpine
2 changes: 1 addition & 1 deletion build/builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine
FROM golang:1.21.5-alpine

# set mirror repository for the package management
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories
Expand Down
2 changes: 1 addition & 1 deletion build/dataload-init/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM alpine:latest

COPY ./_build/datamanager /
COPY ./_build/dataload-init /

ENTRYPOINT [ "/dataload-init" ]
4 changes: 1 addition & 3 deletions build/dataload-manager/Dockerfile.amd64
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
FROM centos:7

RUN yum install -y wget
RUN wget https://github.com/juicedata/juicesync/releases/download/v1.1.1/juicesync-1.1.1-linux-arm64.tar.gz
RUN tar zxf juicesync-1.1.1-linux-arm64.tar.gz && mv juicesync /usr/bin && chmod +x /usr/bin/juicesync
RUN yum update -y nss nss-sysinit nss-tools

COPY ./_build/dataload-manager /

Expand Down
5 changes: 2 additions & 3 deletions build/dataload-manager/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM alpine:latest
FROM centos:7

RUN wget https://github.com/juicedata/juicesync/releases/download/v1.1.1/juicesync-1.1.1-linux-arm64.tar.gz
RUN tar zxf juicesync-1.1.1-linux-arm64.tar.gz && mv juicesync /usr/bin && chmod +x /usr/bin/juicesync
RUN yum update -y nss nss-sysinit nss-tools

COPY ./_build/dataload-manager /

Expand Down
42 changes: 9 additions & 33 deletions cmd/dataload-init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,35 @@ import (
datastorev1alpha1 "github.com/hwameistor/datastore/pkg/apis/client/clientset/versioned/typed/datastore/v1alpha1"
datastore "github.com/hwameistor/datastore/pkg/apis/datastore/v1alpha1"
log "github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/kubernetes"
v1 "k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/client-go/rest"
"os"
"time"
)

var (
nodeName = flag.String("nodename", "", "Node name")
dstDir = flag.String("dstdir", "", "destination Directory")
dstDir = flag.String("dstdir", "", "destination Directory")
)

const (
NameSpaceEnvVar = "NAMESPACE"
pvcNameEnvVar = "PVC_NAME"
NodeEnvVar = "MY_NODENAME"
DataSetEnvVar = "DATASET_NAME"
apiGroup = "example.com"
version = "v1alpha1"
)

func main() {
flag.Parse()
if *nodeName == "" {
log.WithFields(log.Fields{"nodename": *nodeName}).Error("Invalid node name")
os.Exit(1)
}

namespace := os.Getenv(NameSpaceEnvVar)
pvcName := os.Getenv(pvcNameEnvVar)
nodeName := os.Getenv(NodeEnvVar)
dataSetName := os.Getenv(DataSetEnvVar)

if namespace == "" || pvcName == "" {
if namespace == "" || nodeName == "" {
log.Fatal("Namespace or PVC Name environment variables are not set.")
os.Exit(1)
}
Expand All @@ -52,22 +46,8 @@ func main() {
os.Exit(1)
}

clientset, err := kubernetes.NewForConfig(config)
if err != nil {
log.WithError(err).Fatal("Failed to create Kubernetes clientset")
os.Exit(1)
}

pvcClient := clientset.CoreV1().PersistentVolumeClaims(namespace)
pvc, err := getPersistentVolumeClaim(pvcClient, pvcName)
if err != nil {
log.WithError(err).Error("Failed to get PVC")
os.Exit(1)
}

dataSetName := pvc.Spec.VolumeName
dataLoadRequestName := dataSetName + "-" + generateRandomSuffix()
dataLoadRequest := createDataLoadRequest(dataLoadRequestName, dataSetName)
dataLoadRequest := createDataLoadRequest(dataLoadRequestName, dataSetName, nodeName)
if *dstDir != "" {
dataLoadRequest.Spec.DstDir = *dstDir
}
Expand Down Expand Up @@ -103,11 +83,7 @@ func getConfig() (*rest.Config, error) {
return config, nil
}

func getPersistentVolumeClaim(pvcClient v1.PersistentVolumeClaimInterface, pvcName string) (*corev1.PersistentVolumeClaim, error) {
return pvcClient.Get(context.TODO(), pvcName, metav1.GetOptions{})
}

func createDataLoadRequest(dataLoadRequestName, dataSetName string) *datastore.DataLoadRequest {
func createDataLoadRequest(dataLoadRequestName, dataSetName, nodeName string) *datastore.DataLoadRequest {
return &datastore.DataLoadRequest{
TypeMeta: metav1.TypeMeta{
APIVersion: fmt.Sprintf("%s/%s", apiGroup, version),
Expand All @@ -118,7 +94,7 @@ func createDataLoadRequest(dataLoadRequestName, dataSetName string) *datastore.D
},
Spec: datastore.DataLoadRequestSpec{
IsGlobal: true,
Node: *nodeName,
Node: nodeName,
DataSet: dataSetName,
},
Status: datastore.DataLoadRequestStatus{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/hwameistor/datastore

go 1.18
go 1.20

require (
github.com/operator-framework/operator-sdk v0.18.2
Expand Down

0 comments on commit 7975b6b

Please sign in to comment.