Files
novel_dev_team_novel-plus/.github/workflows/release.yml
2026-05-16 19:12:56 +08:00

121 lines
4.0 KiB
Java
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: Create novel-plus Maven Release with ZIPs
on:
push:
# 匹配所有以'v'开头的标签
tags:
- 'v*'
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
# 可选默认是 temurin也可以选择其他发行版
distribution: 'temurin'
- name: Build project with Maven
run: mvn clean install -DskipTests=true -Pcentral-repo
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
with:
# 使用 tag_name 而不是 github.ref
tag_name: ${{ github.ref_name }}
release_name: novel-plus ${{ github.ref_name }}
draft: false
prerelease: false
# 使用 action 来替代直接 curl 进行上传
- name: Upload sql.zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/novel-common/target/build/sql.zip
asset_name: sql.zip
asset_content_type: application/zip
- name: Upload novel-crawl.zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/novel-crawl/target/build/novel-crawl.zip
asset_name: novel-crawl.zip
asset_content_type: application/zip
- name: Upload novel-front.zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/novel-front/target/build/novel-front.zip
asset_name: novel-front.zip
asset_content_type: application/zip
- name: Upload novel-admin.zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/novel-admin/target/build/novel-admin.zip
asset_name: novel-admin.zip
asset_content_type: application/zip
# 登录 Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# 构建并推送 novel-front 镜像
- name: Build and Push novel-front Docker Image
uses: docker/build-push-action@v5
with:
context: ./novel-front/target/build
file: ./novel-front/target/build/Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/novel-front:latest
${{ secrets.DOCKERHUB_USERNAME }}/novel-front:${{ github.ref_name }}
# 构建并推送 novel-admin 镜像
- name: Build and Push novel-admin Docker Image
uses: docker/build-push-action@v5
with:
context: ./novel-admin/target/build
file: ./novel-admin/target/build/Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/novel-admin:latest
${{ secrets.DOCKERHUB_USERNAME }}/novel-admin:${{ github.ref_name }}
# 构建并推送 novel-crawl 镜像
- name: Build and Push novel-crawl Docker Image
uses: docker/build-push-action@v5
with:
context: ./novel-crawl/target/build
file: ./novel-crawl/target/build/Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/novel-crawl:latest
${{ secrets.DOCKERHUB_USERNAME }}/novel-crawl:${{ github.ref_name }}