forked from planetarium/9c-launcher
-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (177 loc) · 6.17 KB
/
build.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
name: build
on:
push:
branches: ["*"]
tags: ["*"]
pull_request: []
jobs:
# APV 서명
sign-apv:
runs-on: ubuntu-latest
steps:
# 클론
- uses: actions/checkout@v2
if: github.event_name != 'pull_request'
with:
submodules: false
lfs: false
- uses: actions/checkout@v2
if: github.event_name == 'pull_request'
with:
ref: ${{ github.pull_request.head.sha }}
submodules: false
lfs: false
# Node.js 설치
- uses: actions/setup-node@v1
with:
node-version: "14"
# 의존성 설치
- run: yarn add @planetarium/cli
# APV 생성
- id: make-apv
run: 'echo "::set-output name=apv::$(scripts/make-apv.sh)"'
env:
APV_SIGN_KEY: ${{ secrets.APV_SIGN_KEY }}
outputs:
apv: ${{ steps.make-apv.outputs.apv }}
# 론처 빌드
build-launcher:
needs: sign-apv
env:
APV: ${{ needs.sign-apv.outputs.apv }}
strategy:
matrix:
os:
- macos-10.15
runs-on: ${{ matrix.os }}
steps:
# 클론
- uses: actions/checkout@v2
if: github.event_name != 'pull_request'
with:
submodules: recursive
ssh-key: ${{ secrets.SUBMODULE_PULL_KEY }}
lfs: false
- uses: actions/checkout@v2
if: github.event_name == 'pull_request'
with:
ref: ${{ github.pull_request.head.sha }}
submodules: recursive
ssh-key: ${{ secrets.SUBMODULE_PULL_KEY }}
lfs: false
# 이미 릴리스된 버전을 쓰고 있는지 검사
- run: |
set -vx
if [[ "$GITHUB_REF" != refs/tags/* ]] && \
git fetch --tags && \
(git tag | grep "^$(jq -r .version package.json)$"); then
urlvar="$(echo "${{ runner.os }}" | tr '[:lower:]' '[:upper:]')_URL"
curl -L -o github-commenter "${!urlvar}"
if [[ "${{ runner.os }}" != "Windows" ]]; then
chmod +x github-commenter
fi
export GITHUB_REPO="${GITHUB_REPOSITORY#*/}"
if [[ "${{ github.event_name }}" = "pull_request" ]]; then
pr_no=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
./github-commenter \
--type pr \
--number "$pr_no"
else
./github-commenter \
--type commit \
--sha "${{ github.sha }}"
fi
exit 1
fi
env:
# 다운로드할 때 쓰는 토큰
GH_TOKEN: ${{ secrets.GH_TOKEN }}
# 코멘트 달 때 쓰는 토큰
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_OWNER: ${{ github.repository_owner }}
GITHUB_COMMENT: |
*package.json* 파일의 `"version"`이 이미 Git 태그로 존재합니다.
버전 범프가 필요합니다.
<!-- 9c-launcher-version-warning -->
GITHUB_DELETE_COMMENT_REGEX: '.*<!-- +9c-launcher-version-warning +-->[ \n\t]*'
MACOS_URL: https://github.com/cloudposse/github-commenter/releases/download/0.6.1/github-commenter_darwin_amd64
WINDOWS_URL: https://github.com/cloudposse/github-commenter/releases/download/0.6.1/github-commenter_windows_amd64.exe
shell: bash
# Node.js 설치
- uses: actions/setup-node@v1
with:
node-version: "14"
- name: Pull node_modules cache
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}-build
# 의존성 설치
- run: yarn
# 코드 스타일 린트
- run: npx prettier --check "src/**/*.{ts,tsx,json}"
if: runner.os != 'Windows' # Windows uses CRLF line endings
# 빌드
- run: yarn build-prod
- name: Type Check
run: npx tsc --noEmit
if: github.event_name == 'pull_request'
# 이전 릴리스 버전으로부터 config.json 복사
- run: |
set -ex
latest_apv_no="$(yarn --silent latest-apv-no)"
temp_dir="$(mktemp -d)"
pushd "$temp_dir"
curl -o tmp.zip "$(printf "$URL_PATTERN" "$latest_apv_no")"
7z x tmp.zip resources/app/config.json
popd
mv "$temp_dir/resources/app/config.json" dist/
shell: bash
env:
URL_PATTERN: "https://download.nine-chronicles.com/v%d/Windows.zip"
# APV 서명 (config.json에 반영)
- run: yarn sign-apv
# 빌드 아티팩트
- if: runner.os == 'Windows'
run: 7z a -r "../9c-launcher-dist-${{ matrix.os }}.7z" *
working-directory: dist/
- if: runner.os != 'Windows'
run: tar cvfj "../9c-launcher-dist-${{ matrix.os }}.tar.bz2" *
working-directory: dist/
- uses: actions/upload-artifact@v2
with:
path: 9c-launcher-dist-${{ matrix.os }}.*
# 패키지
- if: github.ref == 'refs/heads/main'
run: |
pushd NineChronicles.Headless
dotnet clean -c Release
dotnet nuget locals all --clear
popd
yarn pack-release
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
SKIP_APV_SIGN: "1" # 위에서 npm run sign-apv 따로 돌림
- if: github.ref != 'refs/heads/main'
run: |
pushd NineChronicles.Headless
dotnet clean -c Release
dotnet nuget locals all --clear
popd
yarn pack-all
env:
SKIP_APV_SIGN: "1" # 위에서 npm run sign-apv 따로 돌림
# 패키지 아티팩트
- run: mkdir pack-dist/
- if: runner.os == 'Windows'
run: 7z a -r ../../pack-dist/Windows.zip *
working-directory: pack/Nine Chronicles-win32-x64/
- if: runner.os != 'Windows'
run: tar cvfz ../../pack-dist/macOS.tar.gz *
working-directory: pack/Nine Chronicles-darwin-x64/
- if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v2
with:
path: pack-dist/*