Skip to content

Commit ab3b853

Browse files
committed
Merge branch 'main' into feat/10187-toolbox-flyout-nav-shortcuts
2 parents 48b6ad8 + 6038b95 commit ab3b853

161 files changed

Lines changed: 12712 additions & 3503 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: 61 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,20 @@ 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 }}
4950

5051
- name: Setup Node.js
5152
uses: actions/setup-node@v7
@@ -54,146 +55,93 @@ jobs:
5455
registry-url: 'https://registry.npmjs.org'
5556

5657
- name: Install dependencies
57-
if: ${{ !inputs.skip_versioning }}
5858
run: npm ci
5959

60-
- name: Determine version bump
61-
id: bump
62-
if: ${{ !inputs.skip_versioning && inputs.version_override == '' }}
63-
working-directory: packages/blockly
60+
- name: Determine Dist Tag
61+
id: dist
62+
env:
63+
VERSION_OVERRIDE: ${{ inputs.version_override }}
64+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
65+
REF_NAME: ${{ github.ref_name }}
6466
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"
67+
DIST_TAG=$([[ "${VERSION_OVERRIDE}" == *"-beta."* || "${REF_NAME}" != "${DEFAULT_BRANCH}" ]] && echo "beta" || echo "latest")
68+
echo "dist_tag=$DIST_TAG" >> "$GITHUB_OUTPUT"
69+
echo "NPM distribution tag: $DIST_TAG"
6870
69-
- name: Apply version bump
71+
- name: Version
7072
if: ${{ !inputs.skip_versioning }}
71-
working-directory: packages/blockly
7273
env:
73-
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
74-
REF_NAME: ${{ github.ref_name }}
75-
RELEASE_TYPE: ${{ steps.bump.outputs.release_type }}
74+
GH_TOKEN: ${{ github.token }}
7675
VERSION_OVERRIDE: ${{ inputs.version_override }}
76+
DRY_RUN: ${{ inputs.dry_run }}
77+
DIST_TAG: ${{ steps.dist.outputs.dist_tag }}
7778
run: |
7879
set -euo pipefail
80+
VERSION_COMMAND="npx lerna version"
7981
if [ -n "${VERSION_OVERRIDE}" ]; then
80-
npm version "${VERSION_OVERRIDE}" --no-git-tag-version
81-
exit 0
82+
VERSION_COMMAND="${VERSION_COMMAND} ${VERSION_OVERRIDE}"
8283
fi
83-
if [ "${REF_NAME}" = "${DEFAULT_BRANCH}" ]; then
84-
npm version "${RELEASE_TYPE}" --no-git-tag-version
85-
exit 0
84+
if [ "${DIST_TAG}" = "latest" ]; then
85+
VERSION=$(node -p "require('./packages/blockly/package.json').version")
86+
if [[ "${VERSION}" == *"-beta."* ]]; then
87+
VERSION_COMMAND="${VERSION_COMMAND} --conventional-graduate"
88+
fi
89+
else
90+
VERSION_COMMAND="${VERSION_COMMAND} --conventional-prerelease --preid beta"
8691
fi
87-
VERSION=$(node -p "require('./package.json').version")
88-
if [[ "${VERSION}" == *"-beta."* ]]; then
89-
npm version prerelease --preid=beta --no-git-tag-version
92+
VERSION_COMMAND="${VERSION_COMMAND} --conventional-commits --yes"
93+
if [ "${DRY_RUN}" = "true" ]; then
94+
VERSION_COMMAND="${VERSION_COMMAND} --no-push --no-git-tag-version"
95+
echo "Dry run: would publish the following versions to npm dist-tag: ${DIST_TAG}"
96+
eval "$VERSION_COMMAND"
97+
if [ "${DIST_TAG}" = "beta" ]; then
98+
echo "GitHub release would be created as prerelease."
99+
fi
90100
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
101+
eval "$VERSION_COMMAND"
100102
fi
101103
102-
- name: Read package version
103-
id: version
104+
- name: Build core package
105+
if: ${{ !inputs.dry_run }}
104106
working-directory: packages/blockly
105-
run: |
106-
VERSION=$(node -p "require('./package.json').version")
107-
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
108-
echo "Version: $VERSION"
107+
run: npm run package
109108

110-
- name: Dry run summary
111-
if: ${{ inputs.dry_run }}
109+
- name: Publish
110+
if: ${{ !inputs.dry_run }}
111+
env:
112+
GH_TOKEN: ${{ github.token }}
113+
SKIP_VERSIONING: ${{ inputs.skip_versioning }}
114+
DIST_TAG: ${{ steps.dist.outputs.dist_tag }}
112115
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."
116+
if [ "${SKIP_VERSIONING}" = "true" ]; then
117+
npx lerna publish from-package --yes --dist-tag ${DIST_TAG} --loglevel silly
118+
else
119+
npx lerna publish from-git --yes --dist-tag ${DIST_TAG} --loglevel silly
117120
fi
118121
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-
178122
- name: Create tarball
123+
if: ${{ !inputs.dry_run }}
179124
working-directory: packages/blockly
180125
run: npm pack ./dist
181-
126+
182127
- name: Create GitHub release
128+
if: ${{ !inputs.dry_run }}
183129
working-directory: packages/blockly
184130
env:
185131
GH_TOKEN: ${{ github.token }}
132+
DIST_TAG: ${{ steps.dist.outputs.dist_tag }}
186133
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" \
134+
VERSION=$(node -p "require('./packages/blockly/package.json').version")
135+
TARBALL="blockly-${VERSION}.tgz"
136+
if [ "${DIST_TAG}" == "beta" ]; then
137+
gh release create "blockly-v${VERSION}" "$TARBALL" \
190138
--repo "$GITHUB_REPOSITORY" \
191-
--title "blockly-v${{ needs.version.outputs.version }}" \
139+
--title "blockly-v${VERSION}" \
192140
--generate-notes \
193141
--prerelease
194142
else
195-
gh release create "blockly-v${{ needs.version.outputs.version }}" "$TARBALL" \
143+
gh release create "blockly-v${VERSION}" "$TARBALL" \
196144
--repo "$GITHUB_REPOSITORY" \
197-
--title "blockly-v${{ needs.version.outputs.version }}" \
145+
--title "blockly-v${VERSION}" \
198146
--generate-notes
199147
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+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ build-debug.log
1111
/nbproject/private/
1212
tsdoc-metadata.json
1313
.vscode
14+
/CHANGELOG.md
1415

1516
# All packages
1617
build/
@@ -23,6 +24,7 @@ packages/blockly/tests/compile/main_compressed.js
2324
packages/blockly/tests/compile/main_compressed.js.map
2425
packages/blockly/tests/mocha/test-modules.generated.mjs
2526
packages/blockly/temp/
27+
packages/blockly/CHANGELOG.md
2628

2729
# Docs:
2830
# Autogenerated reference docs, do not check in

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)