-
Notifications
You must be signed in to change notification settings - Fork 96
84 lines (72 loc) · 2.29 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
name: build
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
push:
branches: [ main ]
jobs:
build:
strategy:
matrix:
platform: [ ubuntu-latest ]
name: Build
runs-on: ${{ matrix.platform }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Get dependencies
run: |
sudo apt-get update -y
\cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python
run: uv python install
- name: Install dependencies
run: |
uv sync --default-index https://pypi.org/simple/
- name: Restore cache lock
id: cache-lock-restore
run: |
if git show-ref --verify --quiet refs/remotes/origin/release; then
git restore --source=origin/release sources/cache.lock || true
fi
- name: Restore cached sources
id: cache-restore
uses: actions/cache/restore@v4
with:
path: runtime/sources
key: cache-sources-${{ hashFiles('**/cache.lock') }}
- name: Sync sources
env:
PYTHONPATH: ${{ env.PYTHONPATH }}:${{ github.workspace }}/src
run: |
uv run src/main.py
date > sources/cache.lock
- name: Save cached sources
id: cache-save
uses: actions/cache/save@v4
with:
path: runtime/sources
key: cache-sources-${{ hashFiles('**/cache.lock') }}
- name: Cleanup
env:
PYTHONPATH: ${{ env.PYTHONPATH }}:${{ github.workspace }}/src
run: |
uv run src/cleanup.py
- name: Commit files
run: |
sudo git config --local user.email "github-actions[bot]@users.noreply.github.com"
sudo git config --local user.name "github-actions[bot]"
sudo git rm --cached --ignore-unmatch -r -f *
sudo git add .
sudo git commit -m "Add sync changes"
sudo git show-ref --verify --quiet refs/heads/release || sudo git checkout -b release
sudo git push -f origin release