Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08ac8c51be | ||
|
|
34ba9df440 | ||
|
|
071b3ed2ff | ||
|
|
a3d1acce41 | ||
|
|
88844d74f7 |
@@ -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"
|
||||||
@@ -24,6 +24,14 @@
|
|||||||
|
|
||||||
## 開發
|
## 開發
|
||||||
|
|
||||||
`ci.yaml` 跑 ,並用 `uses: ./` 實際執行一次。
|
`ci.yaml` 用 `uses: ./` 實際執行一次。
|
||||||
|
|
||||||
圖示:`icon.svg`(Gitea 儲存庫頭像用 `icon.png`)。
|
圖示:`icon.svg`(Gitea 儲存庫頭像用 `icon.png`)。
|
||||||
|
|
||||||
|
## 內部引用的版本
|
||||||
|
|
||||||
|
`ci-cache`、`ci-env` 的版本取自呼叫端 repo 的 Gitea 變數 `ACTION_CI_CACHE_VERSION`、`ACTION_CI_ENV_VERSION`,不寫死在 `action.yml`,所以呼叫端要先設好這兩個變數。
|
||||||
|
|
||||||
|
## 發版
|
||||||
|
|
||||||
|
`main` 的 `ci` 通過後,`cd.yaml` 用 [release-go](https://gitea.jsc.idv.tw/actions/release-go) 算下一個版本並打標籤(只遞增 patch,每位最大 9);只動文件、圖示、測試、`.gitea/`、`go.mod` 時不發版。呼叫端要把 Gitea 變數 `ACTION_CI_RUN_VERSION` 改成新標籤才會採用。
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
name: ci-run
|
name: ci-run
|
||||||
description: "跑一個 CI 工作:還原快取(ci-cache)→ 在 ci-env 容器裡執行指令。要在 checkout 之後使用,需要工具鏈時呼叫的工作流要有 env: GO_VERSION、NODE_VERSION"
|
description: "跑一個 CI 工作:還原快取(ci-cache)→ 在 ci-env 容器裡執行指令。內部用的 ci-cache、ci-env 版本取自呼叫端的 Gitea 變數 ACTION_CI_CACHE_VERSION、ACTION_CI_ENV_VERSION。要在 checkout 之後使用,需要工具鏈時呼叫的工作流要有 env: GO_VERSION、NODE_VERSION"
|
||||||
inputs:
|
inputs:
|
||||||
command:
|
command:
|
||||||
description: "要在 ci-env 容器裡執行的 shell 指令"
|
description: "要在 ci-env 容器裡執行的 shell 指令"
|
||||||
@@ -16,11 +16,11 @@ inputs:
|
|||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
- uses: https://gitea.jsc.idv.tw/actions/ci-cache@v0.0.1
|
- uses: https://gitea.jsc.idv.tw/actions/ci-cache@${{ vars.ACTION_CI_CACHE_VERSION }}
|
||||||
with:
|
with:
|
||||||
key: ${{ inputs.cache_key }}
|
key: ${{ inputs.cache_key }}
|
||||||
restore_keys: ${{ inputs.cache_restore_keys }}
|
restore_keys: ${{ inputs.cache_restore_keys }}
|
||||||
- name: ${{ inputs.name }}
|
- name: ${{ inputs.name }}
|
||||||
uses: https://gitea.jsc.idv.tw/actions/ci-env@v0.0.1
|
uses: https://gitea.jsc.idv.tw/actions/ci-env@${{ vars.ACTION_CI_ENV_VERSION }}
|
||||||
with:
|
with:
|
||||||
command: ${{ inputs.command }}
|
command: ${{ inputs.command }}
|
||||||
|
|||||||
Reference in New Issue
Block a user