diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..ee5a98a --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,44 @@ +name: Tag, Release, & Publish + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + + - name: tag + id: autotagger + uses: butlerlogic/action-autotag@stable + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: release + id: create_release + if: steps.autotagger.outputs.tagcreated == 'yes' + uses: actions/create-release@v1.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.autotagger.outputs.tagname }} + release_name: ${{ steps.autotagger.outputs.tagname }} + + - name: setup node + id: setup_node + if: steps.autotagger.outputs.tagname != '' + uses: actions/setup-node@v2 + with: + node-version: 14 + registry-url: https://registry.npmjs.org/ + + - name: publish + id: publish + if: steps.autotagger.outputs.tagname != '' + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 55bfb56..5de8534 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@voken/avatar", - "version": "1.1.0", + "version": "1.3.1", "description": "Create a `.svg` avatar from `seed`", "keywords": [ "avatar", @@ -22,7 +22,7 @@ "main": "src/index.js", "dependencies": { "@dicebear/avatars": "^4.5.2", - "@dicebear/avatars-gridy-sprites": "^4.5.2" + "@dicebear/avatars-jdenticon-sprites": "^4.5.2" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/src/index.js b/src/index.js index dedd8ca..40011d6 100644 --- a/src/index.js +++ b/src/index.js @@ -1,23 +1,30 @@ +const crypto = require('crypto') const Avatars = require('@dicebear/avatars').default -const sprites = require('@dicebear/avatars-gridy-sprites').default +// const sprites = require('@dicebear/avatars-gridy-sprites').default +const sprites = require('@dicebear/avatars-jdenticon-sprites').default const svgFromSeed = function (seed) { - const options = { - colorful: true, - deterministic: true - } - const avatars = new Avatars(sprites, options) - return avatars.create(seed) + // const options = { + // colorful: true, + // deterministic: true + // } + // const avatars = new Avatars(sprites, options) + const avatars = new Avatars(sprites) + return avatars.create(_sha256(seed)) } const svgDataUriFromSeed = function (seed) { const options = { dataUri: true, - colorful: true, - deterministic: true + // colorful: true, + // deterministic: true } const avatars = new Avatars(sprites, options) - return avatars.create(seed) + return avatars.create(_sha256(seed)) +} + +const _sha256 = function (value) { + return crypto.createHash('sha256').update(value).digest().toString('hex') } module.exports = {