13 Commits
Author SHA1 Message Date
admin 4877b4618b Merge pull request '調整:ci 只在 PR 觸發(拿掉 push: main)' (#2) from chore/ci-pr-only into main
Reviewed-on: #2
2026-11-05 04:55:56 +00:00
bot 67d6c7e685 調整:ci 只在 PR 觸發(拿掉 push: main,和羽藏一致)
cd / tag (pull_request) Successful in 4s
ci / test (pull_request) Successful in 42s
2026-11-05 04:53:13 +00:00
admin e2a339cff3 Merge pull request '調整:ci/cd 一致化,版本計算抽到 next-version' (#1) from chore/unify-ci-cd into main
ci / test (push) Successful in 9s
Reviewed-on: #1
2026-11-05 04:28:47 +00:00
bot ae4360ab00 調整:ci/cd 一致化(action-ci 自動偵測、action-cd)、版本計算抽到 next-version
cd / tag (pull_request) Successful in 1m12s
ci / test (pull_request) Successful in 5s
2026-11-05 04:12:39 +00:00
bot 5bca3d27ad 調整:cd 改成任何分支 → main 的 PR 合併時觸發
ci / test (push) Successful in 5s
2026-11-05 03:57:41 +00:00
bot fe29b942ba 調整:cd 觸發條件參考羽藏,只在 dev → main 的 PR 合併時發版
ci / test (push) Successful in 4s
2026-11-05 03:53:29 +00:00
bot e4f88496ea 調整:cd.yaml 不查 Go 套件庫(go_registry: false)
ci / test (push) Successful in 5s
2026-11-05 03:30:56 +00:00
bot 406b454241 新增:cd.yaml,main 的 ci 通過後用 release-go 算版本並打標籤 2026-11-05 03:30:07 +00:00
bot 9b31a447ea 調整:所有版本號改成從 Gitea 變數取得 2026-11-05 03:24:36 +00:00
bot 5c9c504de5 修正:Docker action 自測改用 action-ci 的唯一標籤映像檔,不再用 uses: ./
ci / test (push) Successful in 40s
2026-11-05 03:20:19 +00:00
bot 29a0966ce2 調整:ci.yaml 改用共用的 action-ci 與 shellcheck
ci / test (push) Successful in 40s
2026-11-05 03:17:09 +00:00
bot 440ba3dd8f 新增:GO_VERSION 可以填 go.mod
ci / test (push) Successful in 4s
2026-11-05 03:16:35 +00:00
bot b1b2204678 修正:icon.png 底部被截掉
ci / test (push) Successful in 41s
2026-11-05 03:11:10 +00:00
5 changed files with 36 additions and 16 deletions
+22
View File
@@ -0,0 +1,22 @@
name: cd
# 只在「任何分支 → main」的 PR 合併時發版:action-cd 用 next-version 算下一版,沒有跳過就在 PR 來源分支的最新提交(pull_request.head.sha)上打標籤並推送。
# branches 寫死 main,來源分支不限;PR 沒合併就關閉時,tag 工作在工作層級跳過。直接推送 main 不發版。
# 版本只遞增 patch、每位最大 9,沒有標籤時從 v0.0.1 開始。只動文件、圖示、測試、.gitea/、go.mod 時不發版(這些不會進映像檔,也不影響使用者)。
# 呼叫端用標籤引用這個 action(版本取自 Gitea 變數),所以發版後要到呼叫端把 ACTION_<名稱>_VERSION 改成新標籤才會生效。
# 沒有手動觸發:發版失敗時重跑這個 workflow 的 run。
on:
pull_request:
types: [closed]
branches: [main]
# 排隊、不取消:連續推送依序發版,版本不重複
concurrency:
group: cd
cancel-in-progress: false
jobs:
tag:
if: ${{ github.event.pull_request.merged == true }}
runs-on: docker-ubuntu
steps:
- uses: https://gitea.jsc.idv.tw/actions/action-cd@${{ vars.ACTION_ACTION_CD_VERSION }}
with:
token: ${{ secrets.TOKEN || github.token }}
+1 -9
View File
@@ -1,7 +1,5 @@
name: ci
on:
push:
branches: [main]
pull_request:
concurrency:
group: ci-${{ github.ref }}
@@ -10,10 +8,4 @@ jobs:
test:
runs-on: docker-ubuntu
steps:
- uses: actions/checkout@v4
- name: shellcheck
run: |
curl -fsSL https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.x86_64.tar.xz | tar -xJ -C "$RUNNER_TEMP" --strip-components=1
"$RUNNER_TEMP/shellcheck" -x -S warning ./*.sh
- name: 建置映像檔
run: docker build -t "action-test:$GITHUB_SHA" .
- uses: https://gitea.jsc.idv.tw/actions/action-ci@${{ vars.ACTION_ACTION_CI_VERSION }}
+5 -4
View File
@@ -26,8 +26,9 @@
|---|---|
|`zip`|模組 zip 的路徑(相對於 workspace),傳給 publish-go|
## 開發
## 開發與發版
`ci.yaml` 跑 shellcheck、、建置映像檔。
圖示:`icon.svg`(Gitea 儲存庫頭像用 `icon.png`)。
- CI(`ci.yaml`):用 [action-ci](https://gitea.jsc.idv.tw/actions/action-ci) 跑 shellcheck,建置映像檔。
- CD(`cd.yaml`):「任何分支 → `main`」的 PR 合併時,用 [action-cd](https://gitea.jsc.idv.tw/actions/action-cd) 算下一個版本([next-version](https://gitea.jsc.idv.tw/actions/next-version),只遞增 patch、每位最大 9)並在 PR 來源最新提交上打標籤;只動文件、圖示、測試、`.gitea/`、`go.mod` 時不發版。直接推送 `main` 不發版。
- 呼叫端要把 Gitea 變數 `ACTION_BUILD_GO_VERSION` 改成新標籤才會採用。
- 圖示:`icon.svg`(儲存庫頭像用 `icon.png`)。
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 21 KiB

+8 -3
View File
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
# 工具鏈與快取環境:被 source(不單獨執行),呼叫端已 set -euo pipefail 並 cd 到 workspace。
# GO_VERSION 可以填 go.mod,表示用 go.mod 的版本。
# 效果:HOME/GOPATH/GOCACHE 指到 workspace 的 .ci-home,GO_VERSION、NODE_VERSION 有設的就依版本下載到快取並加進 PATH(沒設的不裝)。
# 快取(Go 模組、npm、rod 下載的 Chromium 等)放在 workspace,讓 workflow 的 actions/cache 存取
export HOME="$PWD/.ci-home" GOPATH="$PWD/.ci-home/go" GOCACHE="$PWD/.ci-home/go-build" npm_config_cache="$PWD/.ci-home/npm"
@@ -17,11 +18,15 @@ fetch_toolchain() { # <名稱> <網址> <解壓參數> <檢查的執行檔>;
mkdir -p "$tc"
# Go 與 Node 的版本通常來自 Gitea 的 Actions 變數(workflow 的 env 傳進來),依版本裝在快取裡,換版本只要改變數
if [ -n "${GO_VERSION:-}" ]; then
fetch_toolchain "go-$GO_VERSION" "https://go.dev/dl/go$GO_VERSION.linux-amd64.tar.gz" -xz go
export PATH="$tc/go-$GO_VERSION/bin:$PATH"
go_ver=$GO_VERSION
# GO_VERSION=go.mod:用 go.mod 的 go 版本(不必另外維護變數)
[ "$go_ver" != go.mod ] || go_ver=$(sed -n 's/^go //p' go.mod)
[ -n "$go_ver" ] || { echo "GO_VERSION=go.mod,但 go.mod 沒有 go 版本" >&2; exit 1; }
fetch_toolchain "go-$go_ver" "https://go.dev/dl/go$go_ver.linux-amd64.tar.gz" -xz go
export PATH="$tc/go-$go_ver/bin:$PATH"
if [ -f go.mod ]; then
want=$(sed -n 's/^go //p' go.mod)
[ "$(go env GOVERSION)" = "go$want" ] || { echo "GO_VERSION($GO_VERSION)和 go.mod($want)不同,請更新變數" >&2; exit 1; }
[ "$(go env GOVERSION)" = "go$want" ] || { echo "GO_VERSION($go_ver)和 go.mod($want)不同,請更新變數" >&2; exit 1; }
fi
fi
if [ -n "${NODE_VERSION:-}" ]; then