From f2b3e200979924adae30f88f54b831bad6b3934f Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Thu, 5 Nov 2020 21:38:34 +1100 Subject: [PATCH] ci: generate npm package (#31) * working on automated pre-release builds * checking condition is valid * pushing to github packages * playing with scopes * moving to separate job * forgot to download the artifact * don't need to install when the package already exists --- .github/workflows/node.js.yml | 40 +++++++++++++++++++++++++++++++++++ .gitignore | 3 ++- .npmignore | 9 +++++++- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 6748844a..b9226778 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -25,3 +25,43 @@ jobs: node-version: ${{ matrix.node-version }} - run: npm ci - run: npm test + + package: + needs: [test] + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: Use Node.js 14.x + uses: actions/setup-node@v1 + with: + node-version: 14.x + + - run: npm ci + - run: npm run build + - run: npm version prerelease --preid=ci-$GITHUB_RUN_ID --no-git-tag-version + - run: npm pack + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: package + path: "*.tgz" + + publish: + name: "Publish to GitHub Packages" + needs: [package] + runs-on: ubuntu-18.04 + if: github.repository_owner == 'manekinekko' # && github.token != '' + steps: + - name: Upload + uses: actions/download-artifact@v2 + with: + name: package + - uses: actions/setup-node@v1 + with: + node-version: ${{ env.NODE_VERSION }} + registry-url: https://npm.pkg.github.com/ + scope: "@manekinekko" + - run: echo "registry=https://npm.pkg.github.com/@manekinekko" >> .npmrc + - run: npm publish $(ls *.tgz) + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 22e8db74..6e7eede6 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,5 @@ __pycache__/ *.py[cod] *$py.class -dist \ No newline at end of file +dist +*.tgz diff --git a/.npmignore b/.npmignore index 1927772b..c05ed8f8 100644 --- a/.npmignore +++ b/.npmignore @@ -1 +1,8 @@ -local.settings.json \ No newline at end of file +local.settings.json +.vscode +.github +.release-it.json +.editorconfig +.tsconfig +.nvmrc +.prettierrc