This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
145 lines (121 loc) · 5.41 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
name: Release
on:
workflow_dispatch:
pull_request_target:
branches:
- master
types:
- closed
jobs:
release:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true
outputs:
version: ${{ steps.tag_version.outputs.new_version }}
release-upload-url: ${{ steps.create_release.outputs.upload_url }}
release-html-url: ${{ steps.create_release.outputs.html_url }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: "minor"
custom_release_rules: "feat:minor:✨ Features,fix:patch:🐛 Fixes,docs:patch:📰 Docs,chore:patch:🎨 Chores,pref:patch:🎈 Performance improvements,refactor:patch:🧹 Refactoring,build:patch:🔍 Build,ci:patch:🔍 CI,revert:patch:⏪ Revert,style:patch:🧹 Style,test:patch:👀 Test"
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: adopt
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Sed Version
run: |
sed -r -i "1,/version/s#<version>(.+?)</version>#<version>${{ steps.tag_version.outputs.new_version }}</version>#" pom.xml
git diff
- name: Set PROJECT_NAME
id: vars
run: |
echo "PROJECT_NAME=`TOP=$(git rev-parse --show-toplevel); echo ${TOP##*/}`" >> $GITHUB_OUTPUT
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Publish release
uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
release_name: ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
- name: Upload Release Asset
uses: shogo82148/actions-upload-release-asset@v1.6.4
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: target/*.jar
- name: Calculate hash
working-directory: ./target
run: |
sha256sum *.jar > sha256sum.txt
- name: Upload Release Asset sha256sum.txt
uses: shogo82148/actions-upload-release-asset@v1.6.4
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: target/sha256sum.txt
- name: Released comment
uses: actions/github-script@v6
if: github.event_name == 'pull_request_target'
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `# リリースが完了しました\n\n${{ steps.create_release.outputs.html_url }}`
})
deploy-production:
runs-on: ubuntu-latest
needs: release
steps:
- name: Deploy
id: deployRequest
uses: fjogeleit/http-request-action@master
with:
url: ${{ secrets.DEPLOY_URL }}
method: 'POST'
bearerToken: ${{ secrets.DEPLOY_KEY }}
ignoreStatusCodes: '500'
timeout: 600000
- name: Show Response
run: echo ${{ steps.deployRequest.outputs.response }}
- name: Is Successful Deploy
if: ${{ fromJson(steps.deployRequest.outputs.response).status == 'SUCCESSFUL' }}
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
# :white_check_mark: デプロイが完了しました
プルリクエストがマージされたため、本番環境へのデプロイを行いました。
バージョンは `${{ needs.release.outputs.version }}` です。稼働中バージョンの確認は Minecraft サーバ内で `/ver AntiAlts3` を実行することで確認できます。
反映は本番環境の再起動後ですので、アクティブログインユーザーの同意を得て再起動するか、3時の自動再起動を待ってください。
${{ needs.release.outputs.release-html-url }}
- name: Is Failed Deploy
if: ${{ fromJson(steps.deployRequest.outputs.response).status == 'ERROR' }}
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
# :x: デプロイに失敗しました
プルリクエストがマージされたため、本番環境へのデプロイを行おうとしましたが失敗しました。
エラー内容は以下の通りです。
```
${{ fromJson(steps.deployRequest.outputs.response).type }} (${{ fromJson(steps.deployRequest.outputs.response).type_ja }}) - ${{ fromJson(steps.deployRequest.outputs.response).status }} (${{ fromJson(steps.deployRequest.outputs.response).status_ja }})
${{ fromJson(steps.deployRequest.outputs.response).message }}
```