-
Notifications
You must be signed in to change notification settings - Fork 176
155 lines (133 loc) · 5.73 KB
/
push-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
name: Push Release
# 配置触发事件为标签为v开头的推送
on:
push:
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
discussions: write
steps:
- uses: actions/checkout@v4
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: ReleaseVersion
run: |
echo ${{ env.RELEASE_VERSION }}
- name: 建立JDK17运行环境
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: 构建Maven项目
run: mvn -B package --file pom.xml
# 构建前端
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8.6.10
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: 初始化前端子项目
run: git submodule init && git submodule update --init --recursive
- name: 安装前端依赖
run: |
cd autoplan-front && pnpm install --no-frozen-lockfile
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 构建前端
run: cd autoplan-front && pnpm run build
- run: mkdir build && mkdir build/Linux_x64 && mkdir build/Linux_aarch64 && mkdir build/Windows_x64
- run: wget https://corretto.aws/downloads/latest/amazon-corretto-17-x64-linux-jdk.tar.gz && tar -zxvf amazon-corretto-17-x64-linux-jdk.tar.gz
- run: find . -type d -name 'amazon-corretto-17*linux-x64' -exec cp -r {} build/Linux_x64/jdk \;
- run: wget https://corretto.aws/downloads/latest/amazon-corretto-17-aarch64-linux-jdk.tar.gz && tar -zxvf amazon-corretto-17-aarch64-linux-jdk.tar.gz
- run: find . -type d -name 'amazon-corretto-17*linux-aarch64' -exec cp -r {} build/Linux_aarch64/jdk \;
- run: wget https://corretto.aws/downloads/latest/amazon-corretto-17-x64-windows-jdk.zip && unzip amazon-corretto-17-x64-windows-jdk.zip -d amazon-corretto-17-x64-windows-jdk
- run: find ./amazon-corretto-17-x64-windows-jdk -maxdepth 1 -type d -name 'jdk17*' -exec cp -r {} build/Windows_x64/jdk \;
- run: cp target/auto_plan.jar build/Linux_x64 && cp target/auto_plan.jar build/Linux_aarch64 && cp target/auto_plan.jar build/Windows_x64
- run: cp script/start.sh build/Linux_x64 && cp script/start.sh build/Linux_aarch64 && cp script/start.bat build/Windows_x64
- run: cp docs/application-example.yml build/Linux_x64 && cp docs/application-example.yml build/Linux_aarch64 && cp docs/application-example.yml build/Windows_x64
- run: tar -czvf build/auto_plan_linux_x64.tar.gz build/Linux_x64/
- run: tar -czvf build/auto_plan_linux_aarch64.tar.gz build/Linux_aarch64/
- run: zip -r build/auto_plan_windows_x64.zip build/Windows_x64/
- run: zip -r build/autoplan_front.zip autoplan-front/dist/
- run: cp target/auto_plan.jar build
- run: cp docs/application-example.yml build
# - name: 获取 Maven pom.xml中 version版本环境变量
# run: echo "RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
# 上传文件并发布 Release
# - name: Upload Release
# uses: softprops/action-gh-release@v1
# if: startsWith(github.ref, 'refs/tags/')
# with:
# name: "Release ${{ env.RELEASE_VERSION }}"
# tag_name: ${{ env.RELEASE_VERSION }}
# files: |
# build/auto_plan_linux_x64.tar.gz
# build/auto_plan_linux_aarch64.tar.gz
# build/auto_plan_windows_x64.zip
# build/auto_plan.jar
# build/autoplan_front.zip
# build/application-example.yml
- name: Upload Release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ env.RELEASE_VERSION }}"
prerelease: false
title: "${{ env.RELEASE_VERSION }}"
files: |
build/auto_plan*
build/application-example.yml
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: wyt1215819315/auto_plan
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=ref,event=branch
- name: Build and push streampark
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64/v8
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}