From 58a5191502a946e9d5712f1a6ba56eb72608fbd2 Mon Sep 17 00:00:00 2001 From: CJ Hare Date: Wed, 31 Aug 2022 11:43:03 +1000 Subject: [PATCH] feat: npm publishing on release publish (#159) --- .github/workflows/npm-publish.yml | 53 ++++++++++++++ .npmignore | 113 ++++++++++++++++++++++++++++++ package.json | 16 +++-- 3 files changed, 177 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/npm-publish.yml create mode 100644 .npmignore diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..5f60497 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,53 @@ +name: NPM publish CD workflow + +on: + release: + types: [published] + +jobs: + NPM-Publish: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + with: + ref: ${{ github.event.release.target_commitish }} + + - uses: actions/cache@v3 + name: Set up cache + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Set up node + uses: actions/setup-node@v3 + with: + node-version: '16' + registry-url: https://registry.npmjs.org/ + + - name: Install dependencies + run: npm ci + + - name: Set publisher name + run: git config --global user.name "GitHub publish bot" + + - name: Set publisher email + run: git config --global user.email "github-publish-bot@email.com" + + - name: Bump the application version (package.json) + run: npm version ${{ github.event.release.tag_name }} + + - name: Build application + run: npm run build + + - name: Publish to NPM + run: npm publish --access=public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Push version update (package.json) + run: git push + env: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..d459ee0 --- /dev/null +++ b/.npmignore @@ -0,0 +1,113 @@ +# Project config files +hardhat.config.ts +package-lock.json +renovate.json +slither.json +tsconfig.json +.eslintrc +.github/ +.husky/ +.lintstagedrc +.prettierignore +.prettierrc +.solhint.json +.solhintignore + +# Test contracts and files +test/ +contracts/test + +# Hardhat +artifacts +cache + +# TypeChain +typechain-types + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# next.js build output +.next + +# JS file output directory +dist/ + +# IDE +.vscode + +# Generated TS docs +doc/ + +# Eclipse project files +.project +.settings + +# Jetbrains IDE +.idea + +# Docker created bash file +.bash_history + +# MacOS system files +.DS_Store + +# OZ Cache (UUPS proxy deployment addresses) +.openzeppelin + +# Yarn lock file (npm.lock covers this) +yarn.lock +yarn-error.log diff --git a/package.json b/package.json index 110ccfb..9ba69aa 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,24 @@ { - "name": "solidity-project-template", + "name": "@windranger-io/solidity-project-template", "version": "0.0.3", "description": "Everything you need for creating Solidity smart contract with TypeScript testing", - "private": true, + "license": "Apache-2.0", + "private": false, "directories": { "test": "test" }, + "publishConfig": { + "tag": "latest" + }, "repository": { "type": "git", "url": "git+https://github.com/windranger-io/solidity-project-template" }, - "keywords": [], - "author": "", - "license": "Apache-2.0", + "keywords": [ + "solidity", + "ethereum", + "developer-tools" + ], "scripts": { "build": "hardhat compile", "clean": "hardhat clean",