autorel 2.2.6 → 2.2.8-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -38
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +2 -0
- package/dist/config.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -3
- package/dist/lib/sh.d.ts +14 -1
- package/dist/lib/sh.js +17 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,10 +35,13 @@ _Currently only has built-in support for `GitHub` and `NPM`, but you can write y
|
|
|
35
35
|
- Comprehensive test coverage
|
|
36
36
|
- Less broken builds and more time to focus on your code!
|
|
37
37
|
|
|
38
|
+
[Read our FAQ on why you should use `autorel` and how it compares to other tools](docs/faq.md)
|
|
39
|
+
|
|
38
40
|
# Table of Contents
|
|
39
41
|
|
|
40
42
|
- [Example Usage (CLI)](#example-usage-cli)
|
|
41
43
|
- [Example Usage (Library)](#example-usage-library)
|
|
44
|
+
- [System Requirements](#system-requirements)
|
|
42
45
|
- [Commit Messages](#commit-messages)
|
|
43
46
|
- [Usage with GitHub Actions](#usage-with-github-actions)
|
|
44
47
|
- [Usage with Other Repositories (not GitHub)](#usage-with-other-repositories-not-github)
|
|
@@ -74,7 +77,9 @@ autorel --publish
|
|
|
74
77
|
|
|
75
78
|
## Avoiding Breaking Changes
|
|
76
79
|
|
|
77
|
-
|
|
80
|
+
If using the `npx` command, you may want to append the version number to prevent breaking changes in the future. You can do this by appending `@^` followed by the major version number.
|
|
81
|
+
|
|
82
|
+
Example: `npx autorel@^2`
|
|
78
83
|
|
|
79
84
|
# Example Usage (Library)
|
|
80
85
|
|
|
@@ -94,6 +99,14 @@ You may want to add the version number to the npx command to prevent breaking ch
|
|
|
94
99
|
});
|
|
95
100
|
```
|
|
96
101
|
|
|
102
|
+
# System Requirements
|
|
103
|
+
|
|
104
|
+
- Linux or MacOS (Windows is not officially supported)
|
|
105
|
+
- Node.js 14+
|
|
106
|
+
- NPM 7+
|
|
107
|
+
- Git 2.13+
|
|
108
|
+
- Bash
|
|
109
|
+
|
|
97
110
|
# Commit Messages
|
|
98
111
|
|
|
99
112
|
Commit messages are parsed to determine the version bump. They must follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard specification.
|
|
@@ -135,15 +148,7 @@ jobs:
|
|
|
135
148
|
node-version: latest
|
|
136
149
|
registry-url: "https://registry.npmjs.org"
|
|
137
150
|
cache: 'npm'
|
|
138
|
-
-
|
|
139
|
-
id: cache-node-modules
|
|
140
|
-
with:
|
|
141
|
-
path: node_modules
|
|
142
|
-
key: ${{runner.os}}-node-${{hashFiles('package-lock.json')}}
|
|
143
|
-
- run: npm ci
|
|
144
|
-
- run: npm run lint
|
|
145
|
-
- run: npm run test
|
|
146
|
-
- run: npx autorel --publish
|
|
151
|
+
- run: npx autorel@^2
|
|
147
152
|
env:
|
|
148
153
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
149
154
|
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
@@ -155,7 +160,7 @@ It's also recommended you create a `.autorel.yaml` file in the root of your proj
|
|
|
155
160
|
|
|
156
161
|
`autorel` is designed to work with any CI/CD system, not just GitHub Actions. You can use it with GitLab, Bitbucket, Jenkins, or any other system that supports running shell commands.
|
|
157
162
|
|
|
158
|
-
Simply use the `--skip-release` flag (arg: `skipRelease: true`) to skip creating a release on GitHub. Then, you can use
|
|
163
|
+
Simply use the `--skip-release` flag (arg: `skipRelease: true`) to skip creating a release on GitHub. Then, you can use the `--run` flag (arg: `run: string`) to run any command or script after the version bump with the new version number available as an environment variable [see below](#run).
|
|
159
164
|
|
|
160
165
|
If you're interested in contributing built-in support for other systems, please open an issue or PR.
|
|
161
166
|
|
|
@@ -173,9 +178,9 @@ When run in CLI mode, `autorel` can be configured via CLI arguments or a `yaml`
|
|
|
173
178
|
|
|
174
179
|
However, omitting the `--publish` flag will still publish to NPM if `publish: true` is set in the `yaml` file, and the same for other binary flags.
|
|
175
180
|
|
|
176
|
-
When used as a library, you
|
|
181
|
+
When used as a library, you pass the configuration directly to the `autorel` function.
|
|
177
182
|
|
|
178
|
-
All arguments are optional
|
|
183
|
+
All arguments are optional.
|
|
179
184
|
|
|
180
185
|
> ❗️ The `yaml` configuration file must be named `.autorel.yaml` and be in the root of your project.
|
|
181
186
|
|
|
@@ -207,32 +212,59 @@ Whether to skip creating a release on GitHub. If `true`, the release will not be
|
|
|
207
212
|
|
|
208
213
|
## run
|
|
209
214
|
|
|
210
|
-
A command to run after the release is complete.
|
|
215
|
+
A `bash` command/script to run after the release is complete. All scripts are run in "-e" mode, meaning they will exit on the first error.
|
|
216
|
+
|
|
217
|
+
The following environment variables are available:
|
|
211
218
|
|
|
212
219
|
| Variable | Description |
|
|
213
220
|
| --- | --- |
|
|
214
221
|
| `NEXT_VERSION` | The new version number (without the `v`) |
|
|
215
222
|
| `NEXT_TAG` | The new tag, ie. v3.1.0 |
|
|
216
223
|
|
|
224
|
+
Example CLI usage:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
npx autorel --run 'echo "Next version is ${NEXT_VERSION}"'
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Example YAML usage:
|
|
231
|
+
|
|
232
|
+
```yaml
|
|
233
|
+
run: echo "Next version is ${NEXT_VERSION}"
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
You can use the multi-line string syntax in YAML to write a script:
|
|
237
|
+
|
|
238
|
+
```yaml
|
|
239
|
+
run: |
|
|
240
|
+
echo "$(date +"%Y-%m-%d") ${NEXT_VERSION}" >> versions.txt
|
|
241
|
+
aws s3 sync . s3://my-bucket
|
|
242
|
+
```
|
|
243
|
+
|
|
217
244
|
- CLI: `--run`
|
|
218
245
|
- Argument: `run: string`
|
|
219
246
|
- Default: `undefined`
|
|
220
247
|
|
|
221
|
-
##
|
|
248
|
+
## preRun
|
|
222
249
|
|
|
223
|
-
A bash script to run
|
|
250
|
+
A `bash` command/script to run before the release is started. All scripts are run in "-e" mode, meaning they will exit on the first error. Here's where you can do things like run tests or do build steps.
|
|
224
251
|
|
|
225
|
-
|
|
252
|
+
This could save you time and money by not running unnecessary steps in your CI/CD pipeline. It will not run if no release is determined to be necessary, and it will not run in dry-run mode.
|
|
226
253
|
|
|
227
|
-
|
|
254
|
+
This is run *after* determining the new version number but *before* pushing tags, creating the release on GitHub, updating the package.json, or publishing to NPM.
|
|
255
|
+
|
|
256
|
+
Example YAML usage:
|
|
228
257
|
|
|
229
258
|
```yaml
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
259
|
+
preRun: |
|
|
260
|
+
npm ci
|
|
261
|
+
npm run build
|
|
262
|
+
npm run test
|
|
263
|
+
npm run lint
|
|
233
264
|
```
|
|
234
265
|
|
|
235
|
-
-
|
|
266
|
+
- CLI: `--pre-run`
|
|
267
|
+
- Argument: `preRun: string`
|
|
236
268
|
- Default: `undefined`
|
|
237
269
|
|
|
238
270
|
## preRelease
|
|
@@ -245,20 +277,21 @@ The pre-release channel to use. This will be appended to the version number. For
|
|
|
245
277
|
- Argument: `preRelease: string`
|
|
246
278
|
- Default: `undefined`
|
|
247
279
|
|
|
248
|
-
## breakingChangeTitle (YAML only)
|
|
280
|
+
## breakingChangeTitle (YAML/library only)
|
|
249
281
|
|
|
250
282
|
The title to use for the breaking changes section in the release notes.
|
|
251
283
|
|
|
252
284
|
- Argument: `breakingChangeTitle: string`
|
|
253
285
|
- Default: `"🚨 Breaking Changes 🚨"`
|
|
254
286
|
|
|
255
|
-
## commitTypes (YAML only)
|
|
287
|
+
## commitTypes (YAML/library only)
|
|
256
288
|
|
|
257
|
-
The commit types to use for both the release notes and version bumping.
|
|
289
|
+
The commit types to use for both the release notes and version bumping.
|
|
258
290
|
|
|
259
291
|
- Argument: `commitTypes: CommitType[]`
|
|
292
|
+
- Defaults: [src/defaults.ts](src/defaults.ts)
|
|
260
293
|
|
|
261
|
-
## branches (YAML only)
|
|
294
|
+
## branches (YAML/library only)
|
|
262
295
|
|
|
263
296
|
The branches to use for the release along with their pre-release channel. If not provided, the default is:
|
|
264
297
|
|
|
@@ -302,7 +335,7 @@ branches:
|
|
|
302
335
|
publish: true
|
|
303
336
|
|
|
304
337
|
# Run custom script after publish
|
|
305
|
-
|
|
338
|
+
run: |
|
|
306
339
|
echo "$(date +"%Y-%m-%d") ${NEXT_VERSION}" >> versions.txt
|
|
307
340
|
aws s3 sync . s3://my-bucket
|
|
308
341
|
```
|
|
@@ -325,11 +358,12 @@ This will output configuration and other debug information.
|
|
|
325
358
|
|
|
326
359
|
If using our npm publishing feature, the package.json file's version will be updated in memory before being pushed to npm, as this is the only place where it's actually required. The change will not be pushed to the repository, as it is not necessary and could cause conflicts. See [this post](https://semantic-release.gitbook.io/semantic-release/support/faq)
|
|
327
360
|
|
|
328
|
-
|
|
361
|
+
If you need access to the new version number in your CI/CD pipeline, you can use the `NEXT_VERSION` or `NEXT_TAG` environment variables.
|
|
362
|
+
|
|
363
|
+
# Support & Feedback
|
|
329
364
|
|
|
330
365
|
- Star this repo if you like it!
|
|
331
366
|
- Submit an [issue](https://github.com/mhweiner/autorel/issues) with your problem, feature request or bug report
|
|
332
|
-
- Issue a PR against `main` and request review. Make sure all tests pass and coverage is good.
|
|
333
367
|
- Write about `autorel` in your blog, tweet about it, or share it with your friends!
|
|
334
368
|
- Support this package by adding our badge to your README:
|
|
335
369
|
|
|
@@ -337,18 +371,13 @@ If using our npm publishing feature, the package.json file's version will be upd
|
|
|
337
371
|
[](https://github.com/mhweiner/autorel)
|
|
338
372
|
```
|
|
339
373
|
|
|
374
|
+
# Contributors & Maintainers Wanted!
|
|
375
|
+
|
|
376
|
+
We are looking for contributors and maintainers to help with the project. If you are interested, please open an issue or PR. Together we can help bring automated releases to everyone!
|
|
377
|
+
|
|
340
378
|
## License
|
|
341
379
|
|
|
342
380
|
MIT © Marc H. Weiner
|
|
343
381
|
|
|
344
382
|
[See full license](LICENSE)
|
|
345
383
|
|
|
346
|
-
## Sponsors
|
|
347
|
-
|
|
348
|
-
<picture>
|
|
349
|
-
<source srcset="docs/aeroview-logo-lockup.svg" media="(prefers-color-scheme: dark)">
|
|
350
|
-
<source srcset="docs/aeroview-logo-lockup-dark.svg" media="(prefers-color-scheme: light)">
|
|
351
|
-
<img src="docs/aeroview-logo-lockup-dark.svg" alt="Logo" style="max-width: 150px;margin: 0 0 10px">
|
|
352
|
-
</picture>
|
|
353
|
-
|
|
354
|
-
Aeroview is a developer-friendly, AI-powered observability platform that helps you monitor, troubleshoot, and optimize your applications. Get started for free at [https://aeroview.io](https://aeroview.io).
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -21,6 +21,7 @@ program
|
|
|
21
21
|
.option('--pre-release <value>', 'Pre-release channel. If specified, the release will be marked as a pre-release. Overrides branches configuration. (arg: preRelease)')
|
|
22
22
|
.option('--use-version <value>', 'Specify a version to be used instead of calculating it from commit analysis. Must be a valid SemVer version, with no \'v\'. Overrides --pre-release, commitType, and branches configuration. (arg: useVersion)')
|
|
23
23
|
.option('--run <value>', 'Command to run after the release is successful. (arg: run)')
|
|
24
|
+
.option('--pre-run <value>', 'Command to run after the release is successful. (arg: preRun)')
|
|
24
25
|
.option('--skip-release', 'Skips creating a release on GitHub. (arg: skipRelease)')
|
|
25
26
|
.option('--publish', 'Publish the package to npm, requires passing --npm-token or NPM_TOKEN environment variable. (arg: publish)')
|
|
26
27
|
.parse(process.argv);
|
|
@@ -28,6 +29,7 @@ const options = program.opts();
|
|
|
28
29
|
const cliOptions = {
|
|
29
30
|
dryRun: options.dryRun,
|
|
30
31
|
run: options.run,
|
|
32
|
+
preRun: options.preRun,
|
|
31
33
|
prereleaseChannel: options.preRelease,
|
|
32
34
|
useVersion: options.useVersion,
|
|
33
35
|
publish: options.publish,
|
package/dist/config.js
CHANGED
|
@@ -36,6 +36,7 @@ const defaults_1 = require("./defaults");
|
|
|
36
36
|
const validateConfig = typura_1.predicates.object({
|
|
37
37
|
dryRun: typura_1.predicates.optional(typura_1.predicates.boolean()),
|
|
38
38
|
run: typura_1.predicates.optional(typura_1.predicates.string()),
|
|
39
|
+
preRun: typura_1.predicates.optional(typura_1.predicates.string()),
|
|
39
40
|
runScript: typura_1.predicates.optional(typura_1.predicates.string()),
|
|
40
41
|
prereleaseChannel: typura_1.predicates.optional(typura_1.predicates.string()),
|
|
41
42
|
useVersion: typura_1.predicates.optional(typura_1.predicates.string()),
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -103,6 +103,13 @@ async function autorel(args) {
|
|
|
103
103
|
output_1.default.debug(`The changelog is:\n${changelog}`);
|
|
104
104
|
if (args.dryRun)
|
|
105
105
|
return;
|
|
106
|
+
if (args.preRun) {
|
|
107
|
+
output_1.default.log('Running pre-release bash script:');
|
|
108
|
+
output_1.default.log('----------------------------');
|
|
109
|
+
output_1.default.log(args.preRun);
|
|
110
|
+
output_1.default.log('----------------------------');
|
|
111
|
+
(0, sh_1.bash)(args.preRun);
|
|
112
|
+
}
|
|
106
113
|
git.createAndPushTag(nextTag);
|
|
107
114
|
const { owner, repository } = git.getRepo();
|
|
108
115
|
!args.skipRelease && github.createRelease({
|
|
@@ -120,15 +127,20 @@ async function autorel(args) {
|
|
|
120
127
|
}
|
|
121
128
|
process.env.NEXT_VERSION = nextTag.replace('v', '');
|
|
122
129
|
process.env.NEXT_TAG = nextTag;
|
|
123
|
-
// run post-release script
|
|
130
|
+
// run post-release bash script
|
|
124
131
|
if (args.run) {
|
|
125
|
-
output_1.default.log('Running post-release command:');
|
|
132
|
+
output_1.default.log('Running post-release bash script/command:');
|
|
126
133
|
output_1.default.log('----------------------------');
|
|
127
134
|
output_1.default.log(args.run);
|
|
128
135
|
output_1.default.log('----------------------------');
|
|
129
|
-
(0, sh_1.
|
|
136
|
+
(0, sh_1.bash)(args.run);
|
|
130
137
|
}
|
|
131
138
|
else if (args.runScript) {
|
|
139
|
+
// TODO: delete this block in the next major version
|
|
140
|
+
output_1.default.warn('----------------------------');
|
|
141
|
+
output_1.default.warn('🚨 The "runScript" option is deprecated. Please use "run" instead. 🚨');
|
|
142
|
+
output_1.default.warn('🚨 The "runScript" option will be removed in the next major version. 🚨');
|
|
143
|
+
output_1.default.warn('----------------------------');
|
|
132
144
|
output_1.default.log('Running post-release bash script:');
|
|
133
145
|
output_1.default.log('');
|
|
134
146
|
output_1.default.log('----------------------------');
|
package/dist/lib/sh.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Executes a bash program/command and returns the output. This is a tagged template
|
|
3
|
+
* literal function, so you can use it like this:
|
|
4
|
+
*
|
|
5
|
+
* const output = $`echo "Hello, World!"`;
|
|
6
|
+
*
|
|
7
|
+
* Also, it logs the command/script to the console in debug mode.
|
|
8
|
+
*/
|
|
1
9
|
export declare function $(strings: TemplateStringsArray, ...values: any[]): string;
|
|
10
|
+
/**
|
|
11
|
+
* Executes a bash program/command but does not return the output. Is not a tagged template
|
|
12
|
+
* literal function. You can use it like this:
|
|
13
|
+
*
|
|
14
|
+
* bash('echo "Hello, World!" > /dev/null');
|
|
15
|
+
*/
|
|
2
16
|
export declare function bash(cmd: string): void;
|
|
3
|
-
export declare function cmd(cmd: string): void;
|
package/dist/lib/sh.js
CHANGED
|
@@ -3,24 +3,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.bash = exports.$ = void 0;
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
8
|
const output_1 = __importDefault(require("./output"));
|
|
9
|
+
/**
|
|
10
|
+
* Executes a bash program/command and returns the output. This is a tagged template
|
|
11
|
+
* literal function, so you can use it like this:
|
|
12
|
+
*
|
|
13
|
+
* const output = $`echo "Hello, World!"`;
|
|
14
|
+
*
|
|
15
|
+
* Also, it logs the command/script to the console in debug mode.
|
|
16
|
+
*/
|
|
9
17
|
function $(strings, ...values) {
|
|
10
18
|
const command = strings.reduce((acc, str, i) => acc + str + (values[i] || ''), '');
|
|
11
19
|
output_1.default.debug(command);
|
|
12
|
-
const escapedCommand = command.replace(/(["$`\\])/g, '\\$1')
|
|
20
|
+
const escapedCommand = command.replace(/(["$`\\])/g, '\\$1');
|
|
13
21
|
const output = (0, child_process_1.execSync)(`bash -c "${escapedCommand}"`, { encoding: 'utf8' });
|
|
14
22
|
return output.trim();
|
|
15
23
|
}
|
|
16
24
|
exports.$ = $;
|
|
25
|
+
/**
|
|
26
|
+
* Executes a bash program/command but does not return the output. Is not a tagged template
|
|
27
|
+
* literal function. You can use it like this:
|
|
28
|
+
*
|
|
29
|
+
* bash('echo "Hello, World!" > /dev/null');
|
|
30
|
+
*/
|
|
17
31
|
function bash(cmd) {
|
|
18
|
-
const escapedCommand = cmd.replace(/(["$`\\])/g, '\\$1')
|
|
32
|
+
const escapedCommand = cmd.replace(/(["$`\\])/g, '\\$1');
|
|
19
33
|
(0, child_process_1.execSync)(`bash -c "${escapedCommand}"`, { encoding: 'utf8', stdio: 'inherit' });
|
|
20
34
|
}
|
|
21
35
|
exports.bash = bash;
|
|
22
|
-
function cmd(cmd) {
|
|
23
|
-
(0, child_process_1.execSync)(cmd, { encoding: 'utf8', stdio: 'inherit' });
|
|
24
|
-
}
|
|
25
|
-
exports.cmd = cmd;
|
|
26
36
|
//# sourceMappingURL=sh.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autorel",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.8-next.3",
|
|
4
4
|
"description": "Automate semantic releases based on conventional commits. Similar to semantic-release but much simpler.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Marc H. Weiner <mhweiner234@gmail.com> (https://mhweiner.com)",
|