diff --git a/.github/workflows/dnt.yaml b/.github/workflows/dnt.yaml new file mode 100644 index 0000000..12e97d6 --- /dev/null +++ b/.github/workflows/dnt.yaml @@ -0,0 +1,40 @@ +name: dnt + +on: + push: + branches: [main] + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: main + + - uses: denoland/setup-deno@v1 + with: + deno-version: canary + + - name: Run build script + run: deno task dnt $GITHUB_SHA + + - name: Checkout new branch for npm/ content + run: | + git checkout -B npm || git checkout npm + git rm -rf . + cp -r npm/* . + rm -rf npm + git config --global user.email "me@example.com" + git config --global user.name "LC-Dailies Bot" + git add . + git commit -m "Publish npm ✨" + + - name: Push new branch to remote + run: | + # Replace with the appropriate remote repository URL + # Example: git push --force origin npm + git push --force -u origin npm diff --git a/.gitignore b/.gitignore index 2c1b756..7513aa7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .env ngrok.exe .denoflare +npm diff --git a/deno.jsonc b/deno.jsonc index 3bcdbdf..e6b6b54 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -7,8 +7,9 @@ "test": "deno test --unstable", "start": "deno run -A --unstable main.ts", "ngrok": "ngrok http 8080", - "cf:push": "deno run -A cf/dailies/push/main.ts", - "cf:serve": "deno run -A cf/dailies/serve/main.ts" + "cf:push": "deno run -A tasks/cf/dailies/push/main.ts", + "cf:serve": "deno run -A tasks/cf/dailies/serve/main.ts", + "dnt": "deno run -A tasks/dnt/main.ts" }, "imports": { "lc-dailies/": "./" diff --git a/cf/dailies/dailies.ts b/tasks/cf/dailies/dailies.ts similarity index 100% rename from cf/dailies/dailies.ts rename to tasks/cf/dailies/dailies.ts diff --git a/cf/dailies/env.ts b/tasks/cf/dailies/env.ts similarity index 100% rename from cf/dailies/env.ts rename to tasks/cf/dailies/env.ts diff --git a/cf/dailies/push/main.ts b/tasks/cf/dailies/push/main.ts similarity index 100% rename from cf/dailies/push/main.ts rename to tasks/cf/dailies/push/main.ts diff --git a/cf/dailies/serve/main.ts b/tasks/cf/dailies/serve/main.ts similarity index 100% rename from cf/dailies/serve/main.ts rename to tasks/cf/dailies/serve/main.ts diff --git a/tasks/dnt/main.ts b/tasks/dnt/main.ts new file mode 100644 index 0000000..b7f9323 --- /dev/null +++ b/tasks/dnt/main.ts @@ -0,0 +1,34 @@ +// Run: +// deno run -A tasks/dnt/main.ts $VERSION + +import { build, emptyDir } from "https://deno.land/x/dnt@0.38.1/mod.ts"; + +await emptyDir("./npm"); + +await build({ + entryPoints: [ + "./api/types.ts", + ], + outDir: "./npm", + test: false, + // see JS docs for overview and more options + shims: { deno: true }, + package: { + // package.json properties + name: "lc-dailies", + version: Deno.args[0], + description: "LC-Dailies utility module.", + license: "MIT", + repository: { + type: "git", + url: "git+https://github.com/acmcsufoss/lc-dailies.git", + }, + bugs: { + url: "https://github.com/acmcsufoss/lc-dailies/issues", + }, + }, +}); + +// post build steps +Deno.copyFileSync("LICENSE", "npm/LICENSE"); +Deno.copyFileSync("README.md", "npm/README.md");