-
Notifications
You must be signed in to change notification settings - Fork 173
184 lines (156 loc) · 5.97 KB
/
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: huntly release workflow
on:
push:
tags: [ v\d+\.\d+\.\d+ ]
permissions:
contents: read
jobs:
create-release:
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
release_id: ${{ steps.create-release.outputs.id }}
release_upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get version
id: get_version
uses: battila7/get-version-action@v2
- name: Get tag message
id: tag
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
echo "message<<EOF" >> $GITHUB_OUTPUT
echo "$(git tag -l --format='%(contents)' ${{ steps.get_version.outputs.version }})" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
id: create-release
uses: ncipollo/release-action@v1
with:
draft: true
name: ${{ steps.get_version.outputs.version }}
tag: ${{ steps.get_version.outputs.version }}
body: "${{ steps.tag.outputs.message }}"
build-upload:
runs-on: ubuntu-latest
needs: create-release
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get version
id: get_version
uses: battila7/get-version-action@v2
- name: Set Node.js
uses: actions/setup-node@v3
with:
node-version: "18.12.1"
cache: "yarn"
cache-dependency-path: "app/client/yarn.lock"
- name: Setup yarn
run: npm install -g yarn --version 1.22.19
- name: Install client dependencies
run: |
cd app/client
yarn install
- name: Install extension dependencies
#if: steps.yarn-cache.outputs.cache-hit != 'true'
run: |
cd app/extension
yarn install
- name: Create extension bundle
run: |
cd app/extension
yarn build
env:
CI: false
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: "11"
distribution: "temurin"
# Retrieve maven dependencies from cache. After a successful run, these dependencies are cached again
- name: Cache maven dependencies
uses: actions/cache@v3
env:
cache-name: cache-maven-dependencies
with:
# maven dependencies are stored in `~/.m2` on Linux/macOS
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: |
cd app/server
mvn clean package
env:
CI: false
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
# 所需要的体系结构,可以在 Available platforms 步骤中获取所有的可用架构
platforms: linux/arm64,linux/amd64
# 镜像推送时间
push: ${{ github.event_name != 'pull_request' }}
# 给清单打上多个标签
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.GITHUB_REPOSITORY_NAME_PART }}:latest
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.GITHUB_REPOSITORY_NAME_PART }}:${{ steps.get_version.outputs.version-without-v }}
- name: package release file
run: |
mkdir release release/huntly-client release/huntly-extension
mv app/server/huntly-server/target/huntly-*.jar release/huntly-server.jar
mv app/client/build release/huntly-client
mv app/extension/dist/ release/huntly-extension
cd release
zip -r huntly-client-${{ steps.get_version.outputs.version-without-v }}.zip ./huntly-client/*
zip -r huntly-browser-extension-${{ steps.get_version.outputs.version-without-v }}.zip ./huntly-extension/*
- name: Upload client-build to release
id: upload-client-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.release_upload_url }}
asset_path: release/huntly-client-${{ steps.get_version.outputs.version-without-v }}.zip
asset_name: huntly-client-${{ steps.get_version.outputs.version-without-v }}.zip
asset_content_type: application/zip
- name: Upload extension-build to release
id: upload-extension-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.release_upload_url }}
asset_path: release/huntly-browser-extension-${{ steps.get_version.outputs.version-without-v }}.zip
asset_name: huntly-browser-extension-${{ steps.get_version.outputs.version-without-v }}.zip
asset_content_type: application/zip
- name: Upload server-build to release
id: upload-server-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.release_upload_url }}
asset_path: release/huntly-server.jar
asset_name: huntly-server-${{ steps.get_version.outputs.version-without-v }}.jar
asset_content_type: application/java-archive