Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Aug 3, 2023
1 parent 21d8b19 commit b45e24c
Show file tree
Hide file tree
Showing 15 changed files with 208 additions and 60 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/productionize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ on:
type: boolean
default: true

# Run workflow upon completion of `publish` workflow run:
workflow_run:
workflows: ["publish"]
types: [completed]


# Concurrency group to prevent multiple concurrent executions:
concurrency:
group: productionize
Expand Down Expand Up @@ -94,10 +100,11 @@ jobs:
# Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency:
- name: 'Update dependencies in package.json'
run: |
PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version)
if grep -q '"@stdlib/string-format"' package.json; then
sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json
sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json
else
node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );"
node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );"
fi
# Configure git:
Expand Down Expand Up @@ -342,7 +349,7 @@ jobs:
# Send status to Slack channel if job fails:
- name: 'Send status to Slack channel in case of failure'
uses: act10ns/slack@v1
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
Expand Down Expand Up @@ -513,7 +520,7 @@ jobs:
# Send status to Slack channel if job fails:
- name: 'Send status to Slack channel in case of failure'
uses: act10ns/slack@v1
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
Expand Down Expand Up @@ -690,7 +697,7 @@ jobs:
# Send status to Slack channel if job fails:
- name: 'Send status to Slack channel in case of failure'
uses: act10ns/slack@v1
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
Expand Down
139 changes: 132 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,23 @@ name: publish

# Workflow triggers:
on:
# Run workflow when a new tag is pushed to the repository:
push:
tags: v[0-9]+.[0-9]+.[0-9]+
# Allow the workflow to be manually run:
workflow_dispatch:
# Workflow inputs:
inputs:
version:
description: 'Version Increment'
type: choice
default: 'none'
options:
- 'none'
- 'major'
- 'minor'
- 'patch'
- 'premajor'
- 'preminor'
- 'prepatch'
- 'prerelease'

# Workflow jobs:
jobs:
Expand All @@ -32,14 +46,15 @@ jobs:
publish:

# Define display name:
name: 'Publish to npm'
name: 'Publish package to npm'

# Define the type of virtual host machine on which to run the job:
runs-on: ubuntu-latest

# Define environment variables:
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# Define the sequence of job steps...
steps:
Expand All @@ -55,6 +70,91 @@ jobs:
node-version: 16
timeout-minutes: 5

