Add publish workflow
ADD
.github/workflows/publish.yml
+name: Publish
+on:
+ push:
+ tags:
+ - v*
+
+jobs:
+ publish-npm:
+ runs-on: ubuntu-latest
+ name: npm publish
+
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-node@v1
+ with:
+ node-version: '13.x'
+
+ - name: Build release
+ run: node scripts/build-release dist
+
+ - name: Create tarball
+ run: tar -C dist -czvf dist.tar.gz .
+
+ - name: Upload tarball
+ uses: actions/upload-artifact@v1
+ with:
+ name: package.tgz
+ path: dist.tar.gz
+
+ - name: Publish
+ run: |
+ cd dist
+ npm publish
+ env:
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}

ADD
scripts/create-version
+#!/usr/bin/env node
+
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+require('./_setup.cjs');
+
+const child = require('child_process');
+const {argv, root} = require('./_constants.cjs');
+const path = require('path');
+const {exec} = require('./_utils.cjs');
+const https = require('https');
+
+function spawnSync(argv, cwd) {
+ const res = child.spawnSync(
+ 'npm',
+ ['--no-git-tag-version', 'version', ...argv],
+ {
+ cwd,
+ },
+ );
+
+ if (res.status !== 0) {
+ console.error(res.stderr.toString());
+ process.exit(1);
+ }
+
+ return res.stdout.toString();
+}
+
+// Ensure git isn't dirty
+const gitRes = child.spawnSync('git', ['diff', '--exit-code']);
+if (gitRes.status === 1) {
+ //console.error('Uncommitted changes');
+ //process.exit(1);
+}
+
+// Update root
+const version = spawnSync(argv, root).trim().slice(1);
+console.log('New version', version);
+
+// Check this isn't an already published version
+https.get(`https://registry.npmjs.org/rome/${version}`, (res) => {
+ if (res.statusCode !== 404) {
+ console.error('This version already exists');
+ process.exit(1);
+ }
+
+ // Update rome package
+ spawnSync([version], path.join(root, 'packages', 'rome'));
+
+ // Create commit and tag
+ exec('git', ['commit', '-m', `Release v${version}`]);
+ exec('git', 'tag', `v${version}`);
+
+ console.log('Done. Push to trigger action.');
+});

Add publish workflow