Files
shellcheck/.gitea/workflows/cd.yaml
T

46 lines
2.2 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: cd
# 只在 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。
on:
pull_request:
types: [closed]
branches: [main]
# 排隊、不取消:連續推送依序發版,版本不重複
concurrency:
group: cd
cancel-in-progress: false
jobs:
tag:
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.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 }}
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"