Skip to content

Commit

Permalink
feat: version 1.1.1!
Browse files Browse the repository at this point in the history
  • Loading branch information
santi100a committed Mar 15, 2023
1 parent 97ef2af commit b8355b6
Show file tree
Hide file tree
Showing 22 changed files with 747 additions and 107 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: npm # See documentation for possible values
directory: / # Location of package manifests
schedule:
interval: weekly
43 changes: 0 additions & 43 deletions .github/workflows/main.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Pull Request check

on:
pull_request:
types:
- edited
- opened
branches:
- main
paths:
- src/**/*.*
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Clone the main repo
run: /usr/bin/git clone https://github.com/${{ github.repository }} main
- name: Check if the PR is acceptable
run: |
diff -q ./tests/ ./main/tests > /dev/null
diff -q ./.github/ ./main/.github > /dev/null
- name: Copy test suites from main repo to PR
run: cp main/tests/*.* tests/
- name: Install dependencies
run: yarn
- name: Run main test suites
run: yarn test
38 changes: 38 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Continuous Deployment (CD)

on:
workflow_call:
secrets:
NPM_AUTH_TOKEN:
required: true
GPR_AUTH_TOKEN:
required: true
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 19.x
always-auth: true
- name: Install dependencies
run: yarn
- name: Build code
run: yarn build
- name: Set access tokens
run: |
npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_AUTH_TOKEN }}
npm set //npm.pkg.github.com/:_authToken ${{ secrets.GPR_AUTH_TOKEN }}
- name: Publish to NPM
run: yarn publish --access public
- name: Get ready to publish to GPR
run: |
jq ".name = \"@$REPO\"" package.json > temp.json
mv temp.json package.json
env:
REPO: ${{ github.repository }}
- name: Publish to GPR
run: yarn publish --access public --registry https://npm.pkg.github.com/
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release Workflow

on:
workflow_call:
secrets:
GH_TOKEN:
required: true
NPM_AUTH_TOKEN:
required: true
GPR_AUTH_TOKEN:
required: true

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Generate tag, release name, and body
run: |
TAG_NAME="v$(jq -r '.version' package.json)"
RELEASE_NAME="Release $TAG_NAME"
BODY=$(sed -n "/## Version $(jq -r '.version' package.json | sed 's/\./\\\./g')/,/##/p" CHANGELOG.md | sed '1d;/^##/d')
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
echo "$BODY" >> release.md
- name: Create release
uses: ncipollo/[email protected]
with:
allowUpdates: true
tag: ${{ env.TAG_NAME }}
name: ${{ env.RELEASE_NAME }}
token: ${{ secrets.GH_TOKEN }}
bodyFile: release.md
draft: false
prerelease: false
call-publisher-workflow:
needs: release
uses: ./.github/workflows/publish.yml
secrets:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
GPR_AUTH_TOKEN: ${{ secrets.GPR_AUTH_TOKEN }}
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Continuous Integration (CI)

on:
push:
branches:
- main
paths:
- src/**/*.ts
- tests/**/*.test.js
- .github/workflows/test.yml
- .github/workflows/release.yml
- .github/workflows/publish.yml


jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 19.x
always-auth: true

- name: Install dependencies
run: yarn

- name: Build source code
run: yarn build

