diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml index 5867abd26..b302b7625 100644 --- a/.github/workflows/create-tag.yml +++ b/.github/workflows/create-tag.yml @@ -1,4 +1,4 @@ -name: "(Tag): Create" +name: "(Release): Create Tag" on: pull_request: @@ -10,7 +10,7 @@ on: - pro-beta jobs: create-tag: - if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'tag/v') + if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v') runs-on: ubuntu-latest steps: - name: Checkout main diff --git a/.github/workflows/prepare-tag.yml b/.github/workflows/prepare-release.yml similarity index 80% rename from .github/workflows/prepare-tag.yml rename to .github/workflows/prepare-release.yml index 20a3ba94c..f3ebb784b 100644 --- a/.github/workflows/prepare-tag.yml +++ b/.github/workflows/prepare-release.yml @@ -1,4 +1,4 @@ -name: "(Tag): Prepare" +name: "(Release): Prepare" permissions: contents: write @@ -9,10 +9,15 @@ on: workflow_dispatch: inputs: version: - description: 'Version to create the tag for (e.g. 3.6.9) or `next`' + description: 'Version to prepare the release for (e.g. 3.6.9) or `next`' required: true type: string default: next + auto_changelog: + description: 'Auto-create changelog and readme entries with AI' + required: false + type: boolean + default: false jobs: version: @@ -66,7 +71,7 @@ jobs: workflow_file="${{ steps.validate.outputs.workflow_file }}" version="${{ needs.version.outputs.version || github.event.inputs.version }}" - echo "::notice::Dispatching workflow '$workflow_file' to generate changelog and readme entries..." + echo "::notice::Dispatching workflow '$workflow_file' to prepare the release pull request..." echo " Calling repo: $target_repo" echo " Version: $version" echo " Changelog path: ${GITHUB_EVENT_INPUTS_CHANGELOG_PATH:-./CHANGELOG.md}" @@ -79,19 +84,26 @@ jobs: --field repo="${{ github.repository }}" \ --field branch="${{ github.ref_name }}" \ --field version="$version" \ - --field readme_path="./src/readme.txt" ; then + --field readme_path="./src/readme.txt" \ + --field generate_changelog="${{ github.event.inputs.auto_changelog }}" ; then echo "::error::Failed to dispatch workflow '$workflow_file' in $target_repo" exit 1 fi + + # Runs are identified by their run-name so concurrent dispatches from + # the other repository are never mistaken for this one. + echo "expected_title=Prepare release v$version for ${{ github.repository }}" >> $GITHUB_OUTPUT echo "::notice::Successfully dispatched changelog generation" # Wait a moment for the run to be created echo "Waiting for workflow run to be created..." sleep 10 - + # Get the workflow run URL for monitoring - if run_url=$(gh run list --repo "$target_repo" --workflow "$workflow_file" --limit 1 --json url -q '.[0].url' 2>/dev/null); then + if run_url=$(gh run list --repo "$target_repo" --workflow "$workflow_file" --limit 15 \ + --json url,displayTitle \ + -q "[.[] | select(.displayTitle == \"Prepare release v$version for ${{ github.repository }}\")][0].url" 2>/dev/null); then if [ -n "$run_url" ] && [ "$run_url" != "null" ]; then echo "::notice::Workflow run: $run_url" echo "run_url=$run_url" >> $GITHUB_OUTPUT @@ -104,21 +116,22 @@ jobs: run: | target_repo="${{ steps.validate.outputs.target_repo }}" workflow_file="${{ steps.validate.outputs.workflow_file }}" + expected_title="${{ steps.dispatch.outputs.expected_title }}" max_attempts=30 attempt=0 - + echo "::notice::Monitoring workflow completion..." - + while [ $attempt -lt $max_attempts ]; do attempt=$((attempt + 1)) - - # Get latest run status + + # Get the status of this dispatch's run, matched by its run-name run_data=$(gh run list \ --repo "$target_repo" \ --workflow "$workflow_file" \ - --limit 1 \ - --json status,conclusion,url \ - -q '.[0] | [.status, .conclusion, .url] | @tsv' 2>/dev/null) + --limit 15 \ + --json status,conclusion,url,displayTitle \ + -q "[.[] | select(.displayTitle == \"$expected_title\")][0] | [.status, .conclusion, .url] | @tsv" 2>/dev/null) if [ -n "$run_data" ]; then status=$(echo "$run_data" | cut -f1) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 86a1b19f1..58e2423cd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,6 +48,30 @@ jobs: with: files: ${{ steps.zip.outputs.path }} + sync-pro: + # Only core releases sync downstream; this job is inert in the pro repository. + if: github.repository == 'codesnippetspro/code-snippets' + runs-on: ubuntu-latest + steps: + - name: Dispatch core to pro sync workflow + env: + GH_TOKEN: ${{ secrets.CHANGELOG_PAT }} + run: | + target_repo="codesnippetspro/.github-private" + workflow_file="sync-core-to-pro.yml" + + echo "::notice::Dispatching core to pro sync for ${{ github.event.release.tag_name }}" + + if ! gh workflow run "$workflow_file" \ + --repo "$target_repo" \ + --ref main \ + --field tag="${{ github.event.release.tag_name }}"; then + echo "::error::Failed to dispatch $workflow_file in $target_repo" + exit 1 + fi + + echo "::notice::Successfully dispatched core to pro sync" + deploy: needs: [build, upload] runs-on: ubuntu-latest diff --git a/AGENTS.md b/AGENTS.md index 702fbe4f2..f5f8c7695 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -172,8 +172,10 @@ plugins. - **Production branch:** `core` - **Pre-release branch:** `core-beta` - **Development branches:** `feat/…`, `fix/…`, `chore/…`, `hotfix/…` -- When creating the same logical branch on both remotes, suffix the Core branch with `-core` and the Pro branch with - `-pro` (for example, `chore/align-agent-rules-core` and `chore/align-agent-rules-pro`). +- Name every new branch with an edition suffix as its final path segment: `/core` in the Core repository and `/pro` + in the Pro repository (for example, `chore/align-agent-rules/core` and `chore/align-agent-rules/pro`). Repository + rules reject branch creation without the suffix. Release automation follows the same pattern + (`release/v…/core`, `sync/core-v…/pro`). - Branch from `core-beta` for all feature and fix work. - Open PRs back into `core-beta`. - Preserve granular history during development and use merge commits for active stack propagation. Squash-merging a