Skip to content

Commit 35b6c2e

Browse files
committed
Merge branch 'main' into fix/174-pr-comment
2 parents 0c7e388 + aa33bb4 commit 35b6c2e

10 files changed

+731
-4
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Check Branch Alias
2+
3+
on:
4+
release:
5+
types: [released]
6+
workflow_dispatch:
7+
8+
permissions: {}
9+
10+
jobs:
11+
check-branch-alias:
12+
uses: wp-cli/.github/.github/workflows/reusable-check-branch-alias.yml@main
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "Copilot Setup Steps"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- .github/workflows/copilot-setup-steps.yml
8+
pull_request:
9+
paths:
10+
- .github/workflows/copilot-setup-steps.yml
11+
12+
jobs:
13+
copilot-setup-steps:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v6
21+
22+
- name: Check existence of composer.json file
23+
id: check_composer_file
24+
uses: andstor/file-existence-action@v3
25+
with:
26+
files: "composer.json"
27+
28+
- name: Set up PHP environment
29+
if: steps.check_composer_file.outputs.files_exists == 'true'
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: 'latest'
33+
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
34+
coverage: 'none'
35+
tools: composer,cs2pr
36+
env:
37+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Install Composer dependencies & cache dependencies
40+
if: steps.check_composer_file.outputs.files_exists == 'true'
41+
uses: ramsey/composer-install@v3
42+
env:
43+
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
44+
with:
45+
# Bust the cache at least once a month - output format: YYYY-MM.
46+
custom-cache-suffix: $(date -u "+%Y-%m")

