Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45cb3db5ab | ||
|
|
2859d663c2 | ||
|
|
d392eb7fa9 | ||
|
|
ce3ab59c66 | ||
|
|
3567ef8844 | ||
|
|
59f63a7f7e | ||
|
|
9e13dad6ad |
@@ -0,0 +1,45 @@
|
|||||||
|
name: cd
|
||||||
|
# main 的 ci 通過後:用 release-go 的 next-version 算下一版,沒有跳過就在剛通過 ci 的提交上打標籤並推送。
|
||||||
|
# 版本只遞增 patch、每位最大 9,沒有標籤時從 v0.0.1 開始。只動文件、圖示、測試、.gitea/、go.mod 時不發版(這些不會進映像檔,也不影響使用者)。
|
||||||
|
# 呼叫端用標籤引用這個 action(版本取自 Gitea 變數),所以發版後要到呼叫端把 ACTION_<名稱>_VERSION 改成新標籤才會生效。
|
||||||
|
# workflow_run 只看 main:ci 在 push main 時跑,成功才觸發;失敗或取消不發版。
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: [ci]
|
||||||
|
types: [completed]
|
||||||
|
branches: [main]
|
||||||
|
# 排隊、不取消:連續推送依序發版,版本不重複
|
||||||
|
concurrency:
|
||||||
|
group: cd
|
||||||
|
cancel-in-progress: false
|
||||||
|
jobs:
|
||||||
|
tag:
|
||||||
|
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' }}
|
||||||
|
runs-on: docker-ubuntu
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
ref: ${{ github.event.workflow_run.head_sha }}
|
||||||
|
token: ${{ secrets.TOKEN || github.token }}
|
||||||
|
- id: ver
|
||||||
|
uses: https://gitea.jsc.idv.tw/actions/release-go@${{ vars.ACTION_RELEASE_GO_VERSION }}
|
||||||
|
with:
|
||||||
|
task: next-version
|
||||||
|
channel: release
|
||||||
|
go_registry: false
|
||||||
|
docs_pattern: '^\.gitea/|^icon\.|^test/|^go\.mod$|\.md$'
|
||||||
|
token: ${{ secrets.TOKEN || github.token }}
|
||||||
|
- name: 只動文件等檔案,不發版
|
||||||
|
if: ${{ steps.ver.outputs.skip == 'true' }}
|
||||||
|
run: echo "不發版"
|
||||||
|
- name: 打標籤並推送 ${{ steps.ver.outputs.version }}
|
||||||
|
if: ${{ steps.ver.outputs.skip != 'true' }}
|
||||||
|
env:
|
||||||
|
VERSION: ${{ steps.ver.outputs.version }}
|
||||||
|
TOKEN: ${{ secrets.TOKEN || github.token }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
git tag "$VERSION" HEAD
|
||||||
|
git push "${GITHUB_SERVER_URL%%://*}://oauth2:${TOKEN}@${GITHUB_SERVER_URL#*://}/${GITHUB_REPOSITORY}.git" "refs/tags/$VERSION"
|
||||||
|
echo "已推送標籤 $VERSION"
|
||||||
@@ -11,14 +11,7 @@ jobs:
|
|||||||
runs-on: docker-ubuntu
|
runs-on: docker-ubuntu
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: shellcheck
|
- uses: https://gitea.jsc.idv.tw/actions/action-ci@${{ vars.ACTION_ACTION_CI_VERSION }}
|
||||||
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
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
go_test: true
|
||||||
- name: 腳本黑箱測試
|
docker_build: true
|
||||||
run: go vet ./... && go test ./test/
|
|
||||||
- name: 建置映像檔
|
|
||||||
run: docker build -t "action-test:$GITHUB_SHA" .
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
# prune-packages
|
# prune-go
|
||||||
|
|
||||||
部署後的善後:正式版留最新 N 個、dev 版只留基底比最新正式版新的,剛部署的版本一定保留。任何失敗只印警告並以 0 結束。
|
部署後的善後:正式版留最新 N 個、dev 版只留基底比最新正式版新的,剛部署的版本一定保留。任何失敗只印警告並以 0 結束。
|
||||||
|
|
||||||
## 用法
|
## 用法
|
||||||
|
|
||||||
版本由呼叫端的 Gitea Actions 變數決定(例如 `vars.ACTION_PRUNE_PACKAGES_VERSION`),不要用分支名稱:runner 依 ref 重用舊映像檔,改了腳本不會生效,所以每次改動都發新標籤。
|
版本由呼叫端的 Gitea Actions 變數決定(例如 `vars.ACTION_PRUNE_GO_VERSION`),不要用分支名稱:runner 依 ref 重用舊映像檔,改了腳本不會生效,所以每次改動都發新標籤。
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: https://gitea.jsc.idv.tw/actions/prune-packages@${{ vars.ACTION_PRUNE_PACKAGES_VERSION }}
|
- uses: https://gitea.jsc.idv.tw/actions/prune-go@${{ vars.ACTION_PRUNE_GO_VERSION }}
|
||||||
with:
|
with:
|
||||||
version: ...
|
version: ...
|
||||||
token: ...
|
token: ...
|
||||||
@@ -25,6 +25,10 @@
|
|||||||
|
|
||||||
## 開發
|
## 開發
|
||||||
|
|
||||||
`ci.yaml` 跑 shellcheck、`test/` 的腳本黑箱測試(`go test ./test/`)、建置映像檔。
|
`ci.yaml` 用共用的 [action-ci](https://gitea.jsc.idv.tw/actions/action-ci) 跑 shellcheck、Go 黑箱測試、映像檔建置。
|
||||||
|
|
||||||
圖示:`icon.svg`(Gitea 儲存庫頭像用 `icon.png`)。
|
圖示:`icon.svg`(Gitea 儲存庫頭像用 `icon.png`)。
|
||||||
|
|
||||||
|
## 發版
|
||||||
|
|
||||||
|
`main` 的 `ci` 通過後,`cd.yaml` 用 [release-go](https://gitea.jsc.idv.tw/actions/release-go) 算下一個版本並打標籤(只遞增 patch,每位最大 9);只動文件、圖示、測試、`.gitea/`、`go.mod` 時不發版。呼叫端要把 Gitea 變數 `ACTION_PRUNE_GO_VERSION` 改成新標籤才會採用。
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
name: prune-packages
|
name: prune-go
|
||||||
description: "整理 Go 套件庫(Docker action,bash+curl):正式版留最新 5 個(KEEP_RELEASES)、dev 版只留基底比最新正式版新的,剛部署的版本一定保留。善後用:失敗只印警告、以 0 結束。要在 checkout 之後使用"
|
description: "整理 Go 套件庫(Docker action,bash+curl):正式版留最新 5 個(KEEP_RELEASES)、dev 版只留基底比最新正式版新的,剛部署的版本一定保留。善後用:失敗只印警告、以 0 結束。要在 checkout 之後使用"
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module gitea.jsc.idv.tw/actions/prune-packages
|
module gitea.jsc.idv.tw/actions/prune-go
|
||||||
|
|
||||||
go 1.27.1
|
go 1.27.1
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 14 KiB |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# 整理 Gitea 的 Go 套件庫:只刪這個專案模組的舊版本,其餘一律不動。CD 在部署成功後呼叫。
|
# 整理 Gitea 的 Go 套件庫:只刪這個專案模組的舊版本,其餘一律不動。CD 在部署成功後呼叫。
|
||||||
# .gitea/actions/prune-packages/prune-packages.sh [剛部署的版本]
|
# prune-packages.sh [剛部署的版本]
|
||||||
# 保留規則(剛部署的版本一定保留):
|
# 保留規則(剛部署的版本一定保留):
|
||||||
# - 正式版(vX.Y.Z):保留最新的 KEEP_RELEASES 個(預設 5)
|
# - 正式版(vX.Y.Z):保留最新的 KEEP_RELEASES 個(預設 5)
|
||||||
# - dev 版(vX.Y.Z-dev.N):只保留「比最新正式版更新的基底」,也就是下一個正式版的 dev 版;
|
# - dev 版(vX.Y.Z-dev.N):只保留「比最新正式版更新的基底」,也就是下一個正式版的 dev 版;
|
||||||
|
|||||||
Reference in New Issue
Block a user