-
Notifications
You must be signed in to change notification settings - Fork 960
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from Leizhenpeng/feat-ci
chore: add binary release and Docker Hub support
- Loading branch information
Showing
8 changed files
with
171 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
name: 问题交流 | ||
about: 有任何问题,都可以在这里交流。 | ||
title: "[问题] " | ||
labels: ["question"] | ||
--- | ||
|
||
# 问题交流 💬 | ||
|
||
有任何问题,都可以在这里交流哦~ | ||
|
||
## 问题是什么呢? 🤔 | ||
|
||
请详细地描述你遇到的问题,包括出现问题的环境和步骤,以及你已经尝试过的解决方法。 | ||
|
||
另外,如果你在解决问题时已经查看过其他 GitHub Issue,请务必在文本中说明并引用相关信息。 | ||
|
||
## 附加信息 📝 | ||
|
||
请提供以下信息以帮助我们更快地解决问题: | ||
|
||
- 输出日志,包括错误信息和堆栈跟踪 | ||
- 相关的代码片段或文件 | ||
- 你的操作系统、golang 版本等环境信息 | ||
|
||
谢谢你的反馈!🙏 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!-- 请务必在创建PR前,在右侧 Labels 选项中加上label的其中一个: [feature]、[fix]、[documentation]、[dependencies]、[test] 。以便于Actions自动生成Releases时自动对PR进行归类。--> | ||
|
||
|
||
**填写PR内容:** | ||
|
||
- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Configuration for Release Drafter: https://github.com/toolmantim/release-drafter | ||
name-template: 'v$NEXT_PATCH_VERSION 🌈' | ||
tag-template: 'v$NEXT_PATCH_VERSION' | ||
version-template: $MAJOR.$MINOR.$PATCH | ||
# Emoji reference: https://gitmoji.carloscuesta.me/ | ||
categories: | ||
- title: 🚀 Features | ||
labels: | ||
- 'feature' | ||
- 'enhancement' | ||
- 'kind/feature' | ||
- title: 🚑️ Bug Fixes | ||
labels: | ||
- 'fix' | ||
- 'bugfix' | ||
- 'bug' | ||
- 'regression' | ||
- 'kind/bug' | ||
- title: 📝 Documentation updates | ||
labels: | ||
- 'doc' | ||
- 'documentation' | ||
- 'kind/doc' | ||
- title: 👷 Maintenance | ||
labels: | ||
- chore | ||
- dependencies | ||
- 'kind/chore' | ||
- 'kind/dep' | ||
- title: 🚦 Tests | ||
labels: | ||
- test | ||
- tests | ||
exclude-labels: | ||
- reverted | ||
- no-changelog | ||
- skip-changelog | ||
- invalid | ||
change-template: '* $TITLE (#$NUMBER) @$AUTHOR' | ||
template: | | ||
## What’s Changed | ||
$CHANGES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,21 +2,21 @@ name: Build Release | |
|
||
on: | ||
release: | ||
types: [created] | ||
types: [created,published] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build-go-binary: | ||
permissions: | ||
contents: write # for build-go-binary | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
goos: [linux, windows] | ||
goarch: [amd64, arm64] | ||
exclude: | ||
goos: [ linux, windows, darwin ] # 需要打包的系统 | ||
goarch: [ amd64, arm64 ] # 需要打包的架构 | ||
exclude: # 排除某些平台和架构 | ||
- goarch: arm64 | ||
goos: windows | ||
steps: | ||
|
@@ -27,13 +27,13 @@ jobs: | |
- name: Parallel build | ||
uses: wangyoucao577/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
goos: ${{ matrix.goos }} | ||
goarch: ${{ matrix.goarch }} | ||
goversion: 1.18 | ||
pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 | ||
executable_compression: "upx -9" | ||
md5sum: false | ||
project_path: "./code" | ||
binary_name: "start-feishubot" | ||
extra_files: ./code/config.example.yaml | ||
binary_name: "feishu-chatgpt" | ||
extra_files: ./code/config.example.yaml readme.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,59 @@ | ||
name: Docker Publish | ||
name: build docker image | ||
|
||
# 仅在release时触发 | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
env: | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
release: | ||
types: [created,published] | ||
|
||
# 可以手动触发 | ||
workflow_dispatch: | ||
inputs: | ||
logLevel: | ||
description: 'Log level' | ||
required: true | ||
default: 'warning' | ||
tags: | ||
description: 'Test scenario tags' | ||
|
||
jobs: | ||
build-and-publish: | ||
buildx: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
architecture: [ amd64, arm64 ] | ||
|
||
steps: | ||
- name: Checkout code | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Login to Docker Hub | ||
- name: Inject slug/short variables | ||
uses: rlespinasse/github-slug-action@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Available platforms | ||
run: echo ${{ steps.buildx.outputs.platforms }} | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ env.DOCKER_USERNAME }} | ||
password: ${{ env.DOCKER_PASSWORD }} | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
go-version: '1.18' | ||
|
||
- name: Install dependencies | ||
run: | ||
cd ./code && go mod tidy | ||
|
||
- name: Build Docker image | ||
run: | | ||
docker build -t feishu-chatgpt:${{ matrix.architecture }}-${{ github.sha }} --build-arg ARCHITECTURE=${{ matrix.architecture }} . | ||
- name: Push Docker image to Docker Hub | ||
run: | | ||
docker tag feishu-chatgpt:${{ matrix.architecture }}-${{ github.sha }} ${{ env.DOCKER_USERNAME }}/feishu-chatgpt:${{ matrix.architecture }}-${{ github.sha }} | ||
docker tag feishu-chatgpt:${{ matrix.architecture }}-${{ github.sha }} ${{ env.DOCKER_USERNAME }}/feishu-chatgpt:${{ matrix.architecture }}-latest | ||
docker push ${{ env.DOCKER_USERNAME }}/feishu-chatgpt:${{ matrix.architecture }}-${{ github.sha }} | ||
docker push ${{ env.DOCKER_USERNAME }}/feishu-chatgpt:${{ matrix.architecture }}-latest | ||
context: . | ||
file: ./Dockerfile | ||
# 所需要的体系结构,可以在 Available platforms 步骤中获取所有的可用架构 | ||
platforms: linux/amd64,linux/arm64/v8 | ||
# 镜像推送时间 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
# 给清单打上多个标签 | ||
tags: | | ||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.GITHUB_REPOSITORY_NAME_PART }}:${{ env.GITHUB_REF_NAME }} | ||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.GITHUB_REPOSITORY_NAME_PART }}:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Release Drafter | ||
|
||
on: | ||
push: | ||
# branches to consider in the event; optional, defaults to all | ||
branches: | ||
- master | ||
# pull_request event is required only for autolabeler | ||
pull_request: | ||
# Only following types are handled by the action, but one can default to all as well | ||
types: [opened, reopened, synchronize] | ||
# pull_request_target event is required for autolabeler to support PRs from forks | ||
# pull_request_target: | ||
# types: [opened, reopened, synchronize] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
update_release_draft: | ||
permissions: | ||
contents: write # for release-drafter/release-drafter to create a github release | ||
pull-requests: write # for release-drafter/release-drafter to add label to PR | ||
runs-on: ubuntu-latest | ||
steps: | ||
# (Optional) GitHub Enterprise requires GHE_HOST variable set | ||
#- name: Set GHE_HOST | ||
# run: | | ||
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV | ||
|
||
# Drafts your next Release notes as Pull Requests are merged into "master" | ||
- uses: release-drafter/release-drafter@v5 | ||
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml | ||
# with: | ||
# config-name: my-config.yml | ||
# disable-autolabeler: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters