From f7d4366dff54c10c20fe8eebcef280d5661d9f60 Mon Sep 17 00:00:00 2001 From: Ethan Davidson <31261035+EthanThatOneKid@users.noreply.github.com> Date: Sat, 7 Oct 2023 10:20:02 -0700 Subject: [PATCH] add `dnt.yaml` workflow Resolves #35. - https://github.com/EthanThatOneKid/pomo/blob/main/.github/workflows/publish.yaml - https://github.com/acmcsufoss/shorter/assets/31261035/27020a60-fddd-42fe-a6e0-2b6a260d2020 (docs: https://docs.deno.com/runtime/manual/tools/task_runner#executing-a-task) --- .github/workflows/dnt.yaml | 39 ++++++++++++++++++++++++++ .gitignore | 1 + deno.jsonc | 5 ++-- {cf => tasks/cf}/dailies/dailies.ts | 0 {cf => tasks/cf}/dailies/env.ts | 0 {cf => tasks/cf}/dailies/push/main.ts | 0 {cf => tasks/cf}/dailies/serve/main.ts | 0 tasks/dnt/main.ts | 34 ++++++++++++++++++++++ 8 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/dnt.yaml rename {cf => tasks/cf}/dailies/dailies.ts (100%) rename {cf => tasks/cf}/dailies/env.ts (100%) rename {cf => tasks/cf}/dailies/push/main.ts (100%) rename {cf => tasks/cf}/dailies/serve/main.ts (100%) create mode 100644 tasks/dnt/main.ts diff --git a/.github/workflows/dnt.yaml b/.github/workflows/dnt.yaml new file mode 100644 index 0000000..f4ae66d --- /dev/null +++ b/.github/workflows/dnt.yaml @@ -0,0 +1,39 @@ +name: dnt + +on: + push: + branches: [main] + +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");