From d6590f86f4f11a241fbf1d755fcc8f585b6cad2e Mon Sep 17 00:00:00 2001 From: Jacob M-G Evans Date: Tue, 8 Aug 2023 13:03:11 -0500 Subject: [PATCH] Automate Action Release Utilizing build & tag action to automate the deps and build steps for releasing the Action. Additionally using NCC for the build process to easy compile the deps into a small executable with the JS file. --- .github/workflows/deploy.yml | 7 ++----- .github/workflows/publish.yml | 27 +++++++++++++++++++++++++++ .gitignore | 3 ++- node_modules/.package-lock.json | 11 ++++++++++- package-lock.json | 14 ++++++++++++-- package.json | 8 +++++--- test/base/public/index.html | 4 ---- test/base/wrangler.toml | 7 ------- test/environment/public/index.html | 4 ---- test/environment/wrangler.toml | 3 --- 10 files changed, 58 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/publish.yml delete mode 100644 test/base/public/index.html delete mode 100644 test/environment/public/index.html diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6229afc..c3c8aec 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -20,8 +20,8 @@ jobs: node-version: "latest" cache: "npm" - - name: Install Dependencies - run: npm install + - name: Install modules and build + run: npm ci && npm run build - name: Unit Tests run: npm run test @@ -29,9 +29,6 @@ jobs: - name: Check Formatting run: npm run check - - name: Build Action - run: npm run build - - name: Only build app uses: ./ with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..a8c166f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,27 @@ +name: Publish + +on: + release: + types: [published, edited] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.event.release.tag_name }} + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "latest" + cache: "npm" + + - name: Install modules and build + run: npm ci && npm run build + + - uses: JasonEtco/build-and-tag-action@v2 + env: + GITHUB_TOKEN: ${{ github.token }} diff --git a/.gitignore b/.gitignore index eb87472..ffae4be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +dist .idea .vscode @@ -31,7 +32,7 @@ Temporary Items .apdisk ### Node ### - +node_modules # Logs logs *.log diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index b823237..252f324 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -1,6 +1,6 @@ { "name": "wrangler-action", - "version": "4.0.0", + "version": "3.0.0", "lockfileVersion": 3, "requires": true, "packages": { @@ -521,6 +521,15 @@ "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", "dev": true }, + "node_modules/@vercel/ncc": { + "version": "0.36.1", + "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.36.1.tgz", + "integrity": "sha512-S4cL7Taa9yb5qbv+6wLgiKVZ03Qfkc4jGRuiUQMQ8HGBD5pcNRnHeYM33zBvJE4/zJGjJJ8GScB+WmTsn9mORw==", + "dev": true, + "bin": { + "ncc": "dist/ncc/cli.js" + } + }, "node_modules/@vitest/expect": { "version": "0.33.0", "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.33.0.tgz", diff --git a/package-lock.json b/package-lock.json index 3a9509a..6769b05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wrangler-action", - "version": "4.0.0", + "version": "3.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "wrangler-action", - "version": "4.0.0", + "version": "3.0.0", "license": "MIT OR Apache-2.0", "dependencies": { "@actions/core": "^1.10.0" @@ -15,6 +15,7 @@ "@changesets/cli": "^2.26.2", "@cloudflare/workers-types": "^4.20230710.1", "@types/node": "^20.4.2", + "@vercel/ncc": "^0.36.1", "prettier": "^3.0.0", "typescript": "^5.1.6", "vitest": "^0.33.0" @@ -873,6 +874,15 @@ "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", "dev": true }, + "node_modules/@vercel/ncc": { + "version": "0.36.1", + "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.36.1.tgz", + "integrity": "sha512-S4cL7Taa9yb5qbv+6wLgiKVZ03Qfkc4jGRuiUQMQ8HGBD5pcNRnHeYM33zBvJE4/zJGjJJ8GScB+WmTsn9mORw==", + "dev": true, + "bin": { + "ncc": "dist/ncc/cli.js" + } + }, "node_modules/@vitest/expect": { "version": "0.33.0", "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.33.0.tgz", diff --git a/package.json b/package.json index d09a5d0..3e7925c 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "type": "module", "main": "dist/index.js", "scripts": { - "build": "tsc", + "start": "npx ncc run ./src/index.ts", + "build": "npx ncc build ./src/index.ts", "test": "vitest", "format": "prettier --write . --ignore-path ./dist/**", "check": "prettier --check . --ignore-path ./dist/**" @@ -32,11 +33,12 @@ "@actions/core": "^1.10.0" }, "devDependencies": { + "@changesets/cli": "^2.26.2", "@cloudflare/workers-types": "^4.20230710.1", "@types/node": "^20.4.2", + "@vercel/ncc": "^0.36.1", "prettier": "^3.0.0", "typescript": "^5.1.6", - "vitest": "^0.33.0", - "@changesets/cli": "^2.26.2" + "vitest": "^0.33.0" } } diff --git a/test/base/public/index.html b/test/base/public/index.html deleted file mode 100644 index 9666e1d..0000000 --- a/test/base/public/index.html +++ /dev/null @@ -1,4 +0,0 @@ -

My Static Site Test

-

To Test Secrets go to /secret

-Secrets - diff --git a/test/base/wrangler.toml b/test/base/wrangler.toml index 1c539fa..4c09785 100644 --- a/test/base/wrangler.toml +++ b/test/base/wrangler.toml @@ -2,10 +2,3 @@ name = "wrangler-action-test" main = "./index.ts" compatibility_date = "2023-07-07" workers_dev = true - -[site] -bucket = "./public" - -# [vars] -# SECRET1 = "value1" -# SECRET2 = "value2" \ No newline at end of file diff --git a/test/environment/public/index.html b/test/environment/public/index.html deleted file mode 100644 index 9666e1d..0000000 --- a/test/environment/public/index.html +++ /dev/null @@ -1,4 +0,0 @@ -

My Static Site Test

-

To Test Secrets go to /secret

-Secrets - diff --git a/test/environment/wrangler.toml b/test/environment/wrangler.toml index 5d41684..015418c 100644 --- a/test/environment/wrangler.toml +++ b/test/environment/wrangler.toml @@ -3,9 +3,6 @@ main = "./index.ts" compatibility_date = "2023-07-07" workers_dev = true -[site] -bucket = "./public" - [env.dev] name = "wrangler-action-dev-environment-test" [env.dev.vars]