From 479f4e31911f1e6856e64d9e16d75b5ba7fa6165 Mon Sep 17 00:00:00 2001 From: zhuwenxing Date: Wed, 26 Apr 2023 10:54:50 +0800 Subject: [PATCH] ci: add release pipeline (#13) Signed-off-by: zhuwenxing --- .github/workflows/release.yaml | 126 +++++++++++++++++++++++++++++++++ .gitignore | 3 +- .goreleaser.yaml | 58 ++++----------- server/.goreleaser-darwin.yaml | 44 ++++++++++++ server/.goreleaser-linux.yaml | 49 +++++++++++++ tests/requirements.txt | 1 - 6 files changed, 236 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/release.yaml create mode 100644 server/.goreleaser-darwin.yaml create mode 100644 server/.goreleaser-linux.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..39c35a85 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,126 @@ +name: release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +permissions: + contents: write + +jobs: + build-linux-binary: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - run: git fetch --force --tags + - uses: actions/setup-go@v4 + with: + go-version: '1.18' + cache-dependency-path: server/go.sum + cache: true + + - uses: goreleaser/goreleaser-action@v4 + with: + # either 'goreleaser' (default) or 'goreleaser-pro': + distribution: goreleaser + workdir: ./server + version: latest + args: release --skip-publish --config .goreleaser-linux.yaml + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + - name: Upload + uses: actions/upload-artifact@v3 + with: + name: milvus-cdc-linux + path: | + server/dist/milvus-cdc* + server/dist/checksums.txt + + build-darwin-binary: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-go@v4 + with: + go-version: '1.18' + cache-dependency-path: server/go.sum + cache: true + + - uses: goreleaser/goreleaser-action@v4 + with: + # either 'goreleaser' (default) or 'goreleaser-pro': + distribution: goreleaser + workdir: ./server + version: latest + args: release --skip-publish --config .goreleaser-darwin.yaml + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + - name: Upload + uses: actions/upload-artifact@v3 + with: + name: milvus-cdc-darwin + path: | + server/dist/milvus-cdc* + server/dist/checksums.txt + merge-and-release: + needs: [build-linux-binary, build-darwin-binary] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - run: git fetch --force --tags + - uses: actions/setup-go@v4 + with: + go-version: '1.18' + cache-dependency-path: server/go.sum + cache: true + - name: Make directories + run: | + mkdir -p ./milvus-cdc-build/linux + mkdir -p ./milvus-cdc-build/darwin + - name: Download linux binaries + uses: actions/download-artifact@v3 + with: + name: milvus-cdc-linux + path: ./milvus-cdc-build/linux + - name: Download darwin binaries + uses: actions/download-artifact@v3 + with: + name: milvus-cdc-darwin + path: ./milvus-cdc-build/darwin + - name: Merge checksum file + run: | + cd ./milvus-cdc-build + cat ./darwin/checksums.txt >> checksums.txt + cat ./linux/checksums.txt >> checksums.txt + rm ./darwin/checksums.txt + rm ./linux/checksums.txt + - name: Check git status + run: | + tree + git status + + - name: Release + uses: goreleaser/goreleaser-action@v4 + with: + args: release --clean --config .goreleaser.yaml + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + - name: Docker Login + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: Build and push docker image + run: | + tag=$(git tag --sort=-version:refname | head -1) + docker build -t milvusdb/milvus-cdc:$tag -t milvusdb/milvus-cdc:latest . + docker push milvusdb/milvus-cdc:$tag + docker push milvusdb/milvus-cdc:latest \ No newline at end of file diff --git a/.gitignore b/.gitignore index f179a236..fee1456e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ **/volumes/* **/__pycache__/* **/.pytest_cache/* -server/cdc \ No newline at end of file +server/cdc +**/milvus-cdc-build/* \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml index f5385d9c..7a3d318b 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,48 +1,20 @@ -# This is an example .goreleaser.yml file with some sensible defaults. -# Make sure to check the documentation at https://goreleaser.com -before: - hooks: - # You may remove this if you don't use go modules. - - go mod tidy - # you may remove this if you don't need go generate - # - go generate ./... builds: - - env: - - CGO_ENABLED=1 - main: ./main - goos: - # - linux - # - windows - - darwin - goarch: - - amd64 - - arm64 -archives: - - format: tar.gz - # this name template makes the OS and Arch compatible with the results of uname. - name_template: >- - {{ .ProjectName }}_ - {{- title .Os }}_ - {{- if eq .Arch "amd64" }}x86_64 - {{- else if eq .Arch "386" }}i386 - {{- else }}{{ .Arch }}{{ end }} - {{- if .Arm }}v{{ .Arm }}{{ end }} - # use zip for windows archives - format_overrides: - - goos: windows - format: zip -checksum: - name_template: 'checksums.txt' -snapshot: - name_template: "{{ incpatch .Version }}-next" + - skip: true changelog: sort: asc filters: exclude: - - '^docs:' - - '^test:' - -# The lines beneath this are called `modelines`. See `:help modeline` -# Feel free to remove those if you don't want/use them. -# yaml-language-server: $schema=https://goreleaser.com/static/schema.json -# vim: set ts=2 sw=2 tw=0 fo=cnqoj + - "^docs:" + - "^test:" +release: + draft: true + mode: append + extra_files: + - glob: ./milvus-cdc-build/**/*.tar.gz + - glob: ./milvus-cdc-build/checksums.txt + name_template: "Release {{.Tag}}" + header: | + # What's Changed + ## 🚀 Features + ## 🎄 Enhancements + ## 🐛 Bug Fixes \ No newline at end of file diff --git a/server/.goreleaser-darwin.yaml b/server/.goreleaser-darwin.yaml new file mode 100644 index 00000000..d9f97f7c --- /dev/null +++ b/server/.goreleaser-darwin.yaml @@ -0,0 +1,44 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + # you may remove this if you don't need go generate + # - go generate ./... +builds: + - + main: ./main + env: + - CGO_ENABLED=1 + goos: + - darwin +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of uname. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + +# The lines beneath this are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj diff --git a/server/.goreleaser-linux.yaml b/server/.goreleaser-linux.yaml new file mode 100644 index 00000000..37c0e57c --- /dev/null +++ b/server/.goreleaser-linux.yaml @@ -0,0 +1,49 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + # you may remove this if you don't need go generate + #- go generate ./... +builds: + - + main: ./main + env: + - CGO_ENABLED=1 + goos: + - linux + goarch: + - amd64 + overrides: + - goos: linux + goarch: amd64 + env: + - CC=gcc + ldflags: + - -extldflags "-static" +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of uname. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + +# The lines beneath this are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj \ No newline at end of file diff --git a/tests/requirements.txt b/tests/requirements.txt index 895a1e7e..55516810 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -14,7 +14,6 @@ pytest-level==0.1.1 pytest-xdist==2.5.0 pymilvus==2.3.0.dev48 pytest-rerunfailures==9.1.1 -git+https://github.com/Projectplace/pytest-tags ndg-httpsclient pyopenssl pyasn1