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
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,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
Expand Down
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