Skip to content

init release action #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Reference from:
# https://goreleaser.com/ci/actions/
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
Test:
name: Unit Test
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Fetch History
run: git fetch --prune --unshallow
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Setup protoc
run: |
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.19.5/protoc-3.19.5-linux-x86_64.zip
unzip protoc-3.19.5-linux-x86_64.zip -d protoc3
- name: Cache Go Dependencies
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: Run Unit Tests
run: |
export PATH="$PATH:$(pwd)/protoc3/bin"
echo $PATH
make test
rm -rf protoc-3.19.5-linux-x86_64.zip
rm -rf protoc3
git status

GolangLint:
name: Golang Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.53
args: --timeout=30m


# Release the artifacts, release note and images.
Release:
runs-on: ubuntu-latest
needs: [Test, GolangLint]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Check if on tag
run: |
if [[ "${GITHUB_REF#refs/tags/}" != "$GITHUB_REF" ]]; then
echo "Running on tag ${GITHUB_REF#refs/tags/}"
else
echo "Not running on a tag"
fi

- name: Get version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19

- name: Release the karbour with GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132 changes: 132 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
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
ldflags:
- -s -w
main: ./cmd/
archives:
- id: release
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
builds_info:
mode: 0644
# format is `time.RFC3339Nano`
mtime: 2008-01-02T15:04:05Z
# format_overrides:
# - goos: windows
# format: zip
files:
- LICENSE
- README.md
- docs/*
- src: dist/CHANGELOG.md
strip_parent: true
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: desc
# Changelog generation implementation to use.
#
# Valid options are:
# - `git`: uses `git log`;
# - `github`: uses the compare GitHub API, appending the author login to the changelog.
# - `gitlab`: uses the compare GitLab API, appending the author name and email to the changelog.
# - `github-native`: uses the GitHub release notes generation API, disables the groups feature.
#
# Default: 'git'
use: github
# Group commits messages by given regex and title.
# Order value defines the order of the groups.
# Providing no regex means all commits will be grouped under the default group.
# Groups are disabled when using github-native, as it already groups things by itself.
# Matches are performed against strings of the form: "<abbrev-commit>[:] <title-commit>".
# Regex use RE2 syntax as defined here: https://github.com/google/re2/wiki/Syntax.
groups:
- title: Features
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
order: 0
- title: 'Bug fixes'
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
order: 1
- title: 'Performance improvements'
regexp: '^.*?perf(\([[:word:]]+\))??!?:.+$'
order: 2
- title: 'Refactors'
regexp: '^.*?refactor(\([[:word:]]+\))??!?:.+$'
order: 3
- title: 'Tests'
regexp: '^.*?test(\([[:word:]]+\))??!?:.+$'
order: 4
- title: 'Documents'
regexp: '^.*?docs(\([[:word:]]+\))??!?:.+$'
order: 5
- title: 'Chores'
regexp: '^.*?chore(\([[:word:]]+\))??!?:.+$'
order: 6
- title: 'CI'
regexp: '^.*?ci(\([[:word:]]+\))??!?:.+$'
order: 7
- title: Others
order: 999
filters:
exclude:
- '^style:'

release:
github:
owner: KusionStack
name: kridge
draft: false
footer: |
## Docker Images
* `kusionstack/kridge-manager:{{ .Tag }}`
* `kusionstack/kridge-proxy:{{ .Tag }}`
## Thanks!

dockers:
- image_templates:
- 'kusionstack/{{ .ProjectName }}-manager:{{ .Tag }}'
- 'kusionstack/{{ .ProjectName }}-manager:latest'
dockerfile: ./artifacts/images/manager.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"
- image_templates:
- 'kusionstack/{{ .ProjectName }}-proxy:{{ .Tag }}'
- 'kusionstack/{{ .ProjectName }}-proxy:latest'
dockerfile: ./artifacts/images/proxy.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"