DG_LAB/.github/workflows/build-and-release.yml

62 lines
1.8 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Build and Release
on:
push:
tags:
- 'build*' # 当推送以 build:开头的 tag 时触发,比如 buildXXXX
workflow_dispatch: # 允许手动触发
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository #在 GitHub Actions 的虚拟机上,把仓库里的代码拉下来
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Grant execute permission for Gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew clean build
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: my-build
path: '**/build/libs/*.jar'
release:
needs: build # 这个 job 依赖于上一个 job build 完成。
runs-on: ubuntu-latest
steps:
- name: Download build artifact # 把上一个 job 上传的构建产物下载到当前 job 的 runner 上。
uses: actions/download-artifact@v3
with:
name: my-build
path: ./build-artifacts
- name: Create GitHub Release # 在 GitHub 上创建一个新的 Release版本发布
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body: |
自动发布所有子项目构建产物。
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact to Release # 上传构建产物到 Release
uses: softprops/action-gh-release@v1
with:
files: ./build-artifacts/**/*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}