From 32d7fb0f45a1eb764b0fa10558882d9251005217 Mon Sep 17 00:00:00 2001 From: ShukeBta Date: Fri, 29 May 2026 00:32:13 +0800 Subject: [PATCH] ci: publish artifacts only on version tags --- .github/workflows/docker-publish.yml | 6 +--- .github/workflows/release.yml | 1 - README.md | 45 +++++++++++++++++++++++++++- README_EN.md | 6 ++-- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index f9dcdc8..adb9c5d 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -2,9 +2,7 @@ name: Publish Docker image on: push: - branches: [main] tags: ['v*', 'MediaStationGo-v*'] - workflow_dispatch: permissions: contents: read @@ -32,10 +30,8 @@ jobs: with: images: ghcr.io/shukebta/mediastation-go tags: | - type=raw,value=latest,enable={{is_default_branch}} - type=ref,event=branch + type=raw,value=latest type=ref,event=tag - type=sha,prefix= - name: Build & push uses: docker/build-push-action@v6 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ad4a9a..695fdff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,6 @@ name: Publish release packages on: push: tags: ['v*', 'MediaStationGo-v*'] - workflow_dispatch: permissions: contents: write diff --git a/README.md b/README.md index 3e61e02..5bc4e50 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ MediaStationGo 采用完全开源路线,核心媒体库、刮削、播放、 | 下载联动 | qBittorrent / PT Site Adapter | 站点搜索、订阅、下载任务展示与脱敏 | | 外部兼容 | Emby-style API / DLNA | 面向外部播放器与三端客户端 | | 部署 | Docker / Docker Compose / Shell / PowerShell | NAS、Linux、Windows 均可部署 | -| CI/CD | GitHub Actions / GHCR | 多架构镜像与 Release 包自动发布 | +| CI/CD | GitHub Actions / GHCR | 仅版本标签触发多架构镜像与 Release 包发布 | --- @@ -632,6 +632,49 @@ HTTP Header: x-api-key --- +## 🧪 构建、打包与发布 + +### Docker 镜像 + +默认镜像: + +```text +ghcr.io/shukebta/mediastation-go:latest +ghcr.io/shukebta/mediastation-go:MediaStationGo-v0.0.4 +``` + +> GitHub Actions 仅在推送 `v*` 或 `MediaStationGo-v*` 版本标签时发布 Docker 镜像,不会因 README、截图、文档或普通 `main` 分支提交重复打包。自动发布只生成 `latest` 与版本标签,不再发布 `main` 或短 SHA 标签。 + +Linux/macOS 推送: + +```bash +docker login ghcr.io +IMAGE=ghcr.io/shukebta/mediastation-go TAG=MediaStationGo-v0.0.4 ./scripts/docker-build-push.sh +``` + +Windows 推送: + +```powershell +docker login ghcr.io +.\scripts\docker-build-push.ps1 -Image ghcr.io/shukebta/mediastation-go -Tag MediaStationGo-v0.0.4 +``` + +仅本地构建: + +```powershell +.\scripts\docker-build-push.ps1 -Tag dev -Load +``` + +### Release 包 + +```bash +VERSION=MediaStationGo-v0.0.4 ./scripts/package-release.sh +``` + +GitHub Actions 会在推送 `v*` 或 `MediaStationGo-v*` 版本标签时自动生成 Release 包和 SHA256 校验文件;普通代码或文档提交不会创建 Release 包。 + +> 如果 Release 开启 immutable,不应覆盖同名资产;工作流已设置 `overwrite_files: false`,避免重跑时删除旧资产失败。 + --- ## 🔐 隐私与安全 diff --git a/README_EN.md b/README_EN.md index de1559a..28792e7 100644 --- a/README_EN.md +++ b/README_EN.md @@ -170,7 +170,7 @@ The current base license is `GPL-3.0`, and contributions are welcome under that | Downloads | qBittorrent / PT site adapters | Search, subscriptions, task cards, private URL redaction | | Compatibility | Emby-style API / DLNA | External clients and player integrations | | Deployment | Docker / Docker Compose / Shell / PowerShell | NAS, Linux, Windows, and macOS friendly | -| CI/CD | GitHub Actions / GHCR | Multi-arch Docker images and release packages | +| CI/CD | GitHub Actions / GHCR | Multi-arch Docker images and release packages only on version tags | --- @@ -640,6 +640,8 @@ ghcr.io/shukebta/mediastation-go:latest ghcr.io/shukebta/mediastation-go:MediaStationGo-v0.0.4 ``` +> GitHub Actions publishes Docker images only when a `v*` or `MediaStationGo-v*` version tag is pushed. README, screenshot, documentation, and normal `main` branch commits do not trigger image packaging. Automated publishing now emits only `latest` and the version tag, not `main` or short SHA tags. + Linux/macOS push: ```bash @@ -666,7 +668,7 @@ Local build only: VERSION=MediaStationGo-v0.0.4 ./scripts/package-release.sh ``` -GitHub Actions automatically builds release packages and SHA256 checksums when a `MediaStationGo-v*` tag is pushed. +GitHub Actions automatically builds release packages and SHA256 checksums when a `v*` or `MediaStationGo-v*` version tag is pushed. Normal code or documentation commits do not create release packages. > If immutable releases are enabled, same-name assets should not be overwritten. The workflow uses `overwrite_files: false` to avoid deleting immutable assets on reruns.