- name: Run test suites
run: yarn test
release:
needs: test
uses: ./.github/workflows/release.yml
secrets:
GH_TOKEN: ${{ secrets.GPR_AUTH_TOKEN }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
GPR_AUTH_TOKEN: ${{ secrets.GPR_AUTH_TOKEN }}
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"bracketSameLine": true,
"semi": true,
"singleQuote": true,
"useTabs": true
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Changelog

## Version 1.1.1
- Added `randomIntegers` and `randomFloats`.
60 changes: 60 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Code of Conduct

## My Pledge

In the interest of fostering an open and welcoming environment, as
the maintainer, I pledge to make participation in my project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, level of experience, education,
socio-economic status, nationality, personal appearance, race,
or religion.

## My Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized or foul language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## My Responsibilities

I'm responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

I have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by me.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting me at <[email protected]>. All complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. I will maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Contribute

## How to contribute

You can [file an issue](https://github.com/santi100a/random-lib/issues)
or a [pull request](https://github.com/santi100a/random-lib/pulls).
You can also [start a discussion](https://github.com/santi100a/random-lib/discussions).
## Types of accepted contributions and how to ask for them
- Bug reports (issue/PR if you know how to fix it)
- Feature requests (issue)
- Code contributions (PR)
- Documentation improvements (PR)

**Please submit each PR independently, as I might want to merge some but not others.**

## Contribution rules
You must comply with the [Code of Conduct](CODE_OF_CONDUCT.md) when doing contributions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Santi's Random Number Library
[![Build Status](https://github.com/santi100a/random-lib/actions/workflows/main.yml/badge.svg)](https://github.com/santi100a/random-lib/actions)
[![GitHub stars](https://img.shields.io/github/stars/santi100a/random-lib.svg)](https://github.com/santi100a/santitools-python)
[![License](https://img.shields.io/github/license/santi100a/random-lib.svg)](https://github.com/santi100a/santitools-python)
[![Build Status](https://github.com/santi100a/random-lib/actions/workflows/test.yml/badge.svg)](https://github.com/santi100a/random-lib/actions)
[![npm homepage](https://img.shields.io/npm/v/@santi100/random-lib)](https://npmjs.org/package/@santi100/random-lib)
[![GitHub stars](https://img.shields.io/github/stars/santi100a/random-lib.svg)](https://github.com/santi100a/random-lib)
[![License](https://img.shields.io/github/license/santi100a/random-lib.svg)](https://github.com/santi100a/random-lib)
[![Bundlephobia stats](https://img.shields.io/bundlephobia/min/@santi100/random-lib)](https://bundlephobia.com/package/@santi100/random-lib@latest)

**WARNING: This library doesn't generate cryptographically safe random numbers, due to its reliability on `Math.random()`. This library is designed to be portable across the browser and Node.js, to the expense of security.**

Expand All @@ -11,4 +13,14 @@ There's no warranty, and be aware there might be bugs in my code. Pull requests
### `random(max: number, min: number = 0)`
Generate a random integer between `min` (0 by default) and `max`.
### `randomFloat(max: number, min: number = 0)`
Generate a random floating-point number between `min` (0 by default) and `max`.
Generate a random floating-point number between `min` (0 by default) and `max`.
### `randomFromArray<T = unknown>(array: T[]): T;`
Returns a random item of `array`.
### `function randomIntegers(amount?: number, opts?: RandomArraysOptions): number[];`
Returns an array with `amount` random integers.
### `function randomFloats(amount?: number, opts?: RandomArraysOptions): number[];`
Returns an array with `amount` random floating-point numbers.
## Usage
```typescript
import { random } from '@santi100/random-lib'; // ESM
const { random } = require('@santi100/random-lib'); // CJS
26 changes: 26 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Security Policy

## Reporting a Vulnerability

**First see the [Code of Conduct](CODE_OF_CONDUCT.md) and [Contribution instructions](CONTRIBUTE.md)!**

If you believe you have discovered a security vulnerability in this project, please email me at <[email protected]>. Please include a detailed description of the vulnerability and steps to reproduce it, along with any relevant information on the environment and configuration where the vulnerability was discovered. Please do not disclose the vulnerability publicly until it has been addressed by me.

## Scope
This security policy applies to all versions of the project, including any pre-release or beta versions. I will make reasonable efforts to address vulnerabilities in a timely manner, but I can make no guarantees whatsoever regarding the timeline or process for addressing vulnerabilities.

## Responsible Disclosure
I am committed to addressing security vulnerabilities in a responsible manner, and will follow the principles of responsible disclosure:

- I will acknowledge receipt of your vulnerability report as soon as possible.
- I will provide an estimated timeline for addressing the vulnerability and keep you informed of any changes to the timeline.
- I will provide credit to you in the release notes for any vulnerability that you report, unless you prefer to remain anonymous.
- I will not take legal action against you or disclose your identity to any third party without your consent, unless required by law.
## Vulnerability Severity
I will evaluate the severity of reported vulnerabilities. The severity of the vulnerability will determine the priority for addressing it.

## Patching
I will try my best to provide patches for all vulnerabilities that are confirmed and accepted. I will make reasonable efforts to provide patches in a timely manner, and will prioritize high-severity vulnerabilities. I may provide workarounds or mitigation advice in cases where a patch is not immediately available.

## Public Disclosure
I will coordinate with you to determine an appropriate timeline for public disclosure of the vulnerability, taking into account the severity of the vulnerability, the availability of patches, and any other relevant factors. I will make a best effort to release a patch for the vulnerability before publicly disclosing it, and will coordinate with other affected parties if necessary.
Loading

0 comments on commit b8355b6

Please sign in to comment.