diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..3f743b2 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,71 @@ +name: Publish to NPM +on: + # When Release Pull Request is merged + push: + branches: + - master + +env: + CI: true +jobs: + publish: + name: Publish + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: "0" + - name: Use Node.js (.nvmrc) + uses: actions/setup-node@v3 + with: + cache: npm + node-version: 18 + - name: Set Current Version + id: set_current_version + if: startsWith(github.event.pull_request.title, 'v') + shell: bash -ex {0} + run: | + CURRENT_VERSION=$(node -p 'require("./package.json").version') + echo "::set-output name=CURRENT_VERSION::${CURRENT_VERSION}" + - name: Create Git Tag + uses: azu/action-package-version-to-git-tag@v1 + with: + version: ${{ steps.set_current_version.outputs.CURRENT_VERSION }} + github_token: ${{ secrets.GITHUB_TOKEN }} + github_repo: ${{ github.repository }} + git_commit_sha: ${{ github.sha }} + git_tag_prefix: "v" + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ steps.set_current_version.outputs.CURRENT_VERSION }} + release_name: ${{ github.event.pull_request.title }} + body: | + ${{ github.event.pull_request.body }} + draft: false + prerelease: false + - name: Authenticate with Registry + run: | + yarn logout + echo "init-author-name=Frontegg LTD" > .npmrc + echo "init-author-email=hello@frontegg.com" >> .npmrc + echo "init-author-url=https://frontegg.com" >> .npmrc + echo "init-license=MIT" >> .npmrc + echo "always-auth=true" >> .npmrc + echo "registry=https://registry.npmjs.org" >> .npmrc + echo "_authToken=$NPM_TOKEN" >> .npmrc + echo "@frontegg:registry=https://registry.npmjs.org" >> .npmrc + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc + npm whoami + env: + NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + - name: Publish + run: | + npm publish --tag latest + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..5ba1e70 --- /dev/null +++ b/.npmignore @@ -0,0 +1,9 @@ +.github +.nyc_output +coverage +node_modules +test +.eslintrc.yml +.gitignore +.prettierrc.yaml +package-lock.json \ No newline at end of file diff --git a/lib/Client.js b/lib/Client.js index 1cf53b5..8979f03 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -81,8 +81,6 @@ module.exports = prototypal({ options.body = JSON.stringify(options.body); } - const t = ''; - return this.getter.got(uri, options).then(res => res.body); }, });