Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into fix/welcome-flow-redo
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsreberski committed Aug 28, 2024
2 parents bd0ca06 + cd69286 commit b35219f
Show file tree
Hide file tree
Showing 678 changed files with 7,384 additions and 17,489 deletions.
169 changes: 89 additions & 80 deletions .github/files/gh-autorelease/files/autorelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,42 @@

set -eo pipefail

: "${GH_TOKEN:?Build argument needs to be set and non-empty.}"
: "${GITHUB_REF:?Build argument needs to be set and non-empty.}"
: "${GITHUB_SHA:?Build argument needs to be set and non-empty.}"
: "${API_TOKEN_GITHUB:?Build argument needs to be set and non-empty.}"
: "${GITHUB_API_URL:?Build argument needs to be set and non-empty.}"
: "${GITHUB_REPOSITORY:?Build argument needs to be set and non-empty.}"

## Determine tag
if [[ ! "$GITHUB_REF" =~ ^refs/tags/v?[0-9]+(\.[0-9]+)+(-[a-z0-9._-]+)?$ ]]; then
echo "::error::Expected GITHUB_REF like \`refs/tags/v1.2.3\` or \`refs/tags/1.2.3\`, got \`$GITHUB_REF\`"
if [[ ! -f composer.json ]]; then
echo '::error::No composer.json. Did it get excluded from the mirror?'
exit 1
fi
TAG="${GITHUB_REF#refs/tags/}"

## Check for alphas
if [[ "$TAG" =~ -(alpha|a\.[0-9]*[02468])$ ]]; then
echo "Not creating a release for alpha version $TAG"
exit 0
fi
echo "Creating release for $TAG"
## Determine tag
ROLLING_MODE=
if [[ "$GITHUB_REF" =~ ^refs/tags/v?[0-9]+(\.[0-9]+)+(-[a-z0-9._-]+)?$ ]]; then
TAG="${GITHUB_REF#refs/tags/}"

## Determine slug and title format.
if [[ ! -f composer.json ]]; then
echo '::error::No composer.json. Did it get excluded from the mirror?'
## Check for alphas
if [[ "$TAG" =~ -(alpha|a\.[0-9]*[02468])$ ]]; then
echo "Not creating a release for alpha version $TAG"
exit 0
fi
elif [[ "$GITHUB_REF" == "refs/heads/trunk" ]]; then
if ! jq -e '.extra.autorelease["rolling-release"]? // false' composer.json > /dev/null; then
echo "::notice::Skipping trunk release because autorelease rolling mode is not enabled."
exit 0
fi
ROLLING_MODE=true
CURRENT_VER=$( sed -nEe 's/^## \[?([^]]*)\]? - .*/\1/;T;p;q' CHANGELOG.md || true )
GIT_SUFFIX=$( git log -1 --format=%h . )
TAG="$CURRENT_VER+rolling.$GIT_SUFFIX"
else
echo "::error::Expected GITHUB_REF like \`refs/tags/v1.2.3\` or \`refs/tags/1.2.3\` or \`refs/heads/trunk\` for rolling releases, got \`$GITHUB_REF\`"
exit 1
fi

echo "Creating release for $TAG"

## Determine slug and title format.
SLUG="$(jq -r '.extra.autorelease.slug? // .extra["wp-plugin-slug"] // .extra["beta-plugin-slug"] // ( .name | sub( "^.*/"; "" ) )' composer.json)"
if [[ -z "$SLUG" ]]; then
echo '::error::Failed to get slug from composer.json.'
Expand All @@ -48,76 +58,75 @@ echo "::group::Creating $SLUG.zip"
git archive -v --output="$SLUG.zip" --prefix="$SLUG/" HEAD 2>&1
echo "::endgroup::"

## Create the release note.
# Extract the changelog section.
echo "::group::Extracting release notes"
if [[ ! -f CHANGELOG.md ]]; then
echo '::endgroup::'
echo '::error::No CHANGELOG.md for release notes.'
exit 1
fi
SCRIPT="
/^## \\[?$(sed 's/[.\[\]\\*^$\/()+?{}|]/\\&/g' <<<"${TAG#v}")\\]? - / {
bc
if [[ -z "$ROLLING_MODE" ]]; then
## Create the release note.
# Extract the changelog section.
echo "::group::Extracting release notes"
if [[ ! -f CHANGELOG.md ]]; then
echo '::endgroup::'
echo '::error::No CHANGELOG.md for release notes.'
exit 1
fi
SCRIPT="
/^## \\[?$(sed 's/[.\[\]\\*^$\/()+?{}|]/\\&/g' <<<"${TAG#v}")\\]? - / {
bc
:a
n
/^## / {
q
}
:c
s/^## \[([^]]+)\]/## \1/
p
ba
}
"
ENTRY=$(sed -n -E -e "$SCRIPT" CHANGELOG.md)
if [[ -z "$ENTRY" ]]; then
echo '::endgroup::'
echo "::error::Failed to find section for ${TAG#v} in CHANGELOG.md"
exit 1
fi