.github/workflows/issue-triage.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Issue Triage
3+
4+
'on':
5+
issues:
6+
types: [opened]
7+
workflow_dispatch:
8+
inputs:
9+
issue_number:
10+
description: 'Issue number to triage (leave empty to process all)'
11+
required: false
12+
type: string
13+
14+
jobs:
15+
issue-triage:
16+
uses: wp-cli/.github/.github/workflows/reusable-issue-triage.yml@main
17+
with:
18+
issue_number: ${{ github.event_name == 'workflow_dispatch' && inputs.issue_number || github.event.issue.number }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Manage Labels
3+
4+
'on':
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- main
9+
- master
10+
paths:
11+
- 'composer.json'
12+
13+
permissions:
14+
issues: write
15+
contents: read
16+
17+
jobs:
18+
manage-labels:
19+
uses: wp-cli/.github/.github/workflows/reusable-manage-labels.yml@main
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Check Branch Alias
2+
3+
on:
4+
workflow_call:
5+
release:
6+
types: [released]
7+
workflow_dispatch:
8+
9+
# Cancels all previous workflow runs for pull requests that have not completed.
10+
concurrency:
11+
# The concurrency group contains the workflow name and the branch name for pull requests
12+
# or the commit hash for any other events.
13+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
14+
cancel-in-progress: true
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
check-branch-alias:
21+
name: Check and update branch-alias
22+
runs-on: ubuntu-latest
23+
if: ${{ github.repository_owner == 'wp-cli' }}
24+
permissions:
25+
contents: write # Required for creating pull requests
26+
pull-requests: write # Required for creating pull requests
27+
28+
steps:
29+
- name: Check out source code
30+
uses: actions/checkout@v5
31+
with:
32+
fetch-depth: 0 # Fetch all history for all tags
33+
token: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Set up PHP
36+
uses: shivammathur/setup-php@v2
37+
with:
38+
php-version: 'latest'
39+
tools: composer
40+
41+
- name: Check existence of composer.json file
42+
id: check_composer_file
43+
uses: andstor/file-existence-action@v3
44+
with:
45+
files: "composer.json"
46+
47+
- name: Check and update branch alias
48+
if: steps.check_composer_file.outputs.files_exists == 'true'
49+
id: check_alias
50+
run: |
51+
# Get the latest stable release tag (exclude pre-releases)
52+
LATEST_TAG=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-version:refname | head -n 1)
53+
54+
if [ -z "$LATEST_TAG" ]; then
55+
echo "No stable release tags found, skipping branch-alias check"
56+
echo "needs_update=false" >> "$GITHUB_OUTPUT"
57+
exit 0
58+
fi
59+
60+
echo "Latest tag: $LATEST_TAG"
61+
62+
# Extract version numbers (remove 'v' prefix and any pre-release/build metadata)
63+
VERSION="${LATEST_TAG#v}"
64+
# Remove any pre-release or build metadata (e.g., -alpha, +build)
65+
VERSION="${VERSION%%-*}"
66+
VERSION="${VERSION%%+*}"
67+
68+
# Parse major, minor, and patch versions
69+
IFS='.' read -r MAJOR MINOR _ <<< "$VERSION"
70+
71+
# Validate that MAJOR and MINOR are numeric
72+
if ! [[ "$MAJOR" =~ ^[0-9]+$ ]] || ! [[ "$MINOR" =~ ^[0-9]+$ ]]; then
73+
echo "Invalid version format: $VERSION"
74+
echo "needs_update=false" >> "$GITHUB_OUTPUT"
75+
exit 0
76+
fi
77+
78+
# Calculate next minor version
79+
NEXT_MINOR=$((MINOR + 1))
80+
EXPECTED_ALIAS="${MAJOR}.${NEXT_MINOR}.x-dev"
81+
82+
echo "Expected branch-alias: $EXPECTED_ALIAS"
83+
84+
# Determine which branch key is being used (dev-main or dev-master)
85+
BRANCH_KEY=""
86+
CURRENT_ALIAS=""
87+
88+
# Try dev-main first
89+
if composer config extra.branch-alias.dev-main > /dev/null 2>&1; then
90+
BRANCH_KEY="dev-main"
91+
CURRENT_ALIAS=$(composer config extra.branch-alias.dev-main)
92+
# Try dev-master if dev-main doesn't exist
93+
elif composer config extra.branch-alias.dev-master > /dev/null 2>&1; then
94+
BRANCH_KEY="dev-master"
95+
CURRENT_ALIAS=$(composer config extra.branch-alias.dev-master)
96+
else
97+
echo "No branch-alias found in composer.json, will use dev-main"
98+
BRANCH_KEY="dev-main"
99+
CURRENT_ALIAS=""
100+
fi
101+
102+
echo "Current branch-alias ($BRANCH_KEY): $CURRENT_ALIAS"
103+
104+
if [ "$CURRENT_ALIAS" != "$EXPECTED_ALIAS" ]; then
105+
echo "Branch alias needs update"
106+
{
107+
echo "needs_update=true"
108+
echo "expected_alias=$EXPECTED_ALIAS"
109+
echo "current_alias=$CURRENT_ALIAS"
110+
echo "branch_key=$BRANCH_KEY"
111+
echo "latest_tag=$LATEST_TAG"
112+
} >> "$GITHUB_OUTPUT"
113+
else
114+
echo "Branch alias is up to date"
115+
echo "needs_update=false" >> "$GITHUB_OUTPUT"
116+
fi
117+
118+
- name: Update composer.json
119+
if: steps.check_alias.outputs.needs_update == 'true'
120+
run: |
121+
BRANCH_KEY="${{ steps.check_alias.outputs.branch_key }}"
122+
EXPECTED_ALIAS="${{ steps.check_alias.outputs.expected_alias }}"
123+
124+
# Update the branch-alias using composer command
125+
composer config "extra.branch-alias.$BRANCH_KEY" "$EXPECTED_ALIAS"
126+
127+
- name: Create Pull Request
128+
if: steps.check_alias.outputs.needs_update == 'true'
129+
uses: peter-evans/create-pull-request@v7
130+
with:
131+
token: ${{ secrets.GITHUB_TOKEN }}
132+
commit-message: "Update branch-alias to ${{ steps.check_alias.outputs.expected_alias }}"
133+
title: "Update branch-alias to ${{ steps.check_alias.outputs.expected_alias }}"
134+
body: |
135+
This PR updates the Composer `branch-alias` configuration to reflect the latest release.
136+
137+
- Latest release: ${{ steps.check_alias.outputs.latest_tag }}
138+
- Previous branch-alias: `${{ steps.check_alias.outputs.current_alias }}`
139+
- Updated branch-alias: `${{ steps.check_alias.outputs.expected_alias }}`
140+
141+
The branch-alias should point to the next minor development version after the latest release.
142+
branch: update-branch-alias
143+
delete-branch: true
144+
labels: |
145+
automated-pr

0 commit comments

Comments
 (0)