File tree Expand file tree Collapse file tree 3 files changed +4
-639
lines changed
.github/actions/javascript/getPreviousVersion Expand file tree Collapse file tree 3 files changed +4
-639
lines changed Original file line number Diff line number Diff line change 1
1
name : ' Get previous npm version'
2
2
description : ' Get the previous app version.'
3
3
inputs :
4
- CURRENT_VERSION :
5
- description : The current app version
6
- required : true
7
4
SEMVER_LEVEL :
8
5
description : Semantic Versioning Level
9
6
required : true
Original file line number Diff line number Diff line change
1
+ const { readFileSync} = require ( 'fs' ) ;
1
2
const core = require ( '@actions/core' ) ;
2
3
const _ = require ( 'underscore' ) ;
3
- const semverValid = require ( 'semver/functions/valid' ) ;
4
4
const versionUpdater = require ( '../../../libs/versionUpdater' ) ;
5
5
6
- const currentVersion = core . getInput ( 'CURRENT_VERSION' , { require : true } ) ;
7
- if ( ! semverValid ( currentVersion ) ) {
8
- core . setFailed ( `Error: CURRENT_VERSION ${ currentVersion } is not a valid semver version` ) ;
9
- }
10
-
11
6
let semverLevel = core . getInput ( 'SEMVER_LEVEL' , { require : true } ) ;
12
7
if ( ! semverLevel || ! _ . contains ( versionUpdater . SEMANTIC_VERSION_LEVELS , semverLevel ) ) {
13
8
semverLevel = versionUpdater . SEMANTIC_VERSION_LEVELS . PATCH ;
14
9
console . warn ( `Invalid input for 'SEMVER_LEVEL': ${ semverLevel } ` , `Defaulting to: ${ semverLevel } ` ) ;
15
10
}
16
11
12
+ const { version : currentVersion } = JSON . parse ( readFileSync ( './package.json' ) ) ;
17
13
const previousVersion = versionUpdater . getPreviousVersion ( currentVersion , semverLevel ) ;
18
14
core . setOutput ( 'PREVIOUS_VERSION' , previousVersion ) ;
You can’t perform that action at this time.
0 commit comments