Skip to content

Commit ac7e089

Browse files
committed
Merge branch 'develop' into remove-babel-plugins
2 parents eb09ae2 + dcba4a1 commit ac7e089

File tree

105 files changed

+7664
-4808
lines changed

Some content is hidden

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

105 files changed

+7664
-4808
lines changed

.github/actions/install-dependencies/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ runs:
3333
packages/*/node_modules
3434
packages/*/src/generated
3535
packages/scratch-gui/static/microbit
36-
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
36+
key: ${{ runner.os }}-npm-${{ hashFiles('.nvmrc', 'package-lock.json') }}
3737
- if: steps.restore-node-modules-cache.outputs.cache-hit != 'true'
3838
name: Install NPM dependencies
3939
working-directory: .
@@ -47,4 +47,4 @@ runs:
4747
packages/*/node_modules
4848
packages/*/src/generated
4949
packages/scratch-gui/static/microbit
50-
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
50+
key: ${{ runner.os }}-npm-${{ hashFiles('.nvmrc', 'package-lock.json') }}

.github/actions/test-package/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Test package
22

3+
description: Test one of the packages in this monorepo.
4+
35
inputs:
46
package_name:
57
description: The name of the tested package

.github/actions/update-i18n/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Update i18n
22

3+
description: Update i18n files for one of the packages in this monorepo.
4+
35
inputs:
46
package_name:
57
description: The name of the updated package

.github/path-filters.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# The `&global` anchor defines a set of common paths to include by reference in the other filters.
2+
global: &global
3+
- ".github/path-filters.yml"
4+
- ".github/workflows/ci.yml"
5+
- ".nvmrc"
6+
- "package.json"
7+
- "package-lock.json"
8+
- "scripts/**"
9+
10+
any-workspace:
11+
- *global
12+
- "packages/**"
13+
14+
scratch-svg-renderer:
15+
- *global
16+
- "packages/scratch-svg-renderer/**"
17+
scratch-render:
18+
- *global
19+
- "packages/scratch-render/**"
20+
- "packages/scratch-svg-renderer/**"
21+
scratch-vm:
22+
- *global
23+
- "packages/scratch-render/**"
24+
- "packages/scratch-svg-renderer/**"
25+
- "packages/scratch-vm/**"
26+
scratch-gui:
27+
- *global
28+
- "packages/scratch-gui/**"
29+
- "packages/scratch-render/**"
30+
- "packages/scratch-svg-renderer/**"
31+
- "packages/scratch-vm/**"

.github/release.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
changelog:
2+
categories:
3+
- title: General
4+
labels:
5+
- '*'
6+
exclude:
7+
authors:
8+
- 'renovate[bot]'
9+
labels:
10+
- 'dependencies'
11+
- 'security'
12+
- title: Security
13+
labels:
14+
- 'security'
15+
# The "Dependencies" category includes
16+
# - items with the 'dependencies' label
17+
# - items excluded above, mainly by the exclude.authors in "General"
18+
- title: Dependencies
19+
labels:
20+
- '*'

.github/workflows/ci.yml

Lines changed: 68 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,78 +12,100 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15-
ci:
16-
name: Detect affected packages, build and test
15+
build:
16+
name: Build
1717
runs-on: ubuntu-latest
18+
outputs:
19+
any-workspace: ${{ steps.filter.outputs.any-workspace }}
20+
packages: ${{ steps.filter.outputs.changes }}
1821
steps:
1922
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
20-
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
23+
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
2124
with:
2225
cache: 'npm'
2326
node-version-file: '.nvmrc'
24-
- uses: wagoid/commitlint-github-action@9763196e10f27aef304c9b8b660d31d97fce0f99 # v5
2527
- name: Debug info
28+
# https://docs.github.com/en/actions/reference/security/secure-use#use-an-intermediate-environment-variable
29+
env:
30+
GH_HEAD_REF: ${{ github.head_ref }}
2631
run: |
2732
cat <<EOF
2833
Scratch environment: ${{ vars.SCRATCH_ENV || '<none>' }}
2934
Node version: $(node --version)
3035
NPM version: $(npm --version)
3136
GitHub ref: ${{ github.ref }}
32-
GitHub head ref: ${{ github.head_ref }}
37+
GitHub head ref: ${GH_HEAD_REF}
3338
Working directory: $(pwd)
3439
EOF
3540
3641
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
3742
id: filter
3843
with:
39-
# Files in the `global` filter affect all workspaces, even if workspace-specific files have not changed.
40-
filters: |
41-
global:
42-
- ".github/workflows/ci.yml"
43-
- "package.json"
44-
- "package-lock.json"
45-
- "scripts/**"
46-
any-workspace:
47-
- "packages/**"
48-
scratch-svg-renderer:
49-
- "packages/scratch-svg-renderer/**"
50-
scratch-render:
51-
- "packages/scratch-render/**"
52-
- "packages/scratch-svg-renderer/**"
53-
scratch-vm:
54-
- "packages/scratch-render/**"
55-
- "packages/scratch-svg-renderer/**"
56-
- "packages/scratch-vm/**"
57-
scratch-gui:
58-
- "packages/scratch-gui/**"
59-
- "packages/scratch-render/**"
60-
- "packages/scratch-svg-renderer/**"
61-
- "packages/scratch-vm/**"
44+
filters: ./.github/path-filters.yml
6245