# Configure git:
- name: 'Configure git'
run: |
git config --local user.email "noreply@stdlib.io"
git config --local user.name "stdlib-bot"
# Increment package version (if requested):
- name: 'Increment package version (if requested)'
if: ${{ github.event.inputs.version != 'none' }}
run: |
# Save NPM_TOKEN to user's .npmrc:
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
# Increment package version:
npm version ${{ github.event.inputs.version }} --no-git-tag-version
# Define variable for new version:
NEW_VERSION=$(node -p "require('./package.json').version")
# Replace branch in README.md link definitions for badges with the new version:
find . -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/branch([=:])[^ ]+/branch\1v${NEW_VERSION}/g"
# Create a new commit and tag:
git add package.json README.md
git commit -m "Release v${NEW_VERSION}"
git tag -a "v${NEW_VERSION}" -m "Release v${NEW_VERSION}"
# Push changes to GitHub:
SLUG=${{ github.repository }}
git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" --follow-tags
# Remove CLI:
- name: 'Remove CLI'
if: ${{ github.ref == 'refs/heads/main' }}
run: |
# Exit if the package does not have a CLI:
if ! grep -q '"bin":' package.json; then
exit 0
fi
rm -rf ./bin/cli
rm -f test/test.cli.js
rm -f etc/cli_opts.json
rm -f docs/usage.txt
# For all dependencies, check in all *.js files if they are still used; if not, remove them:
jq -r '.dependencies | keys[]' ./package.json | while read -r dep; do
dep=$(echo "$dep" | xargs)
if ! grep -q "$dep" lib/** && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then
jq --indent 2 "del(.dependencies[\"$dep\"])" ./package.json > ./package.json.tmp
mv ./package.json.tmp ./package.json
fi
done
jq -r '.devDependencies | keys[]' ./package.json | while read -r dep; do
if [[ "$dep" != "@stdlib"* ]]; then
continue
fi
dep=$(echo "$dep" | xargs)
if ! grep -q "$dep" lib/** && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then
jq --indent 2 "del(.devDependencies[\"$dep\"])" ./package.json > ./package.json.tmp
mv ./package.json.tmp ./package.json
fi
done
# Remove CLI section:
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"cli\">[\s\S]+?<\!\-\- \/.cli \-\->//"
# Remove CLI from package.json:
jq -r 'del(.bin)' package.json > package.json.tmp
mv package.json.tmp package.json
# Add entry for CLI package to See Also section of README.md:
cliPkgName=$(jq -r '.name' package.json)-cli
escapedPkg=$(echo "$cliPkgName" | sed -e 's/\//\\\//g')
escapedPkg=$(echo "$escapedPkg" | sed -e 's/\@/\\\@/g')
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"related\">(?:\n\n\* \* \*\n\n## See Also\n\n)?/<section class=\"related\">\n\n## See Also\n\n- <span class=\"package-name\">[\`$escapedPkg\`][$escapedPkg]<\/span><span class=\"delimiter\">: <\/span><span class=\"description\">CLI package for use as a command-line utility.<\/span>\n/"
# Add link definition for CLI package to README.md:
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"links\">/<section class=\"links\">\n\n[$escapedPkg]: https:\/\/www.npmjs.com\/package\/$escapedPkg/"
# Replace GitHub MathJax equations with SVGs:
- name: 'Replace GitHub MathJax equations with SVGs'
run: |
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe 's/```math\n([\s\S]+?)\n```\n\n//g'
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe 's/<!-- <div class="equation"(.*)(<\/div>\s*-->)/<div class="equation"$1<\/div>/sg'
# Replace GitHub links to individual packages with npm links:
- name: 'Replace all GitHub links to individual packages with npm links'
run: |
Expand All @@ -65,14 +165,39 @@ jobs:
run: |
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`\n\nAlternatively,[^<]+<\/section>/\`\`\`\n\n<\/section>/"
# Remove unnecessary files:
- name: 'Remove unnecessary files'
run: |
rm -f docs/repl.txt
rm -f docs/types/test.ts
# Replace all stdlib GitHub dependencies with the respective npm packages:
- name: 'Replace all stdlib GitHub dependencies with the respective npm packages'
run: |
find package.json -type f -print0 | xargs -0 sed -Ei 's/"github:stdlib-js[^"]*"/"^0.0.x"/g'
for dep in $(jq -r '.dependencies | keys | .[]' package.json); do
if [[ "$dep" != "@stdlib"* ]]; then
continue
fi
# Trim leading and trailing whitespace:
dep=$(echo "$dep" | xargs)
version="^$(npm view $dep version)"
jq -r --arg dep "$dep" --arg version "$version" '.dependencies[$dep] = $version' package.json > package.json.tmp
mv package.json.tmp package.json
done
for dep in $(jq -r '.devDependencies | keys | .[]' package.json); do
if [[ "$dep" != "@stdlib"* ]]; then
continue
fi
# Trim leading and trailing whitespace:
dep=$(echo "$dep" | xargs)
version="^$(npm view $dep version)"
jq -r --arg dep "$dep" --arg version "$version" '.devDependencies[$dep] = $version' package.json > package.json.tmp
mv package.json.tmp package.json
done
# Publish package to npm:
- name: 'Publish package to npm'
uses: JS-DevTools/npm-publish@v1
uses: JS-DevTools/npm-publish@v2
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
Expand All @@ -84,7 +209,7 @@ jobs:
# Send status to Slack channel if job fails:
- name: 'Send status to Slack channel in case of failure'
uses: act10ns/slack@v1
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ on:
# Run workflow on each push to the main branch:
push:

# Run workflow upon completion of `publish` workflow run:
workflow_run:
workflows: ["publish"]
types: [completed]

# Workflow jobs:
jobs:

Expand Down Expand Up @@ -84,7 +89,7 @@ jobs:
# Send status to Slack channel if job fails:
- name: 'Send status to Slack channel in case of failure'
uses: act10ns/slack@v1
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test_bundles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
# Send notification to Slack channel if job fails:
- name: 'Send status to Slack channel in case of failure'
uses: act10ns/slack@v1
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
Expand Down Expand Up @@ -130,7 +130,7 @@ jobs:
# Send notification to Slack channel if job fails:
- name: 'Send status to Slack channel in case of failure'
uses: act10ns/slack@v1
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
# Send notification to Slack channel if job fails:
- name: 'Send status to Slack channel in case of failure'
uses: act10ns/slack@v1
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
# Send Slack notification if job fails:
- name: 'Send status to Slack channel in case of failure'
uses: act10ns/slack@v1
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:

# Send Slack notification if job fails:
- name: 'Send notification to Slack in case of failure'
uses: act10ns/slack@v1
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,7 @@ jsconfig.json
################
*.sublime-workspace
*.sublime-project

# Other editor files #
######################
.idea/
19 changes: 14 additions & 5 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,37 @@
# Contributors listed in alphabetical order.

Ali Salesi <ali_sal1381@yahoo.com>
Amit Jimiwal <amitjimiwal45@gmail.com>
Athan Reines <kgryte@gmail.com>
Brendan Graetz <bguiz@users.noreply.github.com>
Bruno Fenzl <brunofenzl@gmail.com>
Christopher Dambamuromo <chridam@gmail.com>
Dan Rose <danoftheroses@gmail.com>
Dominik Moritz <domoritz@gmail.com>
Dorrin Sotoudeh <dorrinsotoudeh123@gmail.com>
Frank Kovacs <fran70kk@gmail.com>
James <jdgelok@gmail.com>
Harshita Kalani <harshitakalani02@gmail.com>
James Gelok <jdgelok@gmail.com>
Jithin KS <jithinks112@gmail.com>
Joey Reed <joeyrreed@gmail.com>
Jordan Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com>
Joris Labie <joris.labie1@gmail.com>
Justin Dennison <justin1dennison@gmail.com>
Marcus <mfantham@users.noreply.github.com>
Marcus Fantham <mfantham@users.noreply.github.com>
Matt Cochrane <matthew.cochrane.eng@gmail.com>
Milan Raj <rajsite@users.noreply.github.com>
Momtchil Momtchev <momtchil@momtchev.com>
Naresh Jagadeesan <naresh.naresh000@gmail.com>
Nithin Katta <88046362+nithinkatta@users.noreply.github.com>
Ognjen Jevremović <ognjenjevremovic@users.noreply.github.com>
Philipp Burckhardt <pburckhardt@outlook.com>
Pranav <85227306+Pranavchiku@users.noreply.github.com>
Pranav Goswami <goswami.4@iitj.ac.in>
Ricky Reusser <rsreusser@gmail.com>
Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com>
Ryan Seal <splrk@users.noreply.github.com>
Seyyed Parsa Neshaei <spneshaei@users.noreply.github.com>
Shraddheya Shendre <shendreshraddheya@gmail.com>
Stephannie Jiménez Gacha <steff456@hotmail.com>
dorrin-sot <59933477+dorrin-sot@users.noreply.github.com>
rei2hu <rei2hu@users.noreply.github.com>
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
orimiles5 <97595296+orimiles5@users.noreply.github.com>
rei2hu <reimu@reimu.ws>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
-->

[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
[chat-url]: https://gitter.im/stdlib-js/stdlib/
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im

[stdlib]: https://github.com/stdlib-js/stdlib

Expand Down
12 changes: 6 additions & 6 deletions branches.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ C -->|bundle| D[esm];
C -->|bundle| E[deno];
C -->|bundle| F[umd];
click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/random/sample"
click B href "https://github.com/stdlib-js/random-sample/tree/main"
click C href "https://github.com/stdlib-js/random-sample/tree/production"
click D href "https://github.com/stdlib-js/random-sample/tree/esm"
click E href "https://github.com/stdlib-js/random-sample/tree/deno"
click F href "https://github.com/stdlib-js/random-sample/tree/umd"
%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/random/sample"
%% click B href "https://github.com/stdlib-js/random-sample/tree/main"
%% click C href "https://github.com/stdlib-js/random-sample/tree/production"
%% click D href "https://github.com/stdlib-js/random-sample/tree/esm"
%% click E href "https://github.com/stdlib-js/random-sample/tree/deno"
%% click F href "https://github.com/stdlib-js/random-sample/tree/umd"
```

[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/random/sample
Expand Down
1 change: 0 additions & 1 deletion lib/renormalizing.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*
* - After each draw, the probabilities of the remaining observations are renormalized so that they sum to one.
*
*
* @private
* @param {ArrayLike} x - array-like object from which to sample
* @param {NonNegativeInteger} size - sample size
Expand Down
Loading

0 comments on commit b45e24c

Please sign in to comment.