mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-05-07 16:53:40 +08:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1ada17f30 | ||
|
|
cb0ac7eb67 | ||
|
|
31efedbde9 | ||
|
|
3defb07325 | ||
|
|
e36f829e70 | ||
|
|
c20b579523 | ||
|
|
ceec222604 | ||
|
|
60ea7795ae | ||
|
|
6cbacbd127 | ||
|
|
8ea2fbe0f9 | ||
|
|
e3fded16ac |
27
.github/workflows/docker-image-debug.yml
vendored
27
.github/workflows/docker-image-debug.yml
vendored
@@ -12,18 +12,37 @@ jobs:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ secrets.DOCKERHUB_USERNAME }}/bili-sync
|
||||
tags: |
|
||||
type=raw,value=debug
|
||||
-
|
||||
name: Set Up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
-
|
||||
name: Set Up Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
-
|
||||
name: Build and push images
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
file: Dockerfile
|
||||
platforms: |
|
||||
linux/amd64
|
||||
linux/arm64/v8
|
||||
push: true
|
||||
tags: |
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/bili-sync:debug
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha, scope=${{ github.workflow }}
|
||||
cache-to: type=gha, scope=${{ github.workflow }}
|
||||
29
.github/workflows/docker-image.yml
vendored
29
.github/workflows/docker-image.yml
vendored
@@ -12,22 +12,41 @@ jobs:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ secrets.DOCKERHUB_USERNAME }}/bili-sync
|
||||
tags: |
|
||||
type=raw,value=${{ github.ref_name }}
|
||||
type=raw,value=latest
|
||||
-
|
||||
name: Set Up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
-
|
||||
name: Set Up Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
-
|
||||
name: Build and push images
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
file: Dockerfile
|
||||
platforms: |
|
||||
linux/amd64
|
||||
linux/arm64/v8
|
||||
push: true
|
||||
tags: |
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/bili-sync:${{ github.ref_name }}
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/bili-sync:latest
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha, scope=${{ github.workflow }}
|
||||
cache-to: type=gha, scope=${{ github.workflow }}
|
||||
-
|
||||
name: Update DockerHub description
|
||||
uses: peter-evans/dockerhub-description@v3
|
||||
|
||||
34
Dockerfile
34
Dockerfile
@@ -1,22 +1,30 @@
|
||||
FROM python:3.11.6-alpine3.18 AS base
|
||||
FROM python:3.11.7-alpine3.19
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV BILI_IN_DOCKER=true
|
||||
ENV LANG=zh_CN.UTF-8 \
|
||||
TZ=Asia/Shanghai \
|
||||
BILI_IN_DOCKER=true
|
||||
|
||||
RUN apk add --no-cache ffmpeg tini \
|
||||
&& apk add --no-cache --virtual .build-deps \
|
||||
gcc \
|
||||
musl-dev \
|
||||
libffi-dev \
|
||||
openssl-dev \
|
||||
&& pip install poetry
|
||||
|
||||
COPY poetry.lock pyproject.toml ./
|
||||
|
||||
RUN apk add ffmpeg \
|
||||
&& apk add --no-cache --virtual .build-deps \
|
||||
gcc \
|
||||
musl-dev \
|
||||
libffi-dev \
|
||||
openssl-dev \
|
||||
&& pip install poetry \
|
||||
&& poetry config virtualenvs.create false \
|
||||
&& poetry install --no-dev --no-interaction --no-ansi \
|
||||
&& apk del .build-deps
|
||||
RUN poetry config virtualenvs.create false \
|
||||
&& poetry install --only main --no-root \
|
||||
&& apk del .build-deps \
|
||||
&& rm -rf \
|
||||
/root/.cache \
|
||||
/tmp/*
|
||||
|
||||
COPY . .
|
||||
|
||||
ENTRYPOINT [ "python", "entry.py" ]
|
||||
ENTRYPOINT [ "tini", "python", "entry.py" ]
|
||||
|
||||
VOLUME [ "/app/config", "/app/data", "/app/thumb", "/Videos/Bilibilis" ]
|
||||
@@ -13,9 +13,9 @@
|
||||
|
||||
## 工作截图
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
## 配置文件
|
||||
|
||||
|
||||
14
migrations/models/3_20240104221037_update.py
Normal file
14
migrations/models/3_20240104221037_update.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from tortoise import BaseDBAsyncClient
|
||||
|
||||
|
||||
async def upgrade(db: BaseDBAsyncClient) -> str:
|
||||
return """
|
||||
CREATE TABLE IF NOT EXISTS "program" (
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
"version" VARCHAR(20) NOT NULL
|
||||
);"""
|
||||
|
||||
|
||||
async def downgrade(db: BaseDBAsyncClient) -> str:
|
||||
return """
|
||||
DROP TABLE IF EXISTS "program";"""
|
||||
16
models.py
16
models.py
@@ -14,6 +14,7 @@ from constants import (
|
||||
)
|
||||
from settings import settings
|
||||
from utils import aopen
|
||||
from version import VERSION
|
||||
|
||||
|
||||
class FavoriteList(Model):
|
||||
@@ -148,6 +149,11 @@ class FavoriteItem(Model):
|
||||
)
|
||||
|
||||
|
||||
class Program(Model):
|
||||
id = fields.IntField(pk=True)
|
||||
version = fields.CharField(max_length=20)
|
||||
|
||||
|
||||
async def init_model() -> None:
|
||||
await Tortoise.init(config=TORTOISE_ORM)
|
||||
migrate_commands = (
|
||||
@@ -157,3 +163,13 @@ async def init_model() -> None:
|
||||
)
|
||||
process = await create_subprocess_exec(*migrate_commands)
|
||||
await process.communicate()
|
||||
program, created = await Program.get_or_create(
|
||||
defaults={
|
||||
"version": VERSION,
|
||||
}
|
||||
)
|
||||
if created or program.version != VERSION:
|
||||
# 把新版本的迁移逻辑写在这里
|
||||
pass
|
||||
program.version = VERSION
|
||||
await program.save()
|
||||
|
||||
945
poetry.lock
generated
945
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "bili-sync"
|
||||
version = "1.0.1"
|
||||
version = "1.1.3"
|
||||
description = ""
|
||||
authors = ["amtoaer <amtoaer@gmail.com>"]
|
||||
license = "GPL-3.0"
|
||||
@@ -8,18 +8,19 @@ readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.11"
|
||||
bilibili-api-python = { git = "https://github.com/amtoaer/bilibili-api.git", rev = "dev" }
|
||||
dataclasses-json = "0.6.2"
|
||||
tortoise-orm = "0.20.0"
|
||||
loguru = "0.7.2"
|
||||
uvloop = "0.19.0"
|
||||
aiofiles = "23.2.1"
|
||||
aerich = "0.7.2"
|
||||
aiofiles = "23.2.1"
|
||||
bilibili-api-python = {git = "https://github.com/amtoaer/bilibili-api", rev = "dev"}
|
||||
dataclasses-json = "0.6.2"
|
||||
loguru = "0.7.2"
|
||||
tortoise-orm = "0.20.0"
|
||||
uvloop = "0.19.0"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
black = "23.11.0"
|
||||
ruff = "0.1.6"
|
||||
bump-my-version = "0.15.4"
|
||||
ipython = "8.17.2"
|
||||
ruff = "0.1.6"
|
||||
|
||||
[tool.black]
|
||||
line-length = 80
|
||||
@@ -60,6 +61,22 @@ tortoise_orm = "constants.TORTOISE_ORM"
|
||||
location = "./migrations"
|
||||
src_folder = "./."
|
||||
|
||||
[tool.bumpversion]
|
||||
commit = true
|
||||
message = "chore: bump version from {current_version} to {new_version}"
|
||||
tag = true
|
||||
tag_name = "{new_version}"
|
||||
tag_message = ""
|
||||
current_version = "1.1.3"
|
||||
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
||||
|
||||
[[tool.bumpversion.files]]
|
||||
filename = "version.py"
|
||||
|
||||
[[tool.bumpversion.files]]
|
||||
filename = "pyproject.toml"
|
||||
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
1
version.py
Normal file
1
version.py
Normal file
@@ -0,0 +1 @@
|
||||
VERSION = "1.1.3"
|
||||
Reference in New Issue
Block a user