Skip to content
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/create-tag.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "(Tag): Create"
name: "(Release): Create Tag"

on:
pull_request:
Expand All @@ -10,22 +10,22 @@
- 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
uses: actions/checkout@v4

- name: Get version from package.json
id: version
run: |
tag=$(jq -r .version package.json)
echo "tag=$tag" >> $GITHUB_OUTPUT
echo "::info::Creating git tag [$tag]"

- name: Create tag
run: |
git config user.name "code-snippets-bot"
git config user.email "139164393+code-snippets-bot@users.noreply.github.com"
git tag "v${{ steps.version.outputs.tag }}"
git push origin "v${{ steps.version.outputs.tag }}"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "(Tag): Prepare"
name: "(Release): Prepare"

permissions:
contents: write
Expand All @@ -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:
Expand Down Expand Up @@ -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}"
Expand All @@ -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
Expand All @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading