Skip to content

Commit cda827d

Browse files
committed
Merge remote-tracking branch 'upstream/main' into feat/10187-toolbox-flyout-nav-shortcuts
2 parents 48b6ad8 + dda592a commit cda827d

163 files changed

Lines changed: 12794 additions & 3505 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ permissions:
1212

1313
jobs:
1414
build:
15-
timeout-minutes: 10
15+
timeout-minutes: 20
1616
runs-on: ${{ matrix.os }}
1717

1818
strategy:

.github/workflows/publish.yml

Lines changed: 71 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,27 @@ permissions:
3333
jobs:
3434
ci:
3535
uses: ./.github/workflows/build.yml
36-
37-
version:
36+
37+
publish:
3838
needs: ci
3939
runs-on: ubuntu-latest
40-
timeout-minutes: 30
41-
outputs:
42-
version: ${{ steps.version.outputs.version }}
40+
# Don't try to publish from a fork of RaspberryPiFoundation/blockly.
41+
if: ${{ github.repository_owner == 'RaspberryPiFoundation' }}
42+
environment: release
4343
steps:
4444
- name: Checkout
4545
uses: actions/checkout@v7
4646
with:
4747
ref: ${{ github.ref }}
4848
fetch-depth: 0
49+
ssh-key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
50+
51+
# This uses a reverse-engineered email for the github actions bot. See
52+
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
53+
- name: Git Identity
54+
run: |
55+
git config --global user.name 'github-actions[bot]'
56+
git config --global user.email '<41898282+github-actions[bot]@users.noreply.github.com'
4957
5058
- name: Setup Node.js
5159
uses: actions/setup-node@v7
@@ -54,146 +62,96 @@ jobs:
5462
registry-url: 'https://registry.npmjs.org'
5563

5664
- name: Install dependencies
57-
if: ${{ !inputs.skip_versioning }}
5865
run: npm ci
5966

60-
- name: Determine version bump
61-
id: bump
62-
if: ${{ !inputs.skip_versioning && inputs.version_override == '' }}
63-
working-directory: packages/blockly
67+
- name: Build
68+
run: npm run build
69+
70+
- name: Determine Dist Tag
71+
id: dist
72+
env:
73+
VERSION_OVERRIDE: ${{ inputs.version_override }}
74+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
75+
REF_NAME: ${{ github.ref_name }}
6476
run: |
65-
RELEASE_TYPE=$(npx conventional-recommended-bump --preset conventionalcommits -t blockly-)
66-
echo "release_type=$RELEASE_TYPE" >> "$GITHUB_OUTPUT"
67-
echo "Recommended bump: $RELEASE_TYPE"
77+
DIST_TAG=$([[ "${VERSION_OVERRIDE}" == *"-beta."* || "${REF_NAME}" != "${DEFAULT_BRANCH}" ]] && echo "beta" || echo "latest")
78+
echo "dist_tag=$DIST_TAG" >> "$GITHUB_OUTPUT"
79+
echo "NPM distribution tag: $DIST_TAG"
6880
69-
- name: Apply version bump
81+
- name: Version
7082
if: ${{ !inputs.skip_versioning }}
71-
working-directory: packages/blockly
7283
env:
73-
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
74-
REF_NAME: ${{ github.ref_name }}
75-
RELEASE_TYPE: ${{ steps.bump.outputs.release_type }}
84+
GH_TOKEN: ${{ github.token }}
7685
VERSION_OVERRIDE: ${{ inputs.version_override }}
86+
DRY_RUN: ${{ inputs.dry_run }}
87+
DIST_TAG: ${{ steps.dist.outputs.dist_tag }}
7788
run: |
7889
set -euo pipefail
90+
VERSION_COMMAND="npx lerna version"
7991
if [ -n "${VERSION_OVERRIDE}" ]; then
80-
npm version "${VERSION_OVERRIDE}" --no-git-tag-version
81-
exit 0
92+
VERSION_COMMAND="${VERSION_COMMAND} ${VERSION_OVERRIDE}"
8293
fi
83-
if [ "${REF_NAME}" = "${DEFAULT_BRANCH}" ]; then
84-
npm version "${RELEASE_TYPE}" --no-git-tag-version
85-
exit 0
94+
if [ "${DIST_TAG}" = "latest" ]; then
95+
VERSION=$(node -p "require('./packages/blockly/package.json').version")
96+
if [[ "${VERSION}" == *"-beta."* ]]; then
97+
VERSION_COMMAND="${VERSION_COMMAND} --conventional-graduate"
98+
fi
99+
else
100+
VERSION_COMMAND="${VERSION_COMMAND} --conventional-prerelease --preid beta"
86101
fi
87-
VERSION=$(node -p "require('./package.json').version")
88-
if [[ "${VERSION}" == *"-beta."* ]]; then
89-
npm version prerelease --preid=beta --no-git-tag-version
102+
VERSION_COMMAND="${VERSION_COMMAND} --force-publish --conventional-commits --yes"
103+
if [ "${DRY_RUN}" = "true" ]; then
104+
VERSION_COMMAND="${VERSION_COMMAND} --no-push --no-git-tag-version"
105+
echo "Dry run: would publish the following versions to npm dist-tag: ${DIST_TAG}"
106+
eval "$VERSION_COMMAND"
107+
if [ "${DIST_TAG}" = "beta" ]; then
108+
echo "GitHub release would be created as prerelease."
109+
fi
90110
else
91-
case "${RELEASE_TYPE}" in
92-
major) npm version premajor --preid=beta --no-git-tag-version ;;
93-
minor) npm version preminor --preid=beta --no-git-tag-version ;;
94-
patch) npm version prepatch --preid=beta --no-git-tag-version ;;
95-
*)
96-
echo "::error title=Invalid release bump::conventional-recommended-bump returned '${RELEASE_TYPE}' (expected major, minor, or patch). Fix commits/tags or set version_override." >&2
97-
exit 1
98-
;;
99-
esac
111+
eval "$VERSION_COMMAND"
100112
fi
101113
102-
- name: Read package version
103-
id: version
114+
- name: Build core package
115+
if: ${{ !inputs.dry_run }}
104116
working-directory: packages/blockly
105-
run: |
106-
VERSION=$(node -p "require('./package.json').version")
107-
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
108-
echo "Version: $VERSION"
117+
run: npm run package
109118

110-
- name: Dry run summary
111-
if: ${{ inputs.dry_run }}
119+
- name: Publish
120+
if: ${{ !inputs.dry_run }}
121+
env:
122+
GH_TOKEN: ${{ github.token }}
123+
SKIP_VERSIONING: ${{ inputs.skip_versioning }}
124+
DIST_TAG: ${{ steps.dist.outputs.dist_tag }}
112125
run: |
113-
DIST_TAG="${{ github.ref_name == github.event.repository.default_branch && 'latest' || 'beta' }}"
114-
echo "Dry run: would publish version ${{ steps.version.outputs.version }} to npm dist-tag: ${DIST_TAG}"
115-
if [ "${{ github.ref_name }}" != "${{ github.event.repository.default_branch }}" ]; then
116-
echo "GitHub release would be created as prerelease."
126+
if [ "${SKIP_VERSIONING}" = "true" ]; then
127+
npx lerna publish from-package --yes --dist-tag ${DIST_TAG} --loglevel silly
128+
else
129+
npx lerna publish from-git --yes --dist-tag ${DIST_TAG} --loglevel silly
117130
fi
118131
119-
- name: Upload versioned files
120-
if: ${{ !inputs.skip_versioning }}
121-
uses: actions/upload-artifact@v7
122-
with:
123-
name: versioned-files
124-
path: |
125-
packages/blockly/package.json
126-
package-lock.json
127-
128-
publish:
129-
needs: version
130-
runs-on: ubuntu-latest
131-
if: ${{ !inputs.dry_run }}
132-
environment: release
133-
env:
134-
NPM_DIST_TAG: ${{ github.ref_name == github.event.repository.default_branch && 'latest' || 'beta' }}
135-
steps:
136-
- name: Checkout
137-
uses: actions/checkout@v7
138-
with:
139-
ref: ${{ github.ref }}
140-
fetch-depth: 0
141-
ssh-key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
142-
143-
- name: Download versioned files
144-
if: ${{ !inputs.skip_versioning }}
145-
uses: actions/download-artifact@v8
146-
with:
147-
name: versioned-files
148-
149-
- name: Commit and push version bump
150-
if: ${{ !inputs.skip_versioning }}
151-
run: |
152-
git config user.name "github-actions[bot]"
153-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
154-
git add packages/blockly/package.json package-lock.json
155-
git commit -m "release: v${{ needs.version.outputs.version }}"
156-
git push
157-
TAG="blockly-v${{ needs.version.outputs.version }}"
158-
git tag "$TAG"
159-
git push origin "refs/tags/$TAG"
160-
161-
- name: Setup Node.js
162-
uses: actions/setup-node@v7
163-
with:
164-
node-version: 24.x
165-
registry-url: 'https://registry.npmjs.org'
166-
167-
- name: Install dependencies
168-
run: npm ci
169-
170-
- name: Build package
171-
working-directory: packages/blockly
172-
run: npm run package
173-
174-
- name: Publish to npm
175-
working-directory: packages/blockly/dist
176-
run: npm publish --tag "${NPM_DIST_TAG}" --verbose
177-
178132
- name: Create tarball
133+
if: ${{ !inputs.dry_run }}
179134
working-directory: packages/blockly
180135
run: npm pack ./dist
181-
136+
182137
- name: Create GitHub release
138+
if: ${{ !inputs.dry_run }}
183139
working-directory: packages/blockly
184140
env:
185141
GH_TOKEN: ${{ github.token }}
142+
DIST_TAG: ${{ steps.dist.outputs.dist_tag }}
186143
run: |
187-
TARBALL="blockly-${{ needs.version.outputs.version }}.tgz"
188-
if [ "${{ github.ref_name }}" != "${{ github.event.repository.default_branch }}" ]; then
189-
gh release create "blockly-v${{ needs.version.outputs.version }}" "$TARBALL" \
144+
VERSION=$(node -p "require('./package.json').version")
145+
TARBALL="blockly-${VERSION}.tgz"
146+
if [ "${DIST_TAG}" == "beta" ]; then
147+
gh release create "blockly-v${VERSION}" "$TARBALL" \
190148
--repo "$GITHUB_REPOSITORY" \
191-
--title "blockly-v${{ needs.version.outputs.version }}" \
149+
--title "blockly-v${VERSION}" \
192150
--generate-notes \
193151
--prerelease
194152
else
195-
gh release create "blockly-v${{ needs.version.outputs.version }}" "$TARBALL" \
153+
gh release create "blockly-v${VERSION}" "$TARBALL" \
196154
--repo "$GITHUB_REPOSITORY" \
197-
--title "blockly-v${{ needs.version.outputs.version }}" \
155+
--title "blockly-v${VERSION}" \
198156
--generate-notes
199157
fi

