-
-
Notifications
You must be signed in to change notification settings - Fork 1
135 lines (135 loc) · 4.36 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
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 default nightly
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.event.repository.name }}_${{ github.ref_name }}.zip
RELEASE_NAME: Ju.N.Owen
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
- name: Release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ env.RELEASE_NAME }} ${{ github.ref_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 default nightly
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