Skip to content

Commit 1f90ef3

Browse files
committed
Move version extraction to JS and set debug var
1 parent 65e658c commit 1f90ef3

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

.github/workflows/standalone_publish_custom.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ on:
4343
type: boolean
4444
description: 'Create a patch release'
4545
default: false
46-
onlyUnpublished:
46+
only-unpublished:
4747
type: boolean
4848
description: 'Only publish packages that have not yet been published'
4949
default: false
@@ -103,5 +103,6 @@ jobs:
103103
- name: 'Publish packages'
104104
env:
105105
GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
106+
DEBUG: ${{ env.ACTIONS_STEP_DEBUG && 'scripts:publish-packages' || '' }}
106107
run: |
107-
node lib/node_modules/@stdlib/_tools/scripts/publish_packages.js ${{ github.event.inputs.packages }} ${{ github.event.inputs.patch == 'true' && '--patch ' || '' }}${{ github.event.inputs.dry-run == 'true' && '--skip-upload ' || '' }}${{ github.event.inputs.skip == 'skip-individual' && '--skip-individual ' || '' }}${{ github.event.inputs.skip == 'skip-toplevel' && '--skip-toplevel ' || '' }}${{ github.event.inputs.onlyUnpublished == 'true' && '--only-unpublished ' || '' }}${{ github.event.inputs.pattern && format('--pattern {0}', github.event.inputs.pattern ) || '' }}
108+
node lib/node_modules/@stdlib/_tools/scripts/publish_packages.js ${{ github.event.inputs.packages }} ${{ github.event.inputs.patch == 'true' && '--patch ' || '' }}${{ github.event.inputs.dry-run == 'true' && '--skip-upload ' || '' }}${{ github.event.inputs.skip == 'skip-individual' && '--skip-individual ' || '' }}${{ github.event.inputs.skip == 'skip-toplevel' && '--skip-toplevel ' || '' }}${{ github.event.inputs.only-unpublished == 'true' && '--only-unpublished ' || '' }}${{ github.event.inputs.pattern && format('--pattern {0}', github.event.inputs.pattern ) || '' }}

lib/node_modules/@stdlib/_tools/scripts/publish_packages.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
4848
var removeFirst = require( '@stdlib/string/remove-first' );
4949
var reFromString = require( '@stdlib/utils/regexp-from-string' );
5050
var startsWith = require( '@stdlib/string/starts-with' );
51+
var substringAfterLast = require( '@stdlib/string/substring-after-last' );
5152
var currentYear = require( '@stdlib/time/current-year' );
5253
var namespaceDeps = require( '@stdlib/_tools/pkgs/namespace-deps' );
5354
var depList = require( '@stdlib/_tools/pkgs/dep-list' );
@@ -476,16 +477,14 @@ function publish( pkg, clbk ) {
476477
pth = 'https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/'+pkg;
477478

478479
dist = join( mainDir, 'build', '@stdlib', distPkg );
479-
command = 'git ls-remote --tags --sort="v:refname" https://'+ ENV.GITHUB_TOKEN + '@github.com/stdlib-js/'+distPkg+'.git | tail -n1 | sed \'s/.*\\///; s/[-a-z]*\\^{}//\'';
480+
command = 'git ls-remote --tags --sort="v:refname" https://'+ ENV.GITHUB_TOKEN + '@github.com/stdlib-js/'+distPkg+'.git';
480481
debug( 'Executing command to retrieve last version: %s', command );
481482
try {
482483
command = shell( command ).toString();
483-
if ( contains( command, 'not found' ) ) {
484-
repoExists = false;
485-
} else {
486-
repoExists = true;
487-
version = trim( removeFirst( command ) ); // Remove leading `v`...
488-
}
484+
repoExists = true;
485+
version = substringAfterLast( command, '/' );
486+
version = replace( version, /[-a-z.]*\^{}/, '' );
487+
version = trim( removeFirst( version ) ); // Remove leading `v`...
489488
} catch ( error ) {
490489
console.error( 'Encountered an error when attempting to retrieve the last version. Error: %s', error.message );
491490
repoExists = false;

0 commit comments

Comments
 (0)