# Strip unwanted sections.
SCRIPT="
:a
n
/^## / {
q
/^### .* This section will not be copied to readme\.txt/ {
:b
n
/^#/ ba
bb
}
:c
s/^## \[([^]]+)\]/## \1/
p
ba
}
"
ENTRY=$(sed -n -E -e "$SCRIPT" CHANGELOG.md)
if [[ -z "$ENTRY" ]]; then
echo '::endgroup::'
echo "::error::Failed to find section for ${TAG#v} in CHANGELOG.md"
exit 1
"
ENTRY=$(sed -n -E -e "$SCRIPT" <<<"$ENTRY")

echo "Release notes:"
echo "-----"
echo "$ENTRY"
echo "-----"
echo "::endgroup::"
else
## Using a brief explanation for the rolling release note.
ENTRY="### Rolling release based on the trunk branch."
fi

if [[ -n "$ROLLING_MODE" ]]; then
echo "::group::Deleting stale rolling release"

for R in $( gh release list --limit 100 --json tagName --jq '.[].tagName | select( contains( "rolling" ) )' ); do
echo "Found $R, deleting"
gh release delete "$R" --cleanup-tag --yes
done

echo "::endgroup::"
fi

# Strip unwanted sections.
SCRIPT="
:a
/^### .* This section will not be copied to readme\.txt/ {
:b
n
/^#/ ba
bb
}
p
"
ENTRY=$(sed -n -E -e "$SCRIPT" <<<"$ENTRY")

echo "Release notes:"
echo "-----"
echo "$ENTRY"
echo "-----"
echo "::endgroup::"

echo "::group::Creating release"
curl -v -L \
--write-out '%{response_code}' \
--output out.json \
--request POST \
--header "authorization: Bearer $API_TOKEN_GITHUB" \
--header 'content-type: application/json' \
--header 'accept: application/vnd.github.v3+json' \
--url "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases" \
--data "$(jq -n --arg tag "$TAG" --arg sha "$GITHUB_SHA" --arg title "$TITLE" --arg body "$ENTRY" '{ tag_name: $tag, target_commitish: $sha, name: $title, body: $body}')" \
2>&1 > code.txt
cat out.json
echo
[[ "$(<code.txt)" =~ ^2[0-9][0-9]$ ]] || exit 1
echo "::endgroup::"
gh release create "$TAG" "$SLUG.zip" \
--notes "$ENTRY" \
--target "$GITHUB_SHA" \
--title "$TITLE"

echo "::group::Uploading artifact to release"
curl -v --fail -L \
--request POST \
--header "authorization: Bearer $API_TOKEN_GITHUB" \
--header "content-type: application/zip" \
--url "$(jq -r '.upload_url | sub( "{\\?[^}]*}$"; "" )' out.json)?name=$SLUG.zip" \
--data-binary "@$SLUG.zip" \
2>&1
echo "::endgroup::"
4 changes: 3 additions & 1 deletion .github/files/gh-autorelease/workflows/autorelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
- 'v?[0-9]+.[0-9]+.[0-9]+-*'
- 'v?[0-9]+.[0-9]+.[0-9]+.[0-9]+'
- 'v?[0-9]+.[0-9]+.[0-9]+.[0-9]+-*'
branches:
- 'trunk'

