diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..cb8a256 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +name: Release +on: + push: + branches: + - main + - master + +jobs: + release: + name: Release + runs-on: ubuntu-latest + permissions: + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + id-token: write # to enable use of OIDC for npm provenance + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "lts/*" + cache: 'npm' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm ci + + - name: Verify the integrity of provenance attestations and registry signatures + run: npm audit signatures + + - name: Validate NPM_TOKEN + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + if [ -z "$NPM_TOKEN" ]; then + echo "NPM_TOKEN is not set" + exit 1 + fi + + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npx semantic-release diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..150aeeb --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,31 @@ +name: Tests + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm run test:single + + - name: Upload coverage + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1c45971 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.idea +node_modules +.DS_Store +npm-debug.log +npm-debug.log.* +yarn-debug.log +yarn-debug.log.* +yarn-error.log~ +coverage \ No newline at end of file diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..41d6205 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +registry=https://registry.npmjs.org/ +provenance=true \ No newline at end of file diff --git a/.releaserc.json: b/.releaserc.json: new file mode 100644 index 0000000..ae15ad0 --- /dev/null +++ b/.releaserc.json: @@ -0,0 +1,17 @@ +{ + "branches": ["main", "master"], + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + [ + "@semantic-release/git", + { + "assets": ["package.json", "CHANGELOG.md"], + "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + } + ] + ] +} \ No newline at end of file diff --git a/License.md b/LICENSE.md similarity index 100% rename from License.md rename to LICENSE.md diff --git a/Readme.md b/README.md similarity index 79% rename from Readme.md rename to README.md index a137ae8..1b5ba98 100644 --- a/Readme.md +++ b/README.md @@ -9,6 +9,8 @@ HTML5 like input number, but better ## Installation +### Simple + Include jQuery and `jquery.inputNumber.js` onto your page: ```html @@ -34,6 +36,20 @@ $('input.num').inputNumber({ }); ``` +### Npm + +```bash +npm install jquery-inputnumber +``` + +```javascript + +import InputNumber from 'jquery-inputnumber'; +import 'jquery-inputnumber/inputNumber.css'; + +$('input.num').inputNumber(); +``` + --- ## License diff --git a/component.json b/component.json deleted file mode 100644 index 06e3e3e..0000000 --- a/component.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "jquery.inputNumber", - "version": "0.1.0", - "main": ["./jquery.inputNumber.js"], - "dependencies": { - "jquery": ">=1.7" - } -} \ No newline at end of file diff --git a/index.html b/index.html index 07e2e44..8772918 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@