-
-
Notifications
You must be signed in to change notification settings - Fork 1
184 lines (181 loc) · 6.08 KB
/
main.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: CI
on:
push:
branches: [main]
tags: [junowen-v*, junowen-server-v*]
pull_request:
branches: [main]
jobs:
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.cargo/git
key: cargo-index-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v3
with:
path: target
key: cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Init Rust
shell: bash
run: |
rustup target add i686-pc-windows-msvc
cargo install cargo-bundle-licenses
- name: Build
shell: bash
run: |
cargo build --locked --release --workspace
cargo bundle-licenses --format yaml --output THIRDPARTY.yml
mkdir --parents artifact/modules
mv \
./target/i686-pc-windows-msvc/release/th19_*.dll \
./artifact/modules/
mv \
./target/i686-pc-windows-msvc/release/*.dll \
./target/i686-pc-windows-msvc/release/*.exe \
./artifact/
cp --recursive LICENSE README.md THIRDPARTY.yml ./artifact/
- uses: actions/upload-artifact@v3
with:
name: artifact-windows
path: ./artifact
release-windows:
needs: build-windows
if: startsWith(github.ref, 'refs/tags/junowen-v')
runs-on: ubuntu-latest
env:
FILENAME: ${{ github.ref_name }}.zip
steps:
- uses: actions/download-artifact@v3
with:
name: artifact-windows
path: ./artifact
- name: Zip
run: |
cd artifact
zip ../${{ env.FILENAME }} d3d9.dll modules/th19_junowen.dll LICENSE README.md THIRDPARTY.yml
ref_name=${{github.ref_name}}
echo "RELEASE_NAME=${ref_name/junowen-/Ju.N.Owen }" >> "$GITHUB_ENV"
- name: Release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ env.RELEASE_NAME }}
files: ${{ env.FILENAME }}
build-release-windows-standalone:
needs: build-windows
if: startsWith(github.ref, 'refs/tags/junowen-v')
runs-on: ubuntu-latest
env:
FILENAME: ${{ github.ref_name }}-standalone.zip
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.cargo/git
key: cargo-index-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v3
with:
path: target
key: cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Init Rust
shell: bash
run: |
rustup target add i686-pc-windows-msvc
cargo install cargo-bundle-licenses
- name: Build
shell: bash
run: |
cargo build --locked --release --package junowen --features simple-dll-injection
cargo build --locked --release --package junowen --bin junowen-standalone
cargo bundle-licenses --format yaml --output THIRDPARTY.yml
mv \
target/i686-pc-windows-msvc/release/th19_junowen.dll \
junowen.dll
mv \
target/i686-pc-windows-msvc/release/junowen-standalone.exe \
junowen.exe
mv LICENSE README.md THIRDPARTY.yml .
zip ${{ env.FILENAME }} junowen.dll junowen.exe LICENSE README.md THIRDPARTY.yml
ref_name=${{github.ref_name}}
echo "RELEASE_NAME=${ref_name/junowen-/Ju.N.Owen }" >> "$GITHUB_ENV"
- name: Release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ env.RELEASE_NAME }}
files: ${{ env.FILENAME }}
build-server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.cargo/git
key: cargo-index-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v3
with:
path: target
key: cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Init Rust
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
rustup target add x86_64-unknown-linux-gnu
pip3 install cargo-lambda
mkdir ~/.aws
cat <<EOF > ~/.aws/config
[default]
aws_access_key_id = $AWS_ACCESS_KEY_ID
aws_secret_access_key = $AWS_SECRET_ACCESS_KEY
region = ap-northeast-1
EOF
- name: Build & Deploy dev
run: |
cargo lambda build --locked --package junowen-server --release
cargo lambda deploy --binary-name junowen-server junowen-server-dev
- uses: actions/upload-artifact@v3
with:
name: artifact-server
path: ./target/lambda
release-server:
needs: build-server
if: startsWith(github.ref, 'refs/tags/junowen-server-v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: artifact-server
path: ./target/lambda
- name: Init Rust
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
pip3 install cargo-lambda
mkdir ~/.aws
cat <<EOF > ~/.aws/config
[default]
aws_access_key_id = $AWS_ACCESS_KEY_ID
aws_secret_access_key = $AWS_SECRET_ACCESS_KEY
region = ap-northeast-1
EOF
- name: Deploy
run: |
cargo lambda deploy --binary-name junowen-server junowen-server