Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
399 changes: 399 additions & 0 deletions .github/scripts/prepare_release_line.py

Large diffs are not rendered by default.

97 changes: 97 additions & 0 deletions .github/workflows/prepare-release-line.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
# SPDX-License-Identifier: GPL-3.0-or-later
name: Prepare release line

on:
workflow_dispatch:
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
inputs:
release_line:
description: 已合并配置的 G2 发布线 ID
required: true
type: string
dry_run:
description: 只读全部预检与实际就绪状态
required: false
type: boolean
default: true

permissions:
contents: read

concurrency:
group: prepare-release-line-${{ inputs.release_line }}
cancel-in-progress: false
queue: max

jobs:
prepare:
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
environment: release-line-prepare
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Create installation token
id: app_token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
permission-actions: write
permission-contents: write
permission-pull-requests: read
permission-administration: read

- name: Verify maintainer
if: ${{ !inputs.dry_run }}
env:
GH_TOKEN: ${{ steps.app_token.outputs.token }}
ACTOR: ${{ github.actor }}
run: |
permission=$(gh api "repos/$GITHUB_REPOSITORY/collaborators/$ACTOR/permission" --jq .permission)
case "$permission" in
admin|maintain) ;;
*) echo "::error::$ACTOR does not have maintainer permission"; exit 1 ;;
esac

- name: Try Administration Write for protection
id: admin_token
if: ${{ !inputs.dry_run }}
continue-on-error: true
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
permission-actions: write
permission-contents: write
permission-pull-requests: read
permission-administration: write

- name: Checkout trusted template default branch
uses: actions/checkout@v5
with:
ref: ${{ github.event.repository.default_branch }}
persist-credentials: false

- name: Checkout trusted dde default branch
uses: actions/checkout@v5
with:
repository: ${{ github.repository_owner }}/dde
token: ${{ steps.app_token.outputs.token }}
path: coordinator
persist-credentials: false

- name: Install deps
run: pip install --quiet pyyaml

- name: Prepare and verify G2 members
env:
GH_TOKEN: ${{ steps.admin_token.outputs.token || steps.app_token.outputs.token }}
APP_ID: ${{ secrets.APP_ID }}
RELEASE_LINE: ${{ inputs.release_line }}
DRY_RUN: ${{ inputs.dry_run }}
ADMIN_WRITE: ${{ steps.admin_token.outcome == 'success' }}
CAN_CREATE_BRANCH: "true"
COORDINATOR_DIR: coordinator
run: python3 .github/scripts/prepare_release_line.py
60 changes: 55 additions & 5 deletions .github/workflows/templates-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:
jobs:
templates-sync:
# limit push on linuxdeepin/.github master branch
if: github.repository == 'linuxdeepin/.github' && github.ref == 'refs/heads/master'
if: github.repository == 'linuxdeepin/.github' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Organization-specific sync job skips

When prepare dispatches templates-sync from a .github repository outside linuxdeepin, the job condition requires github.repository to equal linuxdeepin/.github, so the dispatched job skips; sync_templates then times out and Prepare leaves created branches without synchronized workflows or protection checks.

Allow the job to run in the dispatched organization’s .github repository while retaining the default-branch condition.

Prompt for AI agents
In `.github/workflows/templates-sync.yml` at line 17:

**Organization-specific sync job skips**

When prepare dispatches templates-sync from a `.github` repository outside `linuxdeepin`, the job condition requires `github.repository` to equal `linuxdeepin/.github`, so the dispatched job skips; `sync_templates` then times out and Prepare leaves created branches without synchronized workflows or protection checks.

Allow the job to run in the dispatched organization’s `.github` repository while retaining the default-branch condition.

Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
Expand All @@ -37,7 +37,6 @@ jobs:
separator: " "
files: |
workflow-templates/*.yml
.github/workflows/templates-sync.yml

# Install ssh key and known_hosts
- name: Git config
Expand All @@ -54,7 +53,7 @@ jobs:

- name: Sync changed configs
uses: linuxdeepin/action-sync@main
if: steps.changed-configs.outputs.any_changed == 'true'
if: steps.changed-configs.outputs.any_changed == 'true' && steps.changed-files.outputs.any_changed != 'true'
with:
files: "${{ steps.changed-configs.outputs.all_changed_files }}"
message: |
Expand All @@ -67,14 +66,14 @@ jobs:

- name: Get all configs
id: all-configs
if: steps.changed-files.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch'
if: github.event_name != 'workflow_dispatch' && steps.changed-files.outputs.any_changed == 'true' && steps.changed-configs.outputs.any_changed != 'true'
run: |
all_configs=`find repos -type f | grep json | xargs`
echo all configs $all_configs
echo "ALL_CONFIGS=$all_configs" >> $GITHUB_OUTPUT
- name: Sync all files
uses: linuxdeepin/action-sync@main
if: steps.changed-files.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch'
if: github.event_name != 'workflow_dispatch' && steps.changed-files.outputs.any_changed == 'true' && steps.changed-configs.outputs.any_changed != 'true'
with:
files: "${{ steps.all-configs.outputs.ALL_CONFIGS }}"
message: |
Expand All @@ -84,3 +83,54 @@ jobs:

Log: none
Influence: none

- name: Prepare release-line sync configs
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && steps.changed-configs.outputs.any_changed == 'true')
run: |
python3 - <<'PY'
import json
import os
from pathlib import Path

owner = os.environ["GITHUB_REPOSITORY_OWNER"]
names = {
"call-update-changelog.yml": Path(".github/release-line-update.json"),
"call-verify-group-version.yml": Path(".github/release-line-guard.json"),
}
output = {name: [] for name in names}
for path in Path("repos", owner).glob("*.json"):
found = {}
for entry in json.loads(path.read_text(encoding="utf-8")):
name = Path(entry.get("src", "")).name
if name in names and entry.get("dest", "").startswith(f"{owner}/"):
found[name] = entry
if set(found) == set(names):
for name, entry in found.items():
output[name].append(entry)
for name, entries in output.items():
if not entries:
raise RuntimeError(f"missing release-line config: {name}")
names[name].write_text(json.dumps(entries, ensure_ascii=False), encoding="utf-8")
PY

- name: Sync release-line update template

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Develop dispatch targets master

When a maintainer runs the synced workflow from a develop branch and accepts its default inputs, the synced caller keeps base_branch defaulted to master and passes it to the reusable workflow, which checks out that branch. A maintainer running the newly available workflow from a develop/... branch with the defaults therefore generates the changelog and PR for master instead of the selected release line.

Make the caller default its base branch to the selected workflow ref, or otherwise require an explicit branch for non-master runs.

Prompt for AI agents
In `.github/workflows/templates-sync.yml` at line 117:

**Develop dispatch targets master**

When a maintainer runs the synced workflow from a develop branch and accepts its default inputs, the synced caller keeps `base_branch` defaulted to `master` and passes it to the reusable workflow, which checks out that branch. A maintainer running the newly available workflow from a `develop/...` branch with the defaults therefore generates the changelog and PR for master instead of the selected release line.

Make the caller default its base branch to the selected workflow ref, or otherwise require an explicit branch for non-master runs.

if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && steps.changed-configs.outputs.any_changed == 'true')
uses: linuxdeepin/action-sync@main
with:
files: .github/release-line-update.json
message: |
chore: Sync release-line update template

Log: none
Influence: none

- name: Sync release-line guard template
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && steps.changed-configs.outputs.any_changed == 'true')
uses: linuxdeepin/action-sync@main
with:
files: .github/release-line-guard.json
message: |
chore: Sync release-line guard template

Log: none
Influence: none
Loading
Loading