-
Notifications
You must be signed in to change notification settings - Fork 7
161 lines (159 loc) · 5.99 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
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/checkout@v2.2.0
# setup java to use sbt (?)
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '21'
- uses: coursier/cache-action@v5
# install node lts
- name: setup node
uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'npm'
cache-dependency-path: daikoku/javascript/package-lock.json
#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 "daikoku-github-actions@users.noreply.github.com"
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 (and update version in openapi)
- name: update version number
id: version
run: |
find ./manual -type f -name '*.md' | xargs node ./scripts/version.js ${{ github.event.inputs.lastVersion }} ${{ github.event.inputs.releaseversion }}
find ./daikoku/public/swaggers -type f -name 'admin-api-openapi.*' -d 1 | xargs node ./scripts/version.js ${{ github.event.inputs.lastVersion }} ${{ github.event.inputs.releaseversion }}
echo "diff=$(git diff --numstat | wc -l)" >> $GITHUB_OUTPUT
- name: Commit formatted sources
if: steps.version.outputs.diff != '0'
run: |
git config --local user.email "daikoku-github-actions@users.noreply.github.com"
git config --local user.name "daikoku-github-actions"
git add --all
git commit -am "Update version number before release"
# - name: build manual
# id: manual
# run: |
# cd manual
# sbt "release 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 "daikoku-github-actions@users.noreply.github.com"
# 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 "daikoku-github-actions@users.noreply.github.com"
git config --local user.name "daikoku-github-actions"
cd daikoku
sbt "release 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/checkout@v2.2.0
with:
ref: 'v${{ github.event.inputs.releaseVersion }}'
# 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/create-release@v1.1.4
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/upload-release-asset@v1.0.2
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/upload-release-asset@v1.0.2
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: 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/prepare-release@0.1.2
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
REPO_OWNER: ${{ github.repository_owner }}
REPO: daikoku
IGNORE_MILESTONE_NOT_FOUND: true