63-
- if: ${{ steps.filter.outputs.global == 'true' || steps.filter.outputs.any-workspace == 'true' }}
46+
- if: ${{ steps.filter.outputs.any-workspace == 'true' }}
6447
uses: ./.github/actions/install-dependencies
6548

6649
- name: Build packages
67-
if: ${{ steps.filter.outputs.global == 'true' || steps.filter.outputs.any-workspace == 'true' }}
50+
if: ${{ steps.filter.outputs.any-workspace == 'true' }}
6851
run: npm run build
6952

70-
- name: Test scratch-svg-renderer
71-
if: ${{ !cancelled() && (steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-svg-renderer == 'true') }}
72-
uses: ./.github/actions/test-package
53+
- name: Store build artifacts
54+
if: ${{ steps.filter.outputs.any-workspace == 'true' }}
55+
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4
7356
with:
74-
package_name: scratch-svg-renderer
75-
- name: Test scratch-render
76-
if: ${{ !cancelled() && (steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-render == 'true') }}
77-
uses: ./.github/actions/test-package
57+
name: build
58+
path: |
59+
packages/**/build
60+
packages/**/dist
61+
packages/**/playground
62+
63+
test:
64+
runs-on: ubuntu-latest
65+
needs: build
66+
if: ${{ needs.build.outputs.any-workspace == 'true' }}
67+
strategy:
68+
fail-fast: false
69+
matrix:
70+
package: ${{ fromJSON(needs.build.outputs.packages) }}
71+
exclude:
72+
- package: global
73+
- package: any-workspace
74+
name: Test ${{ matrix.package }}
75+
steps:
76+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
77+
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
7878
with:
79-
package_name: scratch-render
80-
- name: Test scratch-vm
81-
if: ${{ !cancelled() && (steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-vm == 'true') }}
82-
uses: ./.github/actions/test-package
79+
cache: 'npm'
80+
node-version-file: '.nvmrc'
81+
- uses: ./.github/actions/install-dependencies
82+
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
8383
with:
84-
package_name: scratch-vm
85-
- name: Test scratch-gui
86-
if: ${{ !cancelled() && (steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-gui == 'true') }}
87-
uses: ./.github/actions/test-package
84+
name: build
85+
path: packages
86+
- uses: ./.github/actions/test-package
8887
with:
89-
package_name: scratch-gui
88+
package_name: ${{ matrix.package }}
89+
90+
results:
91+
name: Results
92+
runs-on: ubuntu-latest
93+
needs: test
94+
if: ${{ always() }}
95+
steps:
96+
- run: |
97+
case "${{ needs.test.result }}" in
98+
success)
99+
echo "Tests passed successfully."
100+
exit 0
101+
;;
102+
skipped)
103+
echo "Tests were unnecessary for these changes, so they were skipped."
104+
echo "If this is unexpected, check the path filters."
105+
exit 0
106+
;;
107+
*)
108+
echo "Tests failed."
109+
exit 1
110+
;;
111+
esac

.github/workflows/commitlint.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Lint commit messages
2+
on: [pull_request]
3+
4+
concurrency:
5+
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.sha }}"
6+
7+
jobs:
8+
commitlint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
12+
- uses: wagoid/commitlint-github-action@9763196e10f27aef304c9b8b660d31d97fce0f99 # v5

.github/workflows/publish.yml

