Repository navigation
feat(ci): support independent G2 release lines #818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| 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: | ||
| 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Allow the job to run in the dispatched organization’s Prompt for AI agentsIn `.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.
sourcery-ai[bot] marked this conversation as resolved.
Resolved
|
||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
@@ -37,7 +37,6 @@ jobs: | |
| separator: " " | ||
| files: | | ||
| workflow-templates/*.yml | ||
| .github/workflows/templates-sync.yml | ||
|
|
||
| # Install ssh key and known_hosts | ||
| - name: Git config | ||
|
|
@@ -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: | | ||
|
|
@@ -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: | | ||
|
|
@@ -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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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 agentsIn `.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 | ||
Uh oh!
There was an error while loading. Please reload this page.