.github/workflows/translatewiki.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ on:
1414
pull_request_target:
1515
types:
1616
- opened
17+
- reopened
18+
- synchronize
1719

1820
jobs:
19-
translatewiki:
21+
retitle-translatewiki-prs:
22+
name: Retitle translatewiki PRs
2023
runs-on: ubuntu-latest
2124
# Only run for the translatewiki bot's PRs, matching on both the author and
2225
# the source branch.
@@ -61,3 +64,43 @@ jobs:
6164
issue_number,
6265
labels: ['PR: chore'],
6366
});
67+
68+
validate-files:
69+
runs-on: ubuntu-latest
70+
# Only run for the translatewiki bot's PRs, matching on both the author and
71+
# the source branch.
72+
if: ${{ github.event.pull_request.user.login == 'translatewiki' && github.event.pull_request.head.ref == 'translatewiki' }}
73+
permissions:
74+
pull-requests: read
75+
steps:
76+
- name: Ensure translatewiki PR only touches msg/
77+
uses: actions/github-script@v9
78+
with:
79+
script: |
80+
const {number: pull_number} = context.payload.pull_request;
81+
82+
// translatewiki localisation PRs must only modify message files.
83+
const allowedPrefix = 'packages/blockly/msg/';
84+
85+
const files = await github.paginate(github.rest.pulls.listFiles, {
86+
owner: context.repo.owner,
87+
repo: context.repo.repo,
88+
pull_number,
89+
per_page: 100,
90+
});
91+
92+
const offending = files
93+
.map((file) => file.filename)
94+
.filter((filename) => !filename.startsWith(allowedPrefix));
95+
96+
if (offending.length > 0) {
97+
core.setFailed(
98+
`translatewiki PR #${pull_number} touches files outside ` +
99+
`${allowedPrefix}:\n${offending.map((f) => ` - ${f}`).join('\n')}`,
100+
);
101+
} else {
102+
core.info(
103+
`translatewiki PR #${pull_number} only touches ${allowedPrefix} ` +
104+
`(${files.length} file(s) checked).`,
105+
);
106+
}

lerna.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": "13.2.0",
3+
"npmClient": "npm",
4+
"changelogPreset": {
5+
"name": "conventionalcommits"
6+
},
7+
"ignoreChanges": ["**/package-lock.json"],
8+
"command": {
9+
"version": {
10+
"tagVersionPrefix": "blockly-v"
11+
},
12+
"publish": {
13+
"tagVersionPrefix": "blockly-v"
14+
}
15+
},
16+
"packages": ["packages/blockly", "packages/plugins/*"],
17+
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
18+
}

0 commit comments

Comments
 (0)