-
Notifications
You must be signed in to change notification settings - Fork 7
177 lines (175 loc) · 6.47 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
name: Release Daikoku
on:
workflow_dispatch:
inputs:
lastVersion:
description: 'last version'
required: true
releaseVersion:
description: 'release version'
required: true
nextVersion:
description: 'next version'
required: true
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
# setup java to use sbt (?)
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- uses: coursier/cache-action@v5
# install node 16
- name: setup node
uses: actions/setup-node@v1
with:
node-version: '16'
#format sources
- name: format sources
id: fmt
run: |
sh ./scripts/build.sh fmt
echo "diff=$(git diff --numstat | wc -l)" >> $GITHUB_OUTPUT
- name: Commit formatted sources
if: steps.fmt.outputs.diff != '0'
run: |
git config --local user.email "[email protected]"
git config --local user.name "daikoku-github-actions"
git add --all
git commit -am "Format sources before release"
- name: Push formatted sources
if: steps.fmt.outputs.diff != '0'
uses: ad-m/github-push-action@master
with:
branch: ${{ github.ref }}
github_token: ${{ secrets.GITHUB_TOKEN}}
#Build manual with right version
- name: build manual
id: manual
run: |
find ./manual/src/main/paradox -type f -name '*.md' | xargs node ./scripts/version.js ${{ github.event.inputs.lastVersion }} ${{ github.event.inputs.releaseversion }}
find ./docs -type f -name '*.html' -d 1 | xargs node ./scripts/version.js ${{ github.event.inputs.lastVersion }} ${{ github.event.inputs.releaseversion }}
cd manual
sbt "release with-defaults release-version ${{ github.event.inputs.releaseversion }}"
cd ..
sh ./scripts/build.sh manual
echo "diff=$(git diff --numstat | wc -l)" >> $GITHUB_OUTPUT
cd ..
- name: Commit manual
if: steps.manual.outputs.diff != '0'
run: |
git config --local user.email "[email protected]"
git config --local user.name "daikoku-github-actions"
git add --all
git commit -am "Update documentation before release"
- name: Push manual
uses: ad-m/github-push-action@master
if: steps.manual.outputs.diff != '0'
with:
branch: ${{ github.ref }}
github_token: ${{ secrets.GITHUB_TOKEN}}
# release sbt (with auto commit tag)
- name: release sbt
run: |
git config --local user.email "[email protected]"
git config --local user.name "daikoku-github-actions"
cd daikoku
sbt "release with-defaults release-version ${{ github.event.inputs.releaseVersion }} next-version ${{ github.event.inputs.nextVersion }}"
- name: push tag
uses: ad-m/github-push-action@master
with:
branch: ${{ github.ref }}
tags: true
github_token: ${{ secrets.GITHUB_TOKEN}}
- name: Checkout release tag
uses: actions/[email protected]
with:
ref: 'v${{ github.event.inputs.releaseVersion }}'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: |
echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: CACHE ACTION
uses: actions/cache@v2
env:
cache-version: v1
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
**/node_modules
key: ${{ runner.os }}-yarn-${{ env.cache-version }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ env.cache-version }}-
${{ runner.os }}-yarn-
${{ runner.os }}-
# clean, build doc and build DK
- name: Build DK
run: sh ./scripts/build.sh github
env:
NODE_OPTIONS: --max_old_space_size=4096
# create github release
- name: Create a Release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.event.inputs.releaseversion }}
release_name: v${{ github.event.inputs.releaseversion }}
draft: false
# attach daikoku.jar, zip & manual.zip to github release
- name: Upload a Release Asset - daikoku.jar
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./daikoku/target/scala-2.13/daikoku.jar
asset_name: daikoku.jar
asset_content_type: application/octet-stream
- name: Upload a Release Asset - daikoku.zip
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./daikoku/target/universal/daikoku.zip
asset_name: daikoku-${{ github.event.inputs.releaseversion }}.zip
asset_content_type: application/octet-stream
- name: Zip manual
run: zip -r ./daikoku-manual.zip ./docs/manual -x '*.DS_Store'
- name: Upload a Release Asset - manual
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./daikoku-manual.zip
asset_name: daikoku-manual-${{ github.event.inputs.releaseversion }}.zip
asset_content_type: application/octet-stream
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
# build docker image & upload it in docker hub
- name: Build docker image
run: |
cd daikoku
sbt 'docker:publishLocal'
docker tag maif/daikoku:latest maif/daikoku:${{ github.event.inputs.releaseversion }}
docker push "maif/daikoku:latest"
docker push "maif/daikoku:${{ github.event.inputs.releaseversion }}"
# close milestone (with the latest release found)
- name: Close milestone
uses: adlerhsieh/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
REPO_OWNER: ${{ github.repository_owner }}
REPO: daikoku
IGNORE_MILESTONE_NOT_FOUND: true