Lines changed: 81 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,119 @@ jobs:
88
ci:
99
uses: ./.github/workflows/ci.yml
1010
cd:
11+
needs:
12+
- ci
1113
runs-on: ubuntu-latest
1214
steps:
15+
- name: Debug info
16+
run: |
17+
cat <<EOF
18+
Release tag name: ${{ github.event.release.tag_name }}
19+
Release target commit-ish: ${{ github.event.release.target_commitish }}
20+
EOF
21+
22+
- name: Determine NPM tag
23+
id: npm_tag
24+
shell: bash
25+
run: |
26+
case ${{ github.event.release.target_commitish }} in
27+
develop | main | master)
28+
if [[ ${{ github.event.release.prerelease }} == true ]]; then
29+
npm_tag=beta
30+
else
31+
npm_tag=latest
32+
fi
33+
;;
34+
*)
35+
# use the branch name
36+
npm_tag="${{ github.event.release.target_commitish }}"
37+
;;
38+
esac
39+
echo "Determined NPM tag: [$npm_tag]"
40+
echo "npm_tag=${npm_tag}" >> "$GITHUB_OUTPUT"
41+
- name: Check NPM tag
42+
run: |
43+
if [ -z "${{ steps.npm_tag.outputs.npm_tag }}" ]; then
44+
echo "Refusing to publish with empty NPM tag."
45+
exit 1
46+
fi
47+
48+
- name: Config GitHub user
49+
shell: bash
50+
run: |
51+
git config --global user.name 'GitHub Actions'
52+
git config --global user.email 'github-actions@localhost'
53+
1354
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
55+
with:
56+
token: ${{ secrets.PAT_RELEASE_PUSH }} # persists the token for pushing to the repo later
57+
1458
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
1559
with:
1660
cache: 'npm'
1761
node-version-file: '.nvmrc'
1862
registry-url: 'https://registry.npmjs.org'
1963

20-
- name: Config GitHub user
21-
shell: bash
22-
run: |
23-
git config --global user.name 'GitHub Actions'
24-
git config --global user.email 'github-actions@localhost'
64+
- uses: ./.github/actions/install-dependencies
2565

2666
- name: Update the version in the package files
2767
shell: bash
2868
run: |
2969
GIT_TAG="${{github.event.release.tag_name}}"
3070
NEW_VERSION="${GIT_TAG/v/}"
3171
32-
bash ./scripts/update-dependencies-with-tag-versions.sh "$NEW_VERSION"
33-
git add package* && git commit -m "Release $NEW_VERSION"
72+
npm version "$NEW_VERSION" --no-git-tag-version
73+
git add package* && git commit -m "chore(release): $NEW_VERSION [skip ci]"
3474
75+
# Install dependencies after the version update so that
76+
# the build outputs refer to the newest version of inner packages
3577
- uses: ./.github/actions/install-dependencies
3678

37-
- name: Build packages
38-
run: npm run build
39-
4079
- name: Publish scratch-svg-renderer
41-
run: npm publish --access=public --workspace=@scratch/scratch-svg-renderer
80+
run: |
81+
npm run build --workspace @scratch/scratch-svg-renderer
82+
npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-svg-renderer
4283
env:
4384
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
4485

4586
- name: Publish scratch-render
46-
run: npm publish --access=public --workspace=@scratch/scratch-render
87+
run: |
88+
npm run build --workspace @scratch/scratch-render
89+
npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-render
4790
env:
4891
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
4992

5093
- name: Publish scratch-vm
51-
run: npm publish --access=public --workspace=@scratch/scratch-vm
94+
run: |
95+
npm run build --workspace @scratch/scratch-vm
96+
npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-vm
5297
env:
5398
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
5499

55100
- name: Publish scratch-gui
56-
run: npm publish --access=public --workspace=@scratch/scratch-gui
101+
run: |
102+
cp ./packages/scratch-gui/package.json ./packages/scratch-gui/package-copy.json
103+
104+
jq 'del(.exports["./standalone"])' ./packages/scratch-gui/package.json | npx sponge ./packages/scratch-gui/package.json
105+
106+
npm run build:dist --workspace @scratch/scratch-gui
107+
npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-gui
108+
109+
mv ./packages/scratch-gui/package-copy.json ./packages/scratch-gui/package.json
110+
env:
111+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
112+
113+
- name: Publish scratch-gui-standalone
114+
run: |
115+
jq '
116+
.name = "@scratch/scratch-gui-standalone" |
117+
del(.peerDependencies) |
118+
.exports."." = .exports."./standalone" |
119+
del(.exports."./standalone")
120+
' ./packages/scratch-gui/package.json | npx sponge ./packages/scratch-gui/package.json
121+
122+
npm --workspace=@scratch/scratch-gui-standalone run clean && npm --workspace=@scratch/scratch-gui-standalone run build:dist-standalone
123+
npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-gui-standalone
57124
env:
58125
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
59126

@@ -110,5 +177,3 @@ jobs:
110177
publish_dir: ./packages/scratch-gui/build
111178
destination_dir: scratch-gui
112179
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
113-
needs:
114-
- ci

0 commit comments

Comments
 (0)