diff --git a/.gitea/workflows/cd.yaml b/.gitea/workflows/cd.yaml index 065424d..dced1a7 100644 --- a/.gitea/workflows/cd.yaml +++ b/.gitea/workflows/cd.yaml @@ -1,12 +1,12 @@ name: cd -# main 的 ci 通過後:用 release-go 的 next-version 算下一版,沒有跳過就在剛通過 ci 的提交上打標籤並推送。 +# 只在 dev → main 的 PR 合併時發版(觸發條件與羽藏的 cd.yaml 相同):用 release-go 的 next-version 算下一版,沒有跳過就在 PR 來源分支的最新提交(pull_request.head.sha)上打標籤並推送。 +# branches 寫死 main;PR 沒合併就關閉、或來源不是 dev 時,tag 工作在工作層級跳過。直接推送 main 不發版。 # 版本只遞增 patch、每位最大 9,沒有標籤時從 v0.0.1 開始。只動文件、圖示、測試、.gitea/、go.mod 時不發版(這些不會進映像檔,也不影響使用者)。 # 呼叫端用標籤引用這個 action(版本取自 Gitea 變數),所以發版後要到呼叫端把 ACTION_<名稱>_VERSION 改成新標籤才會生效。 -# workflow_run 只看 main:ci 在 push main 時跑,成功才觸發;失敗或取消不發版。 +# 沒有手動觸發:發版失敗時重跑這個 workflow 的 run。 on: - workflow_run: - workflows: [ci] - types: [completed] + pull_request: + types: [closed] branches: [main] # 排隊、不取消:連續推送依序發版,版本不重複 concurrency: @@ -14,13 +14,13 @@ concurrency: cancel-in-progress: false jobs: tag: - if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' }} + if: ${{ github.event.pull_request.merged == true && github.head_ref == 'dev' }} runs-on: docker-ubuntu steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ${{ github.event.workflow_run.head_sha }} + ref: ${{ github.event.pull_request.head.sha }} token: ${{ secrets.TOKEN || github.token }} - id: ver uses: https://gitea.jsc.idv.tw/actions/release-go@${{ vars.ACTION_RELEASE_GO_VERSION }} diff --git a/README.md b/README.md index a1b677d..2b96c6b 100644 --- a/README.md +++ b/README.md @@ -31,4 +31,4 @@ ## 發版 -`main` 的 `ci` 通過後,`cd.yaml` 用 [release-go](https://gitea.jsc.idv.tw/actions/release-go) 算下一個版本並打標籤(只遞增 patch,每位最大 9);只動文件、圖示、測試、`.gitea/`、`go.mod` 時不發版。呼叫端要把 Gitea 變數 `ACTION_PRUNE_GO_VERSION` 改成新標籤才會採用。 +只在 `dev` → `main` 的 PR 合併時(和羽藏的 `cd.yaml` 相同的觸發條件),`cd.yaml` 用 [release-go](https://gitea.jsc.idv.tw/actions/release-go) 算下一個版本,在 PR 來源分支的最新提交上打標籤(只遞增 patch,每位最大 9);只動文件、圖示、測試、`.gitea/`、`go.mod` 時不發版。直接推送 `main` 不發版。呼叫端要把 Gitea 變數 `ACTION_PRUNE_GO_VERSION` 改成新標籤才會採用。