Merge pull request #224 from scratchfoundation/implement-semantic-release

Implement semantic release
This commit is contained in:
Christopher Willis-Ford 2024-01-16 10:35:14 -08:00 committed by GitHub
commit c55be08db2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 33411 additions and 21682 deletions

View file

@ -45,28 +45,8 @@ jobs:
mkdir -p ./test/results
npm test
- name: Generate release version
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)
- name: Run semantic-release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TAG: "latest"
run: |
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
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx --no -- semantic-release

View file

@ -2,8 +2,7 @@ name: Lint commit messages
on: [pull_request]
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.sha }}"
jobs:
commitlint:

View file

@ -53,7 +53,7 @@ jobs:
echo "MADE_CHANGES=false" >> "$GITHUB_OUTPUT"
echo "Nothing to commit."
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"
git push
fi

1
.husky/.gitattributes vendored Normal file
View file

@ -0,0 +1 @@
* text eol=lf

4
.husky/commit-msg Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx --no-install commitlint --edit "$1"

View file

@ -2,35 +2,102 @@
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
#### Installation
```bash
npm install --save-dev scratch-l10n
```
### Basic Use
#### Basic Use
```js
import locales, {localeData, isRtl} from 'scratch-l10n';
import editorMessages from 'scratch-l10n/locales/editor-messages';
```
* `locales`: currently supported locales for the Scratch project
* `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`
* `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:
* `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
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.
* `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)
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.
## 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
View file

@ -0,0 +1,4 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
ignores: [message => message.startsWith('chore(release):')]
};

54763
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,86 +1,97 @@
{
"name": "scratch-l10n",
"version": "3.16.0",
"description": "Localization for the Scratch 3.0 components",
"main": "./dist/l10n.js",
"browser": "./src/index.js",
"bin": {
"build-i18n-src": "./scripts/build-i18n-src.js",
"tx-push-src": "./scripts/tx-push-src.js"
},
"scripts": {
"build:data": "babel-node scripts/build-data",
"build": "npm run clean && npm run build:data && webpack --progress --colors --bail",
"clean": "rimraf ./dist ./locales && mkdirp dist locales",
"lint:js": "eslint . --ext .js",
"lint:json": "jshint -e .json www editor/blocks editor/extensions editor/interface editor/paint-editor",
"lint": "npm run lint:js && npm run lint:json",
"pull:interface": "babel-node scripts/tx-pull-editor scratch-editor interface ./editor/interface/",
"pull:paint": "babel-node scripts/tx-pull-editor scratch-editor paint-editor ./editor/paint-editor/",
"pull:extensions": "babel-node scripts/tx-pull-editor scratch-editor extensions ./editor/extensions/",
"pull:blocks": "babel-node scripts/tx-pull-editor scratch-editor blocks ./editor/blocks/",
"pull:editor": "npm run pull:blocks && npm run pull:extensions && npm run pull:paint && npm run pull:interface",
"pull:www": "babel-node scripts/tx-pull-www ./www",
"pull:help:names": "./scripts/tx-pull-help-names.js",
"pull:help:articles": "./scripts/tx-pull-help-articles.js",
"pull:help": "npm run pull:help:names && npm run pull:help:articles",
"push:help": "./scripts/tx-push-help.js",
"sync:help": "npm run push:help && npm run pull:help",
"test": "npm run lint:js && npm run validate:editor && npm run validate:www && npm run build && npm run lint:json",
"update": "scripts/update-translations.sh",
"validate:blocks": "babel-node scripts/validate-translations ./editor/blocks/",
"validate:extensions": "babel-node scripts/validate-translations ./editor/extensions/ && babel-node scripts/validate-extension-inputs",
"validate:interface": "babel-node scripts/validate-translations ./editor/interface/",
"validate:paint": "babel-node scripts/validate-translations ./editor/paint-editor/",
"validate:editor": "npm run validate:blocks && npm run validate:extensions && npm run validate:interface && npm run validate:paint",
"validate:www": "babel-node scripts/validate-www ./www"
},
"repository": {
"type": "git",
"url": "git+https://github.com/LLK/scratch-l10n.git"
},
"author": "Massachusetts Institute of Technology",
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/LLK/scratch-l10n/issues"
},
"homepage": "https://github.com/LLK/scratch-l10n#readme",
"dependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@transifex/api": "4.3.0",
"babel-plugin-react-intl": "^3.0.1",
"download": "^8.0.0",
"transifex": "1.6.6"
},
"devDependencies": {
"@babel/eslint-parser": "7.18.2",
"@babel/node": "7.22.19",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-transform-async-to-generator": "^7.1.0",
"@babel/preset-env": "^7.9.5",
"@babel/preset-react": "^7.0.0",
"async": "3.2.5",
"babel-eslint": "^10.0.1",
"babel-loader": "8.3.0",
"eslint": "8.17.0",
"eslint-config-scratch": "9.0.3",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-react": "^7.5.1",
"format-message-cli": "6.2.4",
"format-message-parse": "6.2.4",
"glob": "7.2.3",
"jshint": "2.13.6",
"json": "^9.0.6",
"jsonlint": "1.6.3",
"lodash.defaultsdeep": "4.6.1",
"mkdirp": "^0.5.1",
"node-fetch": "^2.6.0",
"p-limit": "2.3.0",
"p-queue": "3.2.0",
"rimraf": "^2.6.2",
"webpack": "^4.6.0",
"webpack-cli": "^3.1.2"
"name": "scratch-l10n",
"version": "3.16.0",
"description": "Localization for the Scratch 3.0 components",
"main": "./dist/l10n.js",
"browser": "./src/index.js",
"bin": {
"build-i18n-src": "./scripts/build-i18n-src.js",
"tx-push-src": "./scripts/tx-push-src.js"
},
"scripts": {
"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",
"lint": "npm run lint:js && npm run lint:json",
"lint:js": "eslint . --ext .js",
"lint:json": "jshint -e .json www editor/blocks editor/extensions editor/interface editor/paint-editor",
"prepare": "husky install",
"pull:blocks": "babel-node scripts/tx-pull-editor scratch-editor blocks ./editor/blocks/",
"pull:editor": "npm run pull:blocks && npm run pull:extensions && npm run pull:paint && npm run pull:interface",
"pull:extensions": "babel-node scripts/tx-pull-editor scratch-editor extensions ./editor/extensions/",
"pull:help": "npm run pull:help:names && npm run pull:help:articles",
"pull:help:articles": "./scripts/tx-pull-help-articles.js",
"pull:help:names": "./scripts/tx-pull-help-names.js",
"pull:interface": "babel-node scripts/tx-pull-editor scratch-editor interface ./editor/interface/",
"pull:paint": "babel-node scripts/tx-pull-editor scratch-editor paint-editor ./editor/paint-editor/",
"pull:www": "babel-node scripts/tx-pull-www ./www",
"push:help": "./scripts/tx-push-help.js",
"sync:help": "npm run push:help && npm run pull:help",
"test": "npm run lint:js && npm run validate:editor && npm run validate:www && npm run build && npm run lint:json",
"update": "scripts/update-translations.sh",
"validate:blocks": "babel-node scripts/validate-translations ./editor/blocks/",
"validate:editor": "npm run validate:blocks && npm run validate:extensions && npm run validate:interface && npm run validate:paint",
"validate:extensions": "babel-node scripts/validate-translations ./editor/extensions/ && babel-node scripts/validate-extension-inputs",
"validate:interface": "babel-node scripts/validate-translations ./editor/interface/",
"validate:paint": "babel-node scripts/validate-translations ./editor/paint-editor/",
"validate:www": "babel-node scripts/validate-www ./www"
},
"repository": {
"type": "git",
"url": "git+https://github.com/scratchfoundation/scratch-l10n.git"
},
"author": "Massachusetts Institute of Technology",
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/LLK/scratch-l10n/issues"
},
"homepage": "https://github.com/scratchfoundation/scratch-l10n#readme",
"dependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@transifex/api": "4.3.0",
"babel-plugin-react-intl": "^3.0.1",
"download": "^8.0.0",
"transifex": "1.6.6"
},
"devDependencies": {
"@babel/eslint-parser": "7.18.2",
"@babel/node": "7.22.19",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-transform-async-to-generator": "^7.1.0",
"@babel/preset-env": "^7.9.5",
"@babel/preset-react": "^7.0.0",
"@commitlint/cli": "18.4.4",
"@commitlint/config-conventional": "18.4.4",
"async": "3.2.5",
"babel-eslint": "^10.0.1",
"babel-loader": "8.3.0",
"eslint": "8.17.0",
"eslint-config-scratch": "9.0.3",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-react": "^7.5.1",
"format-message-cli": "6.2.4",
"format-message-parse": "6.2.4",
"glob": "7.2.3",
"husky": "8.0.3",
"jshint": "2.13.6",
"json": "^9.0.6",
"jsonlint": "1.6.3",
"lodash.defaultsdeep": "4.6.1",
"mkdirp": "^0.5.1",
"node-fetch": "^2.6.0",
"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
View file

@ -0,0 +1,14 @@
module.exports = {
extends: 'scratch-semantic-release-config',
branches: [
{
name: 'master'
// default channel
},
{
name: 'hotfix/*',
channel: 'hotfix',
prerelease: 'hotfix'
}
]
};

View file

@ -11,5 +11,5 @@ npm run test
# commit any updates and push. Build and release should happen on the push not here.
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