Skip to content

Create novel-plus Maven Release with ZIPs #36

Create novel-plus Maven Release with ZIPs

Create novel-plus Maven Release with ZIPs #36

Workflow file for this run

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 }}
# 解压 SQL 文件
- name: Unzip MySQL SQL File
run: |
unzip -o ./doc/sql/novel_plus_data.sql.zip -d ./doc/sql/
# 构建并推送 mysql-novel-plus 镜像
- name: Build and Push mysql-novel-plus Docker Image
uses: docker/build-push-action@v5
with:
context: ./doc/sql
file: ./doc/sql/Dockerfile
push: true
tags: |
201206030/mysql-novel-plus:latest
201206030/mysql-novel-plus:${{ github.ref_name }}