jobs:
publish:
Expand All @@ -18,5 +20,5 @@ jobs:
- uses: actions/checkout@v4
- name: Create release
env:
API_TOKEN_GITHUB: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./.github/files/autorelease.sh
13 changes: 0 additions & 13 deletions .github/files/pr-update-to.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,6 @@ function update_tag {
cd $(dirname "${BASH_SOURCE[0]}")/../..
BASE="$PWD"

# If this commit updated a changelog, assume it was a release and update the tag.
echo "Checking for changes to changelogs..."
FILES=()
for FILE in projects/*/*/composer.json; do
PROJECT="${FILE%/composer.json}"
cd "$BASE/$PROJECT"
FILES+=( "$(realpath -m --relative-to="$BASE" "$(jq -r '.extra.changelogger.changelog // "CHANGELOG.md"' composer.json)")" )
done
cd "$BASE"
for F in $(git -c core.quotepath=off diff --name-only HEAD^..HEAD "${FILES[@]}"); do
update_tag "pr-update-to-${F%/*}"
done

# If this commit changed tool versions, update the tag so PRs get rechecked with the new versions.
echo "Checking for changes to .github/versions.sh..."
git diff --exit-code --name-only HEAD^..HEAD .github/versions.sh || update_tag "pr-update-to"
Expand Down
11 changes: 1 addition & 10 deletions .github/files/renovate-post-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,7 @@ for DIR in $(git -c core.quotepath=off diff --name-only HEAD | sed -nE 's!^(proj
echo "Adding change file for $SLUG"
cd "$DIR"

CHANGES_DIR="$(jq -r '.extra.changelogger["changes-dir"] // "changelog"' composer.json)"
if [[ -d "$CHANGES_DIR" && "$(ls -- "$CHANGES_DIR")" ]]; then
changelogger_add 'Updated package dependencies.' '' --filename="${CHANGEFILE}" --filename-auto-suffix
else
changelogger_add 'Updated package dependencies.' '' --filename="${CHANGEFILE}" --filename-auto-suffix
echo "Updating version for $SLUG"
PRERELEASE=$(alpha_tag composer.json 0)
VER=$(changelogger version next --default-first-version --prerelease="$PRERELEASE") || { echo "$VER"; exit 1; }
"$BASE/tools/project-version.sh" -u "$VER" "$SLUG"
fi
changelogger_add 'Updated package dependencies.' '' --filename="${CHANGEFILE}" --filename-auto-suffix
cd "$BASE"
done

Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/block-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Jetpack block performance
on:
schedule:
- cron: '0 */12 * * *'
workflow_dispatch:

env:
# Work around a bug in node 18.18.0. See https://github.com/webpack-contrib/thread-loader/issues/191 for details.
Expand All @@ -18,27 +19,27 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20

- uses: actions/checkout@v4
with:
repository: 'WordPress/gutenberg'
path: 'gutenberg'

- name: Build Gutenberg
working-directory: gutenberg
run: |
npm ci
npx playwright install chromium --with-deps
npm run build:packages
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('gutenberg/**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Build Gutenberg
working-directory: gutenberg
run: |
npm ci
npx playwright install chromium --with-deps
npm run build:packages
- name: Setup tools for J
uses: ./.github/actions/tool-setup

Expand Down Expand Up @@ -87,6 +88,7 @@ jobs:
with:
name: test-output-block-perf
path: tools/e2e-commons/results
include-hidden-files: true

test-reports:
name: "Trigger test report workflow"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ jobs:
with:
name: test-output-${{ matrix.project }}
path: ${{ matrix.path }}/output
include-hidden-files: true

test-report:
name: "Test report"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ jobs:
with:
name: ${{ matrix.artifact }}
path: artifacts
include-hidden-files: true
retention-days: 7

storybook-test:
Expand Down
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/development-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ If you're ready to start, you should see all green `SUCCESS` messages. If the sc

Once you're all set here, you can continue developing. If you're setting up an local environment and want to start testing immediately, please ensure you build the projects you need.

`jetpack build` will provide prompts to determine the project you need or you can pass it a complete command, like `jetpack build plugins/jetpack --with-deps`
`jetpack build` will provide prompts to determine the project you need or you can pass it a complete command, like `jetpack build plugins/jetpack --deps`

### Testing Jetpack cloud features

Expand Down
2 changes: 1 addition & 1 deletion docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Note: This is for Automattician use only. For other methods, check out [ngrok](.
Once you have a local copy of Jetpack and all development tools installed, you can start developing.

1. Make sure the plugin you're developing is activated on your WordPress site.
2. [Build your project](#building-your-project) using `jetpack build [type/project]`, such as `jetpack build plugins/jetpack`
2. [Build your project](development-environment.md#building-your-project) using `jetpack build [type/project]` and including its dependencies, such as `jetpack build plugins/jetpack --deps`
3. Access the plugin's dashboard in your browser.

By default the development build above will run once and if you change any of the files, you need to run `jetpack build` again to see the changes on the site. If you want to avoid that, you can run a continuous build that will rebuild anytime it sees any changes on your local filesystem. To run it, use:
Expand Down
Loading

0 comments on commit b35219f

Please sign in to comment.