Release ghdeb .deb packages #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release ghdeb .deb packages | |
| on: | |
| push: | |
| tags: | |
| - 'v*' # 打 tag(如 v0.7.53)即自动发版 | |
| workflow_dispatch: # 手动触发(可选版本号) | |
| inputs: | |
| version: | |
| description: '版本号(如 0.7.53),留空则用当前分支' | |
| required: false | |
| default: '' | |
| permissions: | |
| contents: write # 需要创建 GitHub Release | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # release notes 需要完整 git 历史 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.24.4' | |
| - name: Build all debs and create GitHub Release | |
| id: build | |
| env: | |
| GH_TOKEN: ${{ github.token }} # Actions 里 gh 需要显式 token | |
| INPUT_VERSION: ${{ github.event.inputs.version }} | |
| run: | | |
| # 版本号:手动触发优先取输入;tag 触发取 tag(v0.7.53 → 0.7.53) | |
| export VERSION="${INPUT_VERSION:-${GITHUB_REF_NAME#v}}" | |
| if [[ -z "$VERSION" || "$VERSION" == *" "* ]]; then | |
| echo "❌ 无法确定版本号(tag 触发需要 v* 标签)"; exit 1 | |
| fi | |
| echo "🚀 自动发版 v${VERSION}" | |
| bash release.sh --push | |
| echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT" | |
| # 注意:GITHUB_TOKEN 创建的 release 不会触发 release 事件(防递归), | |
| # 所以在这里直接 dispatch 给 apt-repo(repository_dispatch 不受防递归限制)。 | |
| - name: Dispatch to Freelamp APT Repo | |
| env: | |
| APT_REPO_TOKEN: ${{ secrets.APT_REPO_TOKEN }} | |
| TAG: ${{ steps.build.outputs.tag }} | |
| run: | | |
| echo "📡 通知 apt-repo 同步 ghdeb@${TAG}" | |
| curl -fsSL -X POST https://api.github.com/repos/LeisureLinux/apt-repo/dispatches \ | |
| -H "Authorization: Bearer ${APT_REPO_TOKEN}" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Content-Type: application/json" \ | |
| -d "{\"event_type\":\"publish\",\"client_payload\":{\"owner\":\"LeisureLinux\",\"repo\":\"ghdeb\",\"tag\":\"${TAG}\"}}" | |
| echo "✅ 已通知 apt-repo 同步 ghdeb@${TAG}" |