Skip to content

Commit

Permalink
chore(ci): add pre release workflow with goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
panshuai111 committed May 30, 2024
1 parent ca5da5f commit a0203c8
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: write
jobs:
Expand Down Expand Up @@ -104,11 +104,29 @@ jobs:
CI=false npm run build
touch build/.gitkeep
- name: Determine GoReleaser Config with Regex
run: |
tag=${GITHUB_REF#refs/tags/}
alpha='v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
beta='v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'
rc='v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
release='v[0-9]+.[0-9]+.[0-9]+'
if [[ $tag =~ $alpha ]] || [[ $tag =~ $beta ]]; then
echo "Match found for alpha or beta tag"
echo "GO_RELEASER_CONFIG=alpha_or_beta_tag.yml" >> $GITHUB_ENV
elif [[ $tag =~ $rc ]] || [[ $tag =~ $release ]]; then
echo "Match found for rc or release tag"
echo "GO_RELEASER_CONFIG=rc_or_release_tag.yml" >> $GITHUB_ENV
else
echo "No match found"
exit 1
fi
- name: Release the karpor with GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --clean
args: release --clean --config .goreleaser/${{ env.GO_RELEASER_CONFIG }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63 changes: 63 additions & 0 deletions .goreleaser/alpha_or_beta_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright The Karpor Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
# GOOS list to build for.
# For more info refer to: https://golang.org/doc/install/source#environment
#
# Default: [ 'darwin', 'linux', 'windows' ]
goos:
- linux
# - windows
- darwin
# GOARCH to build for.
# For more info refer to: https://golang.org/doc/install/source#environment
#
# Default: [ '386', 'amd64', 'arm64' ]
goarch:
- amd64
- arm64
# By using ldflags="-s -w", the symbol table and debug information are removed to decrease the size of the release package.
ldflags:
- -s -w
main: ./cmd/
skip: true

dockers:
- image_templates:
- 'kusionstack/{{ .ProjectName }}:{{ .Tag }}'
- 'kusionstack/{{ .ProjectName }}:latest'
dockerfile: Dockerfile
use: docker
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/amd64"
extra_files:
- ui/
- config/relationship.yaml
4 changes: 3 additions & 1 deletion .goreleaser.yml → .goreleaser/rc_or_release_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com

before:
hooks:
# You may remove this if you don't use go modules.
Expand All @@ -36,7 +37,7 @@ builds:
goarch:
- amd64
- arm64
# 使用 ldflags="-s -w" 去掉符号表和调试信息,以减少发布包的大小
# By using ldflags="-s -w", the symbol table and debug information are removed to decrease the size of the release package.
ldflags:
- -s -w
main: ./cmd/
Expand Down Expand Up @@ -119,6 +120,7 @@ release:
* `kusionstack/karpor:{{ .Tag }}`
## Thanks!
prerelease: auto

dockers:
- image_templates:
Expand Down

0 comments on commit a0203c8

Please sign in to comment.