Skip to content

Commit 45b29db

Browse files
GitHub Actions Release script; (#5384)
* chore(ci): Add release-it script; * chore(ci): add github actions release script;
1 parent 493e04c commit 45b29db

File tree

3 files changed

+58
-26
lines changed

3 files changed

+58
-26
lines changed

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Release Axios
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
type:
6+
type: choice
7+
description: Choose release type
8+
options:
9+
- auto
10+
- patch
11+
- minor
12+
- major
13+
default: auto
14+
beta:
15+
type: boolean
16+
description: Prerelease
17+
default: false
18+
npm:
19+
type: boolean
20+
description: NPM release
21+
default: true
22+
dry:
23+
type: boolean
24+
description: Dry release
25+
default: false
26+
jobs:
27+
releaseIt:
28+
runs-on: ubuntu-latest
29+
env:
30+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
31+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
32+
steps:
33+
- uses: actions/checkout@v2
34+
with:
35+
fetch-depth: 0
36+
- name: git config
37+
run: |
38+
git config user.name "${GITHUB_ACTOR}"
39+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
40+
- name: Setup node
41+
uses: actions/setup-node@v3
42+
with:
43+
node-version: 16
44+
cache: npm
45+
- name: npm credentials
46+
run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
47+
- run: npm install
48+
- name: release
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
TYPE_ARG: ${{ fromJSON('{"auto":"", "patch":"--patch", "minor":"--minor", "major":"--major"}')[github.event.inputs.type] }}
52+
BETA_ARG: ${{ github.event.inputs.beta == true && '--preRelease=beta' || '' }}
53+
NPM_ARG: ${{ github.event.inputs.npm == false && '--no-npm' || '' }}
54+
DRY_ARG: ${{ github.event.inputs.dry == true && '--dry-run' || '' }}
55+
run: npm run release -- --ci --verbose $NPM_ARG $TYPE_ARG $BETA_ARG $DRY_ARG

bin/check-build-version.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import fs from 'fs';
22
import assert from 'assert';
33
import axios from '../index.js';
44
import axiosBuild from '../dist/node/axios.cjs';
5-
import inquirer from 'inquirer';
65

7-
const {version, name} = JSON.parse(fs.readFileSync('./package.json'));
6+
const {version} = JSON.parse(fs.readFileSync('./package.json'));
87

98
console.log('Checking versions...\n----------------------------')
109

@@ -16,27 +15,6 @@ console.log(`----------------------------`);
1615
assert.strictEqual(version, axios.VERSION, `Version mismatch between package and Axios`);
1716
assert.strictEqual(version, axiosBuild.VERSION, `Version mismatch between package and build`);
1817

19-
console.log('PASSED\n');
20-
21-
const choices = [
22-
`Yes, let's release Axios v${version} to npm`,
23-
`No, don't do an npm release - I'll do it myself`
24-
];
25-
26-
inquirer
27-
.prompt([
28-
{
29-
type: 'list',
30-
name: 'release',
31-
message: `You have requested an npm release for ${name.toUpperCase()} v${version}. Are you sure?`,
32-
choices
33-
}
34-
])
35-
.then((answers) => {
36-
if (choices.indexOf(answers.release)) {
37-
console.warn('terminate...');
38-
process.exit(1);
39-
}
40-
});
18+
console.log('✔️ PASSED\n');
4119

4220

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191
"get-stream": "^3.0.0",
9292
"gulp": "^4.0.2",
9393
"husky": "^8.0.2",
94-
"inquirer": "^9.1.4",
9594
"istanbul-instrumenter-loader": "^3.0.1",
9695
"jasmine-core": "^2.4.1",
9796
"karma": "^6.3.17",
@@ -169,7 +168,7 @@
169168
},
170169
"hooks": {
171170
"before:init": "npm test",
172-
"after:bump": "gulp version && npm run build",
171+
"after:bump": "gulp version && npm run build && npm run test:build:version",
173172
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
174173
}
175174
},

0 commit comments

Comments
 (0)