-
-
Notifications
You must be signed in to change notification settings - Fork 1
160 lines (136 loc) · 4.27 KB
/
weekly-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
name: Weekly Build
on:
schedule:
- cron: '0 0 * * 0' # Runs every Sunday at midnight UTC
workflow_dispatch: # Allows manual triggering
jobs:
set-date:
runs-on: ubuntu-latest
outputs:
date: ${{ steps.set-date.outputs.date }}
linux-filename: sbepis-${{ steps.set-date.outputs.date }}-linux.tar.gz
windows-filename: sbepis-${{ steps.set-date.outputs.date }}-windows.zip
steps:
- name: Set date
id: set-date
run: echo "date=$(date +%Y-%m-%d-%H%M)" >> "$GITHUB_OUTPUT"
build-linux:
runs-on: ubuntu-latest
needs: [set-date]
env:
FILENAME: ${{ needs.set-date.outputs.linux-filename }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libasound2-dev libudev-dev
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Build the game
run: cargo build --release
- name: Compress build files
run: |
mkdir -p build/SBEPIS
cp ./target/release/sbepis build/SBEPIS/SBEPIS
cp -r ./sbepis/assets build/SBEPIS/
tar -czf $FILENAME -C build SBEPIS
- name: Install rclone
run: |
curl https://rclone.org/install.sh | sudo bash
- name: Configure rclone
run: |
mkdir -p ~/.config/rclone
cat <<EOF > ~/.config/rclone/rclone.conf
${{ secrets.RCLONE_CONFIG }}
EOF
- name: Upload build to Google Drive
run: rclone copy $FILENAME "gdrive:SBEPIS Builds"
build-windows:
runs-on: windows-latest
needs: [set-date]
env:
FILENAME: ${{ needs.set-date.outputs.windows-filename }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Build the game
run: cargo build --release
- name: Compress build files
run: |
mkdir build\SBEPIS
cp .\target\release\sbepis.exe build\SBEPIS\SBEPIS.exe
cp -r .\sbepis\assets build\SBEPIS\
Compress-Archive -Path .\build\SBEPIS -DestinationPath $env:FILENAME
- name: Install rclone
run: |
choco install rclone
- name: Configure rclone
run: |
$rcloneConfigPath = "$env:USERPROFILE\.config\rclone\rclone.conf"
mkdir -p (Split-Path $rcloneConfigPath)
@"
${{ secrets.RCLONE_CONFIG }}
"@ | Set-Content -Path $rcloneConfigPath
- name: Upload build to Google Drive
run: rclone copy $env:FILENAME "gdrive:SBEPIS Builds"
notify-discord:
runs-on: ubuntu-latest
needs: [set-date, build-linux, build-windows]
env:
DATE: ${{ needs.set-date.outputs.date }}
LINUX_FILENAME: ${{ needs.set-date.outputs.linux-filename }}
WINDOWS_FILENAME: ${{ needs.set-date.outputs.windows-filename }}
steps:
- name: Install rclone
run: |
curl https://rclone.org/install.sh | sudo bash
- name: Configure rclone
run: |
mkdir -p ~/.config/rclone
cat <<EOF > ~/.config/rclone/rclone.conf
${{ secrets.RCLONE_CONFIG }}
EOF
- name: Send Discord notification
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
LINUX_LINK=$(rclone link "gdrive:SBEPIS Builds/$LINUX_FILENAME")
WINDOWS_LINK=$(rclone link "gdrive:SBEPIS Builds/$WINDOWS_FILENAME")
EMBED_CONTENT=$(cat <<EOF
{
"embeds": [
{
"title": "New Builds Available!",
"description": "Build Number: $DATE",
"color": 240116,
"fields": [
{
"name": "Windows",
"value": "[Download]($WINDOWS_LINK)",
"inline": true
},
{
"name": "Linux",
"value": "[Download]($LINUX_LINK)",
"inline": true
}
]
}
]
}
EOF
)
curl -H "Content-Type: application/json" \
-X POST \
-d "$EMBED_CONTENT" \
$DISCORD_WEBHOOK_URL