mirror of
https://github.com/scratchfoundation/scratch-l10n.git
synced 2025-01-03 11:25:51 -05:00
Merge pull request #224 from scratchfoundation/implement-semantic-release
Implement semantic release
This commit is contained in:
commit
c55be08db2
11 changed files with 33411 additions and 21682 deletions
26
.github/workflows/ci-cd.yml
vendored
26
.github/workflows/ci-cd.yml
vendored
|
@ -45,28 +45,8 @@ jobs:
|
||||||
mkdir -p ./test/results
|
mkdir -p ./test/results
|
||||||
npm test
|
npm test
|
||||||
|
|
||||||
- name: Generate release version
|
- name: Run semantic-release
|
||||||
run: |
|
|
||||||
export NODE_ENV=production
|
|
||||||
export RELEASE_TIMESTAMP=$(date +'%Y%m%d%H%M%S')
|
|
||||||
export VPKG=$($(npm bin)/json -f package.json version)
|
|
||||||
export VERSION=${VPKG/%?/}${RELEASE_TIMESTAMP}
|
|
||||||
echo "RELEASE_VERSION=${VERSION}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Deploy to NPM (do a dry-run if not on master)
|
|
||||||
env:
|
env:
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
NPM_TAG: "latest"
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: npx --no -- semantic-release
|
||||||
message=$([[ "$TRIGGER_DEPLOY" == "false" ]] && echo "DRY RUN of" || echo "Deploying")
|
|
||||||
echo "$message version $RELEASE_VERSION to $NPM_TAG"
|
|
||||||
npm --no-git-tag-version version $RELEASE_VERSION
|
|
||||||
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
|
|
||||||
npm publish --tag $NPM_TAG $([[ "$TRIGGER_DEPLOY" == "false" ]] && echo "--dry-run")
|
|
||||||
|
|
||||||
- name: Check Release Version and Create Tag
|
|
||||||
run: |
|
|
||||||
if npm info | grep -q $RELEASE_VERSION; then
|
|
||||||
git tag $RELEASE_VERSION
|
|
||||||
git push origin $RELEASE_VERSION
|
|
||||||
fi
|
|
||||||
|
|
3
.github/workflows/commitlint.yml
vendored
3
.github/workflows/commitlint.yml
vendored
|
@ -2,8 +2,7 @@ name: Lint commit messages
|
||||||
on: [pull_request]
|
on: [pull_request]
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
|
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.sha }}"
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
commitlint:
|
commitlint:
|
||||||
|
|
2
.github/workflows/daily-tx-pull.yml
vendored
2
.github/workflows/daily-tx-pull.yml
vendored
|
@ -53,7 +53,7 @@ jobs:
|
||||||
echo "MADE_CHANGES=false" >> "$GITHUB_OUTPUT"
|
echo "MADE_CHANGES=false" >> "$GITHUB_OUTPUT"
|
||||||
echo "Nothing to commit."
|
echo "Nothing to commit."
|
||||||
else
|
else
|
||||||
git commit -m "pull new editor translations from Transifex"
|
git commit -m "fix: pull new editor translations from Transifex"
|
||||||
echo "MADE_CHANGES=true" >> "$GITHUB_OUTPUT"
|
echo "MADE_CHANGES=true" >> "$GITHUB_OUTPUT"
|
||||||
git push
|
git push
|
||||||
fi
|
fi
|
||||||
|
|
1
.husky/.gitattributes
vendored
Normal file
1
.husky/.gitattributes
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
* text eol=lf
|
4
.husky/commit-msg
Executable file
4
.husky/commit-msg
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname -- "$0")/_/husky.sh"
|
||||||
|
|
||||||
|
npx --no-install commitlint --edit "$1"
|
95
README.md
95
README.md
|
@ -2,35 +2,102 @@
|
||||||
|
|
||||||
Translation of all Scratch projects is managed on the Transifex service: https://www.transifex.com/llk/public
|
Translation of all Scratch projects is managed on the Transifex service: https://www.transifex.com/llk/public
|
||||||
|
|
||||||
This repository collects translations submitted to the Scratch projects on Transifex. **Please do not submit PRs. If you would like to contribute translations, please sign up to translate on Transifex.**
|
This repository collects translations submitted to the Scratch projects on Transifex. **Please do not submit PRs. If
|
||||||
|
you would like to contribute translations, please sign up to translate on Transifex.**
|
||||||
|
|
||||||
## Using scratch-l10n in development
|
## Using scratch-l10n in development
|
||||||
|
|
||||||
#### Installation
|
### Basic Use
|
||||||
```bash
|
|
||||||
npm install --save-dev scratch-l10n
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Basic Use
|
|
||||||
```js
|
```js
|
||||||
import locales, {localeData, isRtl} from 'scratch-l10n';
|
import locales, {localeData, isRtl} from 'scratch-l10n';
|
||||||
import editorMessages from 'scratch-l10n/locales/editor-messages';
|
import editorMessages from 'scratch-l10n/locales/editor-messages';
|
||||||
```
|
```
|
||||||
|
|
||||||
* `locales`: currently supported locales for the Scratch project
|
* `locales`: currently supported locales for the Scratch project
|
||||||
* `isRtl`: function that returns true if the locale is one that is written right-to-left
|
* `isRtl`: function that returns true if the locale is one that is written right-to-left
|
||||||
* `localeData`: locale data for the supported locales, in the format accepted by `addLocaleData` required by `react-intl`
|
* `localeData`: locale data for the supported locales, in the format accepted by `addLocaleData` required by `react-intl`
|
||||||
* `editorMessages`: the actual message strings for all supported locales for a particular resource. `editorMessages` collects all the strings for the interface, extensions and paint-editor.
|
* `editorMessages`: the actual message strings for all supported locales for a particular resource. `editorMessages`
|
||||||
|
collects all the strings for the interface, extensions and paint-editor.
|
||||||
|
|
||||||
|
### Useful Scripts
|
||||||
|
|
||||||
#### Useful Scripts
|
|
||||||
scratch-l10n provides:
|
scratch-l10n provides:
|
||||||
* `build-i18n-src`: script that uses babel and plugins to extract all `FormattedMessage` strings for translation. Combines the message from all the source files into one `en.json`
|
|
||||||
* `tx-push-src`: script to push the `en.json` file to Transifex. Requires that the environment variable `TX_TOKEN` is set with a value that has developer access to the Scratch projects on Transifex (i.e. Scratch Team only)
|
|
||||||
|
|
||||||
#### Versioning
|
* `build-i18n-src`: script that uses babel and plugins to extract all `FormattedMessage` strings for translation.
|
||||||
scratch-l10n uses semantic versioning - breaking changes will increment the major version number, and new features (e.g. a new language) will increment the minor version number. However, the patch number is actually a datetime string. That way it's easy to see how recently the translations were updated.
|
Combines the message from all the source files into one `en.json`
|
||||||
|
* `tx-push-src`: script to push the `en.json` file to Transifex. Requires that the environment variable `TX_TOKEN` is
|
||||||
|
set with a value that has developer access to the Scratch projects on Transifex (i.e. Scratch Team only)
|
||||||
|
|
||||||
In general, changes that require a PR (new functionality, new language) should increment the minor version. Pulling new translations from Transifex is automated and will commit to master directly.
|
### Versioning
|
||||||
|
|
||||||
#### Deprecations
|
`scratch-l10n` uses semantic versioning - breaking changes will increment the major version number, and new features
|
||||||
|
(e.g. a new language) will increment the minor version number. Pulling new translations from Transifex is automated
|
||||||
|
and will increase the patch version.
|
||||||
|
|
||||||
|
### Deprecations
|
||||||
|
|
||||||
We are moving away from using the `tx` cli, so the `.tx/config` file will eventually be deprecated.
|
We are moving away from using the `tx` cli, so the `.tx/config` file will eventually be deprecated.
|
||||||
|
|
||||||
|
## Committing
|
||||||
|
|
||||||
|
This project uses [semantic release](https://github.com/semantic-release/semantic-release) to ensure version bumps
|
||||||
|
follow semver so that projects depending on it don't break unexpectedly.
|
||||||
|
|
||||||
|
In order to automatically determine version updates, semantic release expects commit messages to follow the
|
||||||
|
[conventional-changelog](https://github.com/bcoe/conventional-changelog-standard/blob/master/convention.md)
|
||||||
|
specification.
|
||||||
|
|
||||||
|
Here's a quick introduction:
|
||||||
|
|
||||||
|
* Prefix your commit subject with `fix:` if it fixes a bug but doesn't add any new functionality and doesn't change
|
||||||
|
the API.
|
||||||
|
* Prefix your commit subject with `feat:` if it adds new functionality but maintains backwards compatibility.
|
||||||
|
* Include `BREAKING CHANGE:` as a footer in your commit body, or add `!` to the commit subject, if the change breaks
|
||||||
|
compatibility with existing code.
|
||||||
|
* Other prefixes, such as `chore:`, `docs:`, etc., are allowed but will not change the version or cause a new release.
|
||||||
|
These should only be used for changes that do not affect functionality.
|
||||||
|
|
||||||
|
### Example commit messages
|
||||||
|
|
||||||
|
For more examples, see the [conventional commits documentation](https://www.conventionalcommits.org/en/v1.0.0/#examples).
|
||||||
|
|
||||||
|
#### Fix
|
||||||
|
|
||||||
|
This will increase the `z` in `Version x.y.z`.
|
||||||
|
|
||||||
|
```text
|
||||||
|
fix: fix typo in the sandwich-making instructions
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Feature
|
||||||
|
|
||||||
|
This will increase the `y` in `Version x.y.z` and reset `z` to 0.
|
||||||
|
|
||||||
|
```text
|
||||||
|
feat: add support for halloumi cheese
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Breaking Change
|
||||||
|
|
||||||
|
Either of these will increase the `x` in `Version x.y.z` and reset `y` and `z` to 0.
|
||||||
|
|
||||||
|
```text
|
||||||
|
fix: refine our definition of a sandwich
|
||||||
|
|
||||||
|
BREAKING CHANGE: support for hot dogs has been removed as we no longer consider them sandwiches
|
||||||
|
```
|
||||||
|
|
||||||
|
```text
|
||||||
|
fix!: remove support for hot dogs as we no longer consider them sandwiches
|
||||||
|
```
|
||||||
|
|
||||||
|
### Commitizen
|
||||||
|
|
||||||
|
You can use the [commitizen CLI](https://github.com/commitizen/cz-cli) to make commits formatted in this way:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g commitizen@latest cz-conventional-changelog@latest
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you're ready to make commits using `git cz`.
|
||||||
|
|
4
commitlint.config.js
Normal file
4
commitlint.config.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
module.exports = {
|
||||||
|
extends: ['@commitlint/config-conventional'],
|
||||||
|
ignores: [message => message.startsWith('chore(release):')]
|
||||||
|
};
|
54763
package-lock.json
generated
54763
package-lock.json
generated
File diff suppressed because it is too large
Load diff
179
package.json
179
package.json
|
@ -1,86 +1,97 @@
|
||||||
{
|
{
|
||||||
"name": "scratch-l10n",
|
"name": "scratch-l10n",
|
||||||
"version": "3.16.0",
|
"version": "3.16.0",
|
||||||
"description": "Localization for the Scratch 3.0 components",
|
"description": "Localization for the Scratch 3.0 components",
|
||||||
"main": "./dist/l10n.js",
|
"main": "./dist/l10n.js",
|
||||||
"browser": "./src/index.js",
|
"browser": "./src/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"build-i18n-src": "./scripts/build-i18n-src.js",
|
"build-i18n-src": "./scripts/build-i18n-src.js",
|
||||||
"tx-push-src": "./scripts/tx-push-src.js"
|
"tx-push-src": "./scripts/tx-push-src.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:data": "babel-node scripts/build-data",
|
"build": "npm run clean && npm run build:data && webpack --progress --colors --bail",
|
||||||
"build": "npm run clean && npm run build:data && webpack --progress --colors --bail",
|
"build:data": "babel-node scripts/build-data",
|
||||||
"clean": "rimraf ./dist ./locales && mkdirp dist locales",
|
"clean": "rimraf ./dist ./locales && mkdirp dist locales",
|
||||||
"lint:js": "eslint . --ext .js",
|
"lint": "npm run lint:js && npm run lint:json",
|
||||||
"lint:json": "jshint -e .json www editor/blocks editor/extensions editor/interface editor/paint-editor",
|
"lint:js": "eslint . --ext .js",
|
||||||
"lint": "npm run lint:js && npm run lint:json",
|
"lint:json": "jshint -e .json www editor/blocks editor/extensions editor/interface editor/paint-editor",
|
||||||
"pull:interface": "babel-node scripts/tx-pull-editor scratch-editor interface ./editor/interface/",
|
"prepare": "husky install",
|
||||||
"pull:paint": "babel-node scripts/tx-pull-editor scratch-editor paint-editor ./editor/paint-editor/",
|
"pull:blocks": "babel-node scripts/tx-pull-editor scratch-editor blocks ./editor/blocks/",
|
||||||
"pull:extensions": "babel-node scripts/tx-pull-editor scratch-editor extensions ./editor/extensions/",
|
"pull:editor": "npm run pull:blocks && npm run pull:extensions && npm run pull:paint && npm run pull:interface",
|
||||||
"pull:blocks": "babel-node scripts/tx-pull-editor scratch-editor blocks ./editor/blocks/",
|
"pull:extensions": "babel-node scripts/tx-pull-editor scratch-editor extensions ./editor/extensions/",
|
||||||
"pull:editor": "npm run pull:blocks && npm run pull:extensions && npm run pull:paint && npm run pull:interface",
|
"pull:help": "npm run pull:help:names && npm run pull:help:articles",
|
||||||
"pull:www": "babel-node scripts/tx-pull-www ./www",
|
"pull:help:articles": "./scripts/tx-pull-help-articles.js",
|
||||||
"pull:help:names": "./scripts/tx-pull-help-names.js",
|
"pull:help:names": "./scripts/tx-pull-help-names.js",
|
||||||
"pull:help:articles": "./scripts/tx-pull-help-articles.js",
|
"pull:interface": "babel-node scripts/tx-pull-editor scratch-editor interface ./editor/interface/",
|
||||||
"pull:help": "npm run pull:help:names && npm run pull:help:articles",
|
"pull:paint": "babel-node scripts/tx-pull-editor scratch-editor paint-editor ./editor/paint-editor/",
|
||||||
"push:help": "./scripts/tx-push-help.js",
|
"pull:www": "babel-node scripts/tx-pull-www ./www",
|
||||||
"sync:help": "npm run push:help && npm run pull:help",
|
"push:help": "./scripts/tx-push-help.js",
|
||||||
"test": "npm run lint:js && npm run validate:editor && npm run validate:www && npm run build && npm run lint:json",
|
"sync:help": "npm run push:help && npm run pull:help",
|
||||||
"update": "scripts/update-translations.sh",
|
"test": "npm run lint:js && npm run validate:editor && npm run validate:www && npm run build && npm run lint:json",
|
||||||
"validate:blocks": "babel-node scripts/validate-translations ./editor/blocks/",
|
"update": "scripts/update-translations.sh",
|
||||||
"validate:extensions": "babel-node scripts/validate-translations ./editor/extensions/ && babel-node scripts/validate-extension-inputs",
|
"validate:blocks": "babel-node scripts/validate-translations ./editor/blocks/",
|
||||||
"validate:interface": "babel-node scripts/validate-translations ./editor/interface/",
|
"validate:editor": "npm run validate:blocks && npm run validate:extensions && npm run validate:interface && npm run validate:paint",
|
||||||
"validate:paint": "babel-node scripts/validate-translations ./editor/paint-editor/",
|
"validate:extensions": "babel-node scripts/validate-translations ./editor/extensions/ && babel-node scripts/validate-extension-inputs",
|
||||||
"validate:editor": "npm run validate:blocks && npm run validate:extensions && npm run validate:interface && npm run validate:paint",
|
"validate:interface": "babel-node scripts/validate-translations ./editor/interface/",
|
||||||
"validate:www": "babel-node scripts/validate-www ./www"
|
"validate:paint": "babel-node scripts/validate-translations ./editor/paint-editor/",
|
||||||
},
|
"validate:www": "babel-node scripts/validate-www ./www"
|
||||||
"repository": {
|
},
|
||||||
"type": "git",
|
"repository": {
|
||||||
"url": "git+https://github.com/LLK/scratch-l10n.git"
|
"type": "git",
|
||||||
},
|
"url": "git+https://github.com/scratchfoundation/scratch-l10n.git"
|
||||||
"author": "Massachusetts Institute of Technology",
|
},
|
||||||
"license": "BSD-3-Clause",
|
"author": "Massachusetts Institute of Technology",
|
||||||
"bugs": {
|
"license": "BSD-3-Clause",
|
||||||
"url": "https://github.com/LLK/scratch-l10n/issues"
|
"bugs": {
|
||||||
},
|
"url": "https://github.com/LLK/scratch-l10n/issues"
|
||||||
"homepage": "https://github.com/LLK/scratch-l10n#readme",
|
},
|
||||||
"dependencies": {
|
"homepage": "https://github.com/scratchfoundation/scratch-l10n#readme",
|
||||||
"@babel/cli": "^7.1.2",
|
"dependencies": {
|
||||||
"@babel/core": "^7.1.2",
|
"@babel/cli": "^7.1.2",
|
||||||
"@transifex/api": "4.3.0",
|
"@babel/core": "^7.1.2",
|
||||||
"babel-plugin-react-intl": "^3.0.1",
|
"@transifex/api": "4.3.0",
|
||||||
"download": "^8.0.0",
|
"babel-plugin-react-intl": "^3.0.1",
|
||||||
"transifex": "1.6.6"
|
"download": "^8.0.0",
|
||||||
},
|
"transifex": "1.6.6"
|
||||||
"devDependencies": {
|
},
|
||||||
"@babel/eslint-parser": "7.18.2",
|
"devDependencies": {
|
||||||
"@babel/node": "7.22.19",
|
"@babel/eslint-parser": "7.18.2",
|
||||||
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
|
"@babel/node": "7.22.19",
|
||||||
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
|
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
|
||||||
"@babel/plugin-transform-async-to-generator": "^7.1.0",
|
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
|
||||||
"@babel/preset-env": "^7.9.5",
|
"@babel/plugin-transform-async-to-generator": "^7.1.0",
|
||||||
"@babel/preset-react": "^7.0.0",
|
"@babel/preset-env": "^7.9.5",
|
||||||
"async": "3.2.5",
|
"@babel/preset-react": "^7.0.0",
|
||||||
"babel-eslint": "^10.0.1",
|
"@commitlint/cli": "18.4.4",
|
||||||
"babel-loader": "8.3.0",
|
"@commitlint/config-conventional": "18.4.4",
|
||||||
"eslint": "8.17.0",
|
"async": "3.2.5",
|
||||||
"eslint-config-scratch": "9.0.3",
|
"babel-eslint": "^10.0.1",
|
||||||
"eslint-plugin-import": "2.29.1",
|
"babel-loader": "8.3.0",
|
||||||
"eslint-plugin-react": "^7.5.1",
|
"eslint": "8.17.0",
|
||||||
"format-message-cli": "6.2.4",
|
"eslint-config-scratch": "9.0.3",
|
||||||
"format-message-parse": "6.2.4",
|
"eslint-plugin-import": "2.29.1",
|
||||||
"glob": "7.2.3",
|
"eslint-plugin-react": "^7.5.1",
|
||||||
"jshint": "2.13.6",
|
"format-message-cli": "6.2.4",
|
||||||
"json": "^9.0.6",
|
"format-message-parse": "6.2.4",
|
||||||
"jsonlint": "1.6.3",
|
"glob": "7.2.3",
|
||||||
"lodash.defaultsdeep": "4.6.1",
|
"husky": "8.0.3",
|
||||||
"mkdirp": "^0.5.1",
|
"jshint": "2.13.6",
|
||||||
"node-fetch": "^2.6.0",
|
"json": "^9.0.6",
|
||||||
"p-limit": "2.3.0",
|
"jsonlint": "1.6.3",
|
||||||
"p-queue": "3.2.0",
|
"lodash.defaultsdeep": "4.6.1",
|
||||||
"rimraf": "^2.6.2",
|
"mkdirp": "^0.5.1",
|
||||||
"webpack": "^4.6.0",
|
"node-fetch": "^2.6.0",
|
||||||
"webpack-cli": "^3.1.2"
|
"p-limit": "2.3.0",
|
||||||
|
"p-queue": "3.2.0",
|
||||||
|
"rimraf": "^2.6.2",
|
||||||
|
"scratch-semantic-release-config": "1.0.8",
|
||||||
|
"semantic-release": "19.0.5",
|
||||||
|
"webpack": "^4.6.0",
|
||||||
|
"webpack-cli": "^3.1.2"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"commitizen": {
|
||||||
|
"path": "cz-conventional-changelog"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
14
release.config.js
Normal file
14
release.config.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
module.exports = {
|
||||||
|
extends: 'scratch-semantic-release-config',
|
||||||
|
branches: [
|
||||||
|
{
|
||||||
|
name: 'master'
|
||||||
|
// default channel
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'hotfix/*',
|
||||||
|
channel: 'hotfix',
|
||||||
|
prerelease: 'hotfix'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
|
@ -11,5 +11,5 @@ npm run test
|
||||||
|
|
||||||
# commit any updates and push. Build and release should happen on the push not here.
|
# commit any updates and push. Build and release should happen on the push not here.
|
||||||
git add .
|
git add .
|
||||||
git commit -m "pull new editor translations from Transifex"
|
git commit -m "fix: pull new editor translations from Transifex"
|
||||||
git push https://${GITHUB_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git HEAD:master
|
git push https://${GITHUB_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git HEAD:master
|
||||||
|
|
Loading…
Reference in a new issue