From 41a9c00070e30bc07aed53c950d11583e6b4883d Mon Sep 17 00:00:00 2001 From: ITOH Date: Fri, 4 Feb 2022 18:17:31 +0100 Subject: [PATCH] ci(npm): publish to npm on tag creation (#1997) * Create npm.yml * fix invalid on * Update dnt.ts * Update npm.yml --- .github/workflows/npm.yml | 33 +++++++++++++++++++++++++++++++++ dnt.ts | 3 +-- 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/npm.yml diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml new file mode 100644 index 000000000..bf043baf8 --- /dev/null +++ b/.github/workflows/npm.yml @@ -0,0 +1,33 @@ +name: NPM Publish + +on: + create: + tags: + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + deno: ["v1.x"] + steps: + - uses: actions/checkout@v2 + - uses: denoland/setup-deno@main + with: + deno-version: ${{ matrix.deno }} + # Taken from: https://github.com/denoland/dnt#github-actions---npm-publish-on-tag + - name: Get tag version + if: startsWith(github.ref, 'refs/tags/') + id: get_tag_version + run: echo ::set-output name=TAG_VERSION::${GITHUB_REF/refs\/tags\//} + - uses: actions/setup-node@v2 + with: + node-version: '16.x' + registry-url: 'https://registry.npmjs.org' + - name: npm build + run: deno run -A ./dnt.ts ${{steps.get_tag_version.outputs.TAG_VERSION}} + - name: npm publish + if: startsWith(github.ref, 'refs/tags/') + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: cd npm && npm publish diff --git a/dnt.ts b/dnt.ts index 1b0924033..3a5e64d9d 100644 --- a/dnt.ts +++ b/dnt.ts @@ -1,5 +1,4 @@ import { build } from "https://deno.land/x/dnt@0.7.3/mod.ts"; -import { DISCORDENO_VERSION } from "./mod.ts"; await Deno.remove("npm", { recursive: true }).catch((_) => {}); @@ -11,7 +10,7 @@ await build({ test: false, package: { name: "discordeno", - version: DISCORDENO_VERSION, + version: Deno.args[0], }, compilerOptions: { target: "ES2020" }, });