Skip to content

Commit c2c19ad

Browse files
committed
feat: github actions
1 parent 34b6acf commit c2c19ad

2 files changed

Lines changed: 156 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build-linux-amd64:
8+
runs-on: ubuntu-latest
9+
10+
outputs:
11+
bot-artifact: ${{ steps.upload.outputs.bot }}
12+
web-artifact: ${{ steps.upload.outputs.web }}
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
with:
18+
submodules: recursive
19+
20+
- name: Install dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -y \
24+
build-essential cmake tar pkg-config \
25+
libmysqlclient-dev zlib1g-dev
26+
27+
- name: Configure project
28+
run: |
29+
mkdir -p build
30+
cd build
31+
cmake -DUSE_TLS=1 -DCMAKE_BUILD_TYPE=Release ..
32+
33+
- name: Build project
34+
run: |
35+
cd build
36+
make
37+
38+
- name: Generate Lua pages
39+
run: |
40+
cd build
41+
cmake --build . --target generate_lua_pages
42+
43+
- name: Archive bot
44+
run: |
45+
mkdir -p artifacts
46+
tar -czf artifacts/bot-amd64.tar.gz -C build/bot/bin .
47+
48+
- name: Archive web
49+
run: |
50+
tar -czf artifacts/web-amd64.tar.gz -C www .
51+
52+
- name: Upload artifacts
53+
id: upload
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: build-artifacts-amd64
57+
path: artifacts/
58+
59+
build-linux-arm64:
60+
runs-on: ubuntu-24.04-arm
61+
62+
outputs:
63+
bot-artifact: ${{ steps.upload.outputs.bot }}
64+
web-artifact: ${{ steps.upload.outputs.web }}
65+
66+
steps:
67+
- name: Checkout repository
68+
uses: actions/checkout@v3
69+
with:
70+
submodules: recursive
71+
72+
- name: Install dependencies
73+
run: |
74+
sudo apt-get update
75+
sudo apt-get install -y \
76+
build-essential cmake tar pkg-config \
77+
libmysqlclient-dev zlib1g-dev
78+
79+
- name: Configure project
80+
run: |
81+
mkdir -p build
82+
cd build
83+
cmake -DUSE_TLS=1 -DCMAKE_BUILD_TYPE=Release ..
84+
85+
- name: Build project
86+
run: |
87+
cd build
88+
make
89+
90+
- name: Generate Lua pages
91+
run: |
92+
cd build
93+
cmake --build . --target generate_lua_pages
94+
95+
- name: Archive bot
96+
run: |
97+
mkdir -p artifacts
98+
tar -czf artifacts/bot-arm64.tar.gz -C build/bot/bin .
99+
100+
- name: Archive web
101+
run: |
102+
tar -czf artifacts/web-arm64.tar.gz -C www .
103+
104+
- name: Upload artifacts
105+
id: upload
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: build-artifacts-arm64
109+
path: artifacts/

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Build"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
13+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
14+
15+
permissions:
16+
contents: write
17+
18+
steps:
19+
- name: Download amd64 artifacts
20+
uses: actions/download-artifact@v4
21+
with:
22+
name: build-artifacts-amd64
23+
path: artifacts/amd64
24+
run-id: ${{ github.event.workflow_run.id }}
25+
26+
- name: Download arm64 artifacts
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: build-artifacts-arm64
30+
path: artifacts/arm64
31+
run-id: ${{ github.event.workflow_run.id }}
32+
33+
- name: Set release tag
34+
run: echo "TAG=$(date +'%d%H%M')" >> $GITHUB_ENV
35+
36+
- name: Create GitHub Release
37+
uses: softprops/action-gh-release@v2
38+
with:
39+
tag_name: ${{ env.TAG }}
40+
name: Build ${{ env.TAG }}
41+
files: |
42+
artifacts/amd64/bot-amd64.tar.gz
43+
artifacts/amd64/web-amd64.tar.gz
44+
artifacts/arm64/bot-arm64.tar.gz
45+
artifacts/arm64/web-arm64.tar.gz
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)