Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Build & Push Docker image

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request_target:
branches:
- main
Expand All @@ -15,6 +10,10 @@ on:
types:
- labeled
- synchronize
workflow_run:
workflows: ['Release']
types:
- completed

workflow_dispatch:

Expand Down Expand Up @@ -64,11 +63,17 @@ jobs:
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5

with:
images: ghcr.io/${{ steps.lowercase.outputs.owner }}/moontv
tags: |
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
type=match,pattern=v(.*),group=1,enable=${{ startsWith(github.ref, 'refs/tags/v') }}

- name: Get latest tag
run: |
echo "latest_tag=$(curl -s https://api.github.com/repos/${{ github.repository }}/tags | jq -r '.[0].name // "latest"' | sed 's/^v//')" >> $GITHUB_ENV

- name: Build and push by digest
id: build
Expand All @@ -78,7 +83,8 @@ jobs:
file: ./Dockerfile
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=ghcr.io/${{ steps.lowercase.outputs.owner }}/moontv,push-by-digest=true,name-canonical=true,push=true
tags: ghcr.io/${{ steps.lowercase.outputs.owner }}/moontv:${{ env.latest_tag }}
outputs: type=image,name=ghcr.io/${{ steps.lowercase.outputs.owner }}/moontv,name-canonical=true,push=true

- name: Export digest
run: |
Expand Down Expand Up @@ -128,6 +134,7 @@ jobs:
tags: |
type=ref,event=pr,prefix=pr-
type=raw,value=latest,enable={{is_default_branch}}
type=match,pattern=v(.*),group=1,enable=${{ startsWith(github.ref, 'refs/tags/v') }}

- name: Create manifest list and push
working-directory: /tmp/digests
Expand Down Expand Up @@ -171,7 +178,7 @@ jobs:
构建完成时间:${new Date().toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' })}`
});

cleanup:
cleanup-refresh:
runs-on: ubuntu-latest
needs:
- merge
Expand All @@ -184,13 +191,6 @@ jobs:
repository: ${{ github.repository }}
retain_days: 0
keep_minimum_runs: 2

version-cache-refresh:
runs-on: ubuntu-latest
needs:
- cleanup
if: always() && github.event_name != 'pull_request_target'
steps:
- name: Refresh VERSION.txt cache
run: |
echo "Refreshing VERSION.txt cache..."
Expand Down
96 changes: 96 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Release

on:
push:
tags:
- 'v*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
env:
TZ: Asia/Shanghai
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
echo "Tag: $TAG_NAME"

- name: Get tag message
id: tag_message
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_NAME=${{ steps.version.outputs.tag }}
RELEASE_BODY=$(gh release view "$TAG_NAME" --json body -q .body || echo "")
printf '%s\n' "$RELEASE_BODY" > /tmp/tag_message.txt
echo "Tag message saved to /tmp/tag_message.txt"
echo "Tag message content:"
cat /tmp/tag_message.txt

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Update version files and generate changelog
run: |
CURRENT_DATE=$(date +%Y-%m-%d)
VERSION="${{ steps.version.outputs.version }}"
TAG_MESSAGE=$(cat /tmp/tag_message.txt)
echo "Updating CHANGELOG file..."
{
echo "## [$VERSION] - $CURRENT_DATE"
echo ""
cat /tmp/tag_message.txt
echo ""
} > /tmp/new_entry.txt

if [ -f "CHANGELOG" ]; then
cp CHANGELOG CHANGELOG.bak
cat /tmp/new_entry.txt CHANGELOG.bak > CHANGELOG
else
cp /tmp/new_entry.txt CHANGELOG
fi
echo "✅ Updated CHANGELOG with new entry for version $VERSION"

echo "Updating VERSION.txt..."
echo "$VERSION" > VERSION.txt
echo "✅ Updated VERSION.txt to $VERSION"

echo "Generating changelog TypeScript file..."
node scripts/convert-changelog.js

echo "Updating version.ts..."
sed -i "s/const CURRENT_VERSION = '[^']*';/const CURRENT_VERSION = '$VERSION';/" src/lib/version.ts
echo "✅ Updated version.ts to $VERSION"

- name: Commit generated files
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add CHANGELOG VERSION.txt src/lib/changelog.ts src/lib/version.ts
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "chore: Bump to ${{ steps.version.outputs.version }}"
git push origin HEAD:main
echo "Committed and pushed generated files"
fi
6 changes: 0 additions & 6 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm check:version

pnpm gen:changelog
git add src/lib/version.ts
git add src/lib/changelog.ts

npx lint-staged
30 changes: 30 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
## [1.1.1] - 2025-08-12

### Changed
- 修正 zwei 提供的 cors proxy 地址
- 移除废弃代码

### Fixed
- [运维] docker workflow release 日期使用东八区日期

## [1.1.0] - 2025-08-12

### Added
- 每日新番放送功能,展示每日新番放送的番剧

### Fixed
- 修复远程 CHANGELOG 无法提取变更内容的问题

## [1.0.5] - 2025-08-12

### Changed
- 实现基于 Git 标签的自动 Release 工作流

## [1.0.4] - 2025-08-11

### Added
- 优化版本管理工作流,实现单点修改

### Changed
- 版本号现在从 CHANGELOG 自动提取,无需手动维护 VERSION.txt

## [1.0.3] - 2025-08-11

### Changed
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,22 @@

```bash
# 拉取预构建镜像
# 推荐使用具体版本号标签,确保稳定性
docker pull ghcr.io/lunatechlab/moontv:1.0.4
# 或拉取最新版本
docker pull ghcr.io/lunatechlab/moontv:latest

# 运行容器
# -d: 后台运行 -p: 映射端口 3000 -> 3000
docker run -d --name moontv -p 3000:3000 --env PASSWORD=your_password ghcr.io/lunatechlab/moontv:latest
```

#### 可用标签

- `ghcr.io/lunatechlab/moontv:1.0.4` - 具体版本号,推荐用于生产环境
- `ghcr.io/lunatechlab/moontv:latest` - 最新版本,可能包含最新功能但也可能有未测试的变化
- `ghcr.io/lunatechlab/moontv:pr-{number}` - PR 构建版本,用于测试新功能

访问 `http://服务器 IP:3000` 即可。(需自行到服务器控制台放通 `3000` 端口)

## Docker Compose 最佳实践
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.3
1.1.1
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
"format:check": "prettier -c .",
"gen:runtime": "node scripts/convert-config.js",
"gen:manifest": "node scripts/generate-manifest.js",
"gen:changelog": "node scripts/convert-changelog.js",
"check:version": "node scripts/check-version.js",
"postbuild": "echo 'Build completed - sitemap generation disabled'",
"prepare": "husky install"
},
Expand Down
120 changes: 0 additions & 120 deletions scripts/check-version.js

This file was deleted.

Loading
Loading