mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-04-30 06:37:29 +00:00
ci(github-action): 增加自动发布工作流.
使用 Action 自动执行发布过程, 可避免不少发布问题(比如构建成品包括了其他代码, 内容错误等). 同时在确认发布版本后,将自动构建并发布容器镜像, 支持多平台.
This commit is contained in:
parent
62f6c08cd2
commit
3ec5a8e9c3
61
.github/workflows/create-release.yml
vendored
Normal file
61
.github/workflows/create-release.yml
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
name: Create release draft
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v[0-9]+.[0-9]+.[0-9]+*'
|
||||||
|
|
||||||
|
# 该 Action 有以下步骤:
|
||||||
|
# 1. 拉取并构建代码, 然后生成 Application 发行包;
|
||||||
|
# 2. 创建 Release, 并标记为 Draft(草稿);
|
||||||
|
# 3. 上传 Application 发行包;
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
timeout-minutes: 10
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
# 创建更新日志.
|
||||||
|
- name: 'Get Previous tag'
|
||||||
|
id: previous-tag
|
||||||
|
uses: younited/get-previous-tag-action@v1.0.0
|
||||||
|
with:
|
||||||
|
match: "v*.*.*"
|
||||||
|
- name: Set up Python 3
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.10'
|
||||||
|
- name: Install Commitizen
|
||||||
|
run: pip install -U commitizen
|
||||||
|
- name: Create Change log
|
||||||
|
run: cz ch --start-rev ${{ steps.previous-tag.outputs.previous-tag }} --file-name ${{ github.workspace }}/CURRENT_CHANGELOG.md
|
||||||
|
|
||||||
|
# 开始构建项目.
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '11'
|
||||||
|
distribution: 'adopt-hotspot'
|
||||||
|
cache: 'gradle'
|
||||||
|
- name: Grant execute permission for gradlew
|
||||||
|
run: chmod +x gradlew
|
||||||
|
- name: Build and test
|
||||||
|
uses: gradle/gradle-build-action@v2.2.1
|
||||||
|
with:
|
||||||
|
gradle-version: 'wrapper'
|
||||||
|
arguments: clean test assembleDist
|
||||||
|
|
||||||
|
# 创建新的发行版本
|
||||||
|
- name: Create Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
draft: true
|
||||||
|
body_path: ${{ github.workspace }}/CURRENT_CHANGELOG.md
|
||||||
|
files: |
|
||||||
|
*/build/distributions/*
|
||||||
|
*/build/libs/*
|
48
.github/workflows/release-container-image.yml
vendored
Normal file
48
.github/workflows/release-container-image.yml
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
name: Release container image
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: lamgc/scalabot
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release-image:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 20
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '11'
|
||||||
|
distribution: 'adopt-hotspot'
|
||||||
|
cache: 'gradle'
|
||||||
|
- name: Grant execute permission for gradlew
|
||||||
|
run: chmod +x gradlew
|
||||||
|
- name: Build and test
|
||||||
|
uses: gradle/gradle-build-action@v2.2.1
|
||||||
|
with:
|
||||||
|
gradle-version: 'wrapper'
|
||||||
|
arguments: clean test installDist
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
- name: Set up Docker BuildX
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Build and push container image
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ env.IMAGE_NAME }}:latest, ${{ env.IMAGE_NAME }}:${{ github.ref_name }}
|
||||||
|
platforms: linux/amd64,linux/arm64,windows/amd64
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
Loading…
Reference in New Issue
Block a user