From 5da65b69fad0b58a8fd70dd1bde0fcd571091750 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 16:16:06 +0000 Subject: [PATCH 01/37] test --- .gitignore | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++ bun.lockb | Bin 0 -> 22209 bytes package.json | 26 ++++++++ src/main.ts | 68 ++++++++++++++++++++ tsconfig.json | 22 +++++++ 5 files changed, 291 insertions(+) create mode 100644 .gitignore create mode 100755 bun.lockb create mode 100644 package.json create mode 100644 src/main.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..468f82a --- /dev/null +++ b/.gitignore @@ -0,0 +1,175 @@ +# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore + +# Logs + +logs +_.log +npm-debug.log_ +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Caches + +.cache + +# Diagnostic reports (https://nodejs.org/api/report.html) + +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# Runtime data + +pids +_.pid +_.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover + +lib-cov + +# Coverage directory used by tools like istanbul + +coverage +*.lcov + +# nyc test coverage + +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) + +.grunt + +# Bower dependency directory (https://bower.io/) + +bower_components + +# node-waf configuration + +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) + +build/Release + +# Dependency directories + +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) + +web_modules/ + +# TypeScript cache + +*.tsbuildinfo + +# Optional npm cache directory + +.npm + +# Optional eslint cache + +.eslintcache + +# Optional stylelint cache + +.stylelintcache + +# Microbundle cache + +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history + +.node_repl_history + +# Output of 'npm pack' + +*.tgz + +# Yarn Integrity file + +.yarn-integrity + +# dotenv environment variable files + +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) + +.parcel-cache + +# Next.js build output + +.next +out + +# Nuxt.js build / generate output + +.nuxt +dist + +# Gatsby files + +# Comment in the public line in if your project uses Gatsby and not Next.js + +# https://nextjs.org/blog/next-9-1#public-directory-support + +# public + +# vuepress build output + +.vuepress/dist + +# vuepress v2.x temp and cache directory + +.temp + +# Docusaurus cache and generated files + +.docusaurus + +# Serverless directories + +.serverless/ + +# FuseBox cache + +.fusebox/ + +# DynamoDB Local files + +.dynamodb/ + +# TernJS port file + +.tern-port + +# Stores VSCode versions used for testing VSCode extensions + +.vscode-test + +# yarn v2 + +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..1fb36beb4d5750ae49aaf8059ff7ae1eab5e087d GIT binary patch literal 22209 zcmeHPd0dQN+n;JE`5}}&B1>eZMXNPJ(n7SLg_@?C)J)Axt4avjl0ud&kt}5?m93I3 zkzY~vC|eRC9&5sTUH8nX@q1Fk^ZfCC-q-nj?#_Ld@Aq8iI{TTfTfM(lfPk;%#^GwQ zxq)hK0bE6R7(P7Kd=HKfo8iIZ`??Alf!d0)G#V`$6hNp5L%l z!*RvqS9c9PI@@z9bnGD$xRD}{rtl9xQXDQd7QfI0Y+-;O1O#l~KsKL7I|1+QXtc-> zS05jaKuBW;vstbXmmx!=b%pr7;I{{#$7KsSzHFK=$CtxmcyPBu{9h37=PLAK%x8zJ z6^ECBPw|1@0de3fg6|GK@&tKtSYE)-5kN`c`_gH&P7rU>MwFlMIYOE$#2d7w(K>=3 z34S;5)x7eb>k7dB z4kJ_NuIVh3aM*dGdi#XL=YbBos%yfmFP92Vf4ebbbh{#jn!!`8FJHN7J$dhowGZ|7 zY}{VkMs41BjW-pq1>Nh8O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o~`YX f9`e%#lhxvxon!+h@(OD`Zux*mbS?3}@9+Nrj3@B? literal 0 HcmV?d00001 diff --git a/package.json b/package.json new file mode 100644 index 0000000..7d2a762 --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "type": "module", + "devDependencies": { + "@types/bun": "latest", + "@types/semver": "^7.5.6" + }, + "peerDependencies": { + "typescript": "^5.0.0", + "prettier": "^3.2.4", + "@types/node": "^20.11.7" + }, + "packageManager": "bun@1.0.25", + "dependencies": { + "@actions/core": "^1.10.1", + "@actions/github": "^6.0.0", + "@actions/tool-cache": "^2.0.1", + "@octokit/auth-unauthenticated": "^5.0.1", + "execa": "^8.0.1", + "semver": "^7.5.4" + }, + "scripts": { + "build": "bun build ./src/main.ts --outdir=dist --target=node", + "format": "prettier -w .", + "lint": "tsc --noEmit" + } +} diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..b28ab4c --- /dev/null +++ b/src/main.ts @@ -0,0 +1,68 @@ +#!/usr/bin/env node +import { $ } from "execa" +import * as core from "@actions/core" +import * as tc from "@actions/tool-cache" +import * as github from "@actions/github" +import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated" +import * as semver from "semver" +import { join } from "node:path" +import { mkdir, rm } from "node:fs/promises" + +// Make sure it's still 'dist/index.js' when you change this! +const setupRubyTag = 'v1.170.0' + +const token = core.getInput("fontist-token"); +const octokit = token + ? github.getOctokit(token) + : github.getOctokit(undefined!, { + authStrategy: createUnauthenticatedAuth, + auth: { reason: "no 'fontist-token' input" }, + }); + +const versionRaw = core.getInput("fontist-version"); +let version: string; +if (versionRaw === "latest") { + const { data } = await octokit.rest.repos.getLatestRelease({ + owner: "fontist", + repo: "fontist", + }); + version = data.tag_name.slice(1); +} else { + const releases = await octokit.paginate(octokit.rest.repos.listReleases, { + owner: "fontist", + repo: "fontist", + }); + const versions = releases.map((release) => release.tag_name.slice(1)); + version = semver.maxSatisfying(versions, versionRaw)!; +} +core.debug(`Resolved version: v${version}`); +if (!version) throw new DOMException(`${versionRaw} resolved to ${version}`); + +let found = tc.find("fontist", version); +core.setOutput("cache-hit", !!found) +if (!found) { + let setupRubyPath = await tc.downloadTool(`https://github.com/ruby/setup-ruby/archive/refs/tags/${setupRubyTag}.zip`) + setupRubyPath = await tc.extractZip(setupRubyPath) + + const tempDir =join(process.env.RUNNER_TEMP!, Math.random().toString()) + await mkdir(tempDir); + + let cacheDir = join(process.env.RUNNER_TEMP!, Math.random().toString()) + await mkdir(cacheDir); + cacheDir = await tc.cacheDir(cacheDir, "fontist", version) + try { + const { all } = await $({ + env: { + RUNNER_TOOL_CACHE: join(cacheDir, "setup-ruby-tool-cache"), + GITHUB_PATH: join(tempDir, "GITHUB_PATH"), + GITHUB_ENV: join(tempDir, "GITHUB_ENV"), + }, + all: true + })`${process.execPath} ${setupRubyPath}/dist/index.js` + // Escaped so that "::command::options" isn't interpreted as a command. + console.error(JSON.stringify(all)) + } catch (error) { + await rm(cacheDir, { recursive: true, force: true }) + throw error + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..dcd8fc5 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "lib": ["ESNext"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + /* Linting */ + "skipLibCheck": true, + "strict": true, + "noFallthroughCasesInSwitch": true, + "forceConsistentCasingInFileNames": true + } +} From 2e4d0fa03bd29484833704616362aeda109e08ec Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 16:18:03 +0000 Subject: [PATCH 02/37] use bun workflows --- .github/workflows/publish-action.yml | 10 ++++++++++ .github/workflows/test-action.yml | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-action.yml b/.github/workflows/publish-action.yml index cbdfcfe..8fc62a9 100644 --- a/.github/workflows/publish-action.yml +++ b/.github/workflows/publish-action.yml @@ -9,6 +9,16 @@ jobs: contents: write runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v1 + - run: bun install + - run: bun run build + - run: rm -rf node_modules + - uses: actions4git/setup-git@v1 + - run: git add -Af && git commit -m 'npm run build' + - run: git tag -f "$TAG" && git push -f origin "$TAG" + env: + TAG: ${{ github.event.release.tag_name }} - uses: actions/publish-action@v0.2.2 with: source-tag: ${{ github.event.release.tag_name }} diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index 7b50509..474dc58 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -23,9 +23,14 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + # os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v1 + - run: bun install + - run: bun run build - uses: ./ - - run: fontist list "Fira Code" + - run: typst --version + - run: typst compile test.typ From 124eb90181d42e09441854e2051dce2fc87979e2 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 16:19:20 +0000 Subject: [PATCH 03/37] proper inputs & outputs --- action.yml | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/action.yml b/action.yml index e161325..67c43ef 100644 --- a/action.yml +++ b/action.yml @@ -6,21 +6,17 @@ branding: color: purple inputs: - setup-ruby: - default: true fontist-version: - default: "1.19.0" + default: latest + fontist-token: + default: ${{ github.server_url == 'https://github.com' && github.token || '' }} + setup-ruby-token: + default: ${{ github.server_url == 'https://github.com' && github.token || '' }} + +outputs: + fontist-version: {} + cache-hit: {} runs: - using: composite - steps: - - if: inputs.setup-ruby == 'true' - uses: ruby/setup-ruby@v1 - with: - ruby-version: ruby - - shell: bash - run: | - gem install fontist --version "$(printenv INPUT_FONTIST-VERSION)" - fontist update - env: - INPUT_FONTIST-VERSION: ${{ inputs.fontist-version }} + using: node20 + main: dist/main.js From fe98dc69200c642e30e848ce11da2192f996ba1b Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 16:29:10 +0000 Subject: [PATCH 04/37] use tags instead of releases --- src/main.ts | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/main.ts b/src/main.ts index b28ab4c..5e8990d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -20,21 +20,12 @@ const octokit = token }); const versionRaw = core.getInput("fontist-version"); -let version: string; -if (versionRaw === "latest") { - const { data } = await octokit.rest.repos.getLatestRelease({ - owner: "fontist", - repo: "fontist", - }); - version = data.tag_name.slice(1); -} else { - const releases = await octokit.paginate(octokit.rest.repos.listReleases, { - owner: "fontist", - repo: "fontist", - }); - const versions = releases.map((release) => release.tag_name.slice(1)); - version = semver.maxSatisfying(versions, versionRaw)!; -} +const tags = await octokit.paginate(octokit.rest.repos.listTags, { + owner: "fontist", + repo: "fontist", +}); +const versions = tags.map((tag) => tag.name); +const version = semver.maxSatisfying(versions, versionRaw === "latest" ? "*" : versionRaw)!; core.debug(`Resolved version: v${version}`); if (!version) throw new DOMException(`${versionRaw} resolved to ${version}`); From 5e42ea3aa1f3475dc7727297d02db3de254b14a8 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 16:32:08 +0000 Subject: [PATCH 05/37] subdir of extracted --- src/main.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.ts b/src/main.ts index 5e8990d..be39b32 100644 --- a/src/main.ts +++ b/src/main.ts @@ -34,6 +34,7 @@ core.setOutput("cache-hit", !!found) if (!found) { let setupRubyPath = await tc.downloadTool(`https://github.com/ruby/setup-ruby/archive/refs/tags/${setupRubyTag}.zip`) setupRubyPath = await tc.extractZip(setupRubyPath) + setupRubyPath = join(setupRubyPath, `setup-ruby-${setupRubyTag}`) const tempDir =join(process.env.RUNNER_TEMP!, Math.random().toString()) await mkdir(tempDir); From 33f30ce96ec40be5f9d6d3bd8f869ba61e119588 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 16:35:41 +0000 Subject: [PATCH 06/37] save --- src/main.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index be39b32..bd3cdc1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -32,9 +32,10 @@ if (!version) throw new DOMException(`${versionRaw} resolved to ${version}`); let found = tc.find("fontist", version); core.setOutput("cache-hit", !!found) if (!found) { + core.info(`Downloading setup-ruby@${setupRubyTag}`) let setupRubyPath = await tc.downloadTool(`https://github.com/ruby/setup-ruby/archive/refs/tags/${setupRubyTag}.zip`) setupRubyPath = await tc.extractZip(setupRubyPath) - setupRubyPath = join(setupRubyPath, `setup-ruby-${setupRubyTag}`) + setupRubyPath = join(setupRubyPath, `setup-ruby-${setupRubyTag.slice(1)}`) const tempDir =join(process.env.RUNNER_TEMP!, Math.random().toString()) await mkdir(tempDir); @@ -54,6 +55,7 @@ if (!found) { // Escaped so that "::command::options" isn't interpreted as a command. console.error(JSON.stringify(all)) } catch (error) { + core.error(`Failure inside setup block. Removing tool cache folder.`) await rm(cacheDir, { recursive: true, force: true }) throw error } From 9df307f01b0dd482c8f74db6e90345e79298b7d7 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 16:39:25 +0000 Subject: [PATCH 07/37] set action.yml defaults in env vars --- src/main.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.ts b/src/main.ts index bd3cdc1..ff7b46d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -49,6 +49,8 @@ if (!found) { RUNNER_TOOL_CACHE: join(cacheDir, "setup-ruby-tool-cache"), GITHUB_PATH: join(tempDir, "GITHUB_PATH"), GITHUB_ENV: join(tempDir, "GITHUB_ENV"), + "INPUT_RUBY-VERSION": "ruby", + "INPUT_BUNDLER-CACHE": "false", }, all: true })`${process.execPath} ${setupRubyPath}/dist/index.js` From 4863584f2a9980d3ada5cba13d05a18ed4f7e5e2 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 16:40:47 +0000 Subject: [PATCH 08/37] create files before use --- src/main.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index ff7b46d..fadc62e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,7 +6,7 @@ import * as github from "@actions/github" import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated" import * as semver from "semver" import { join } from "node:path" -import { mkdir, rm } from "node:fs/promises" +import { mkdir, rm, writeFile } from "node:fs/promises" // Make sure it's still 'dist/index.js' when you change this! const setupRubyTag = 'v1.170.0' @@ -44,11 +44,15 @@ if (!found) { await mkdir(cacheDir); cacheDir = await tc.cacheDir(cacheDir, "fontist", version) try { + const githubPath = join(tempDir, "GITHUB_PATH") + await writeFile(githubPath, "") + const githubEnv = join(tempDir, "GITHUB_ENV") + await writeFile(githubEnv, "") const { all } = await $({ env: { RUNNER_TOOL_CACHE: join(cacheDir, "setup-ruby-tool-cache"), - GITHUB_PATH: join(tempDir, "GITHUB_PATH"), - GITHUB_ENV: join(tempDir, "GITHUB_ENV"), + GITHUB_PATH: githubPath, + GITHUB_ENV: githubEnv, "INPUT_RUBY-VERSION": "ruby", "INPUT_BUNDLER-CACHE": "false", }, From 8282e11a2566ecf28b0b4d2d094425ca33276308 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 16:43:26 +0000 Subject: [PATCH 09/37] log env and path --- src/main.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index fadc62e..82c21be 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,7 +6,7 @@ import * as github from "@actions/github" import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated" import * as semver from "semver" import { join } from "node:path" -import { mkdir, rm, writeFile } from "node:fs/promises" +import { mkdir, readFile, rm, writeFile } from "node:fs/promises" // Make sure it's still 'dist/index.js' when you change this! const setupRubyTag = 'v1.170.0' @@ -58,8 +58,9 @@ if (!found) { }, all: true })`${process.execPath} ${setupRubyPath}/dist/index.js` - // Escaped so that "::command::options" isn't interpreted as a command. - console.error(JSON.stringify(all)) + core.info(all!) + core.info(`GITHUB_PATH=${await readFile(githubPath, "utf8")}`) + core.info(`GITHUB_ENV=${await readFile(githubEnv, "utf8")}`) } catch (error) { core.error(`Failure inside setup block. Removing tool cache folder.`) await rm(cacheDir, { recursive: true, force: true }) From f89dafc940eceb8d436328322532ea3dd18f75b2 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 16:50:29 +0000 Subject: [PATCH 10/37] proper command --- .github/workflows/test-action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index 474dc58..db8b7e1 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -32,5 +32,4 @@ jobs: - run: bun install - run: bun run build - uses: ./ - - run: typst --version - - run: typst compile test.typ + - run: fontist list "Fira Code" From e238f708279c4d2951adaf764de79699f8f372bb Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 19:07:35 +0000 Subject: [PATCH 11/37] try this --- action.yml | 16 ++++++++++------ bun.lockb | Bin 22209 -> 22209 bytes setup-fontist/action.yml | 3 +++ src/main.ts | 36 ++++++++++++++---------------------- 4 files changed, 27 insertions(+), 28 deletions(-) create mode 100644 setup-fontist/action.yml diff --git a/action.yml b/action.yml index 67c43ef..ef0652b 100644 --- a/action.yml +++ b/action.yml @@ -6,17 +6,21 @@ branding: color: purple inputs: - fontist-version: - default: latest fontist-token: default: ${{ github.server_url == 'https://github.com' && github.token || '' }} - setup-ruby-token: - default: ${{ github.server_url == 'https://github.com' && github.token || '' }} + fontist-version: + default: latest outputs: fontist-version: {} cache-hit: {} runs: - using: node20 - main: dist/main.js + using: composite + steps: + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ruby + env: + GITHUB_PATH: ${{ runner.temp }}/GITHUB_PATH + - uses: ./setup-fontist diff --git a/bun.lockb b/bun.lockb index 1fb36beb4d5750ae49aaf8059ff7ae1eab5e087d..b611a929845cff00dd4f0a034f3ae482ca354664 100755 GIT binary patch delta 22 ecmX@Omhs?P#to`=?2K{ddZv0Nn|17_N&o;{kOv+B delta 22 acmX@Omhs?P#to`=>`V+`uvy1$sssQ~tOdmY diff --git a/setup-fontist/action.yml b/setup-fontist/action.yml new file mode 100644 index 0000000..e6cf5f7 --- /dev/null +++ b/setup-fontist/action.yml @@ -0,0 +1,3 @@ +runs: + using: node20 + main: ../dist/main.js diff --git a/src/main.ts b/src/main.ts index 82c21be..56fc4cd 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,7 +5,7 @@ import * as tc from "@actions/tool-cache" import * as github from "@actions/github" import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated" import * as semver from "semver" -import { join } from "node:path" +import { delimiter, join } from "node:path" import { mkdir, readFile, rm, writeFile } from "node:fs/promises" // Make sure it's still 'dist/index.js' when you change this! @@ -32,38 +32,30 @@ if (!version) throw new DOMException(`${versionRaw} resolved to ${version}`); let found = tc.find("fontist", version); core.setOutput("cache-hit", !!found) if (!found) { - core.info(`Downloading setup-ruby@${setupRubyTag}`) - let setupRubyPath = await tc.downloadTool(`https://github.com/ruby/setup-ruby/archive/refs/tags/${setupRubyTag}.zip`) - setupRubyPath = await tc.extractZip(setupRubyPath) - setupRubyPath = join(setupRubyPath, `setup-ruby-${setupRubyTag.slice(1)}`) - - const tempDir =join(process.env.RUNNER_TEMP!, Math.random().toString()) - await mkdir(tempDir); + const githubPath = await readFile(join(process.env.RUNNER_TEMP!, "GITHUB_PATH"), "utf8") + const githubPathItems = githubPath.trimEnd().split(/\r?\n/) + const extraPath = githubPathItems.join(delimiter) let cacheDir = join(process.env.RUNNER_TEMP!, Math.random().toString()) await mkdir(cacheDir); cacheDir = await tc.cacheDir(cacheDir, "fontist", version) try { - const githubPath = join(tempDir, "GITHUB_PATH") - await writeFile(githubPath, "") - const githubEnv = join(tempDir, "GITHUB_ENV") - await writeFile(githubEnv, "") const { all } = await $({ + all: true, env: { - RUNNER_TOOL_CACHE: join(cacheDir, "setup-ruby-tool-cache"), - GITHUB_PATH: githubPath, - GITHUB_ENV: githubEnv, - "INPUT_RUBY-VERSION": "ruby", - "INPUT_BUNDLER-CACHE": "false", - }, - all: true - })`${process.execPath} ${setupRubyPath}/dist/index.js` + PATH: `${process.env.PATH}${delimiter}${extraPath}`, + } + })`gem install fontist --version ${version} --install-dir ${join(cacheDir, "install-dir")} --bindir ${join(cacheDir, "bindir")}` core.info(all!) - core.info(`GITHUB_PATH=${await readFile(githubPath, "utf8")}`) - core.info(`GITHUB_ENV=${await readFile(githubEnv, "utf8")}`) } catch (error) { core.error(`Failure inside setup block. Removing tool cache folder.`) await rm(cacheDir, { recursive: true, force: true }) throw error } + + found = cacheDir } + +core.addPath(found); +core.setOutput("fontist-version", version); +core.info(`✅ Fontist v${version} installed!`); From 4464e27397a62f752c1597ef496f1c395d82e61b Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 19:13:31 +0000 Subject: [PATCH 12/37] try this --- src/main.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main.ts b/src/main.ts index 56fc4cd..8854d15 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,16 +8,14 @@ import * as semver from "semver" import { delimiter, join } from "node:path" import { mkdir, readFile, rm, writeFile } from "node:fs/promises" -// Make sure it's still 'dist/index.js' when you change this! -const setupRubyTag = 'v1.170.0' - const token = core.getInput("fontist-token"); -const octokit = token - ? github.getOctokit(token) - : github.getOctokit(undefined!, { - authStrategy: createUnauthenticatedAuth, - auth: { reason: "no 'fontist-token' input" }, - }); +// const octokit = token +// ? github.getOctokit(token) +// : github.getOctokit(undefined!, { +// authStrategy: createUnauthenticatedAuth, +// auth: { reason: "no 'fontist-token' input" }, +// }); +const octokit = github.getOctokit(token) const versionRaw = core.getInput("fontist-version"); const tags = await octokit.paginate(octokit.rest.repos.listTags, { From c6de7d601f47e32b90235c9c9a009f24c71bdbc1 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 19:22:11 +0000 Subject: [PATCH 13/37] pass through inputs --- action.yml | 10 +++++++--- bun.lockb | Bin 22209 -> 22209 bytes package.json | 20 +++++++++----------- src/main.ts | 13 ++++++------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/action.yml b/action.yml index ef0652b..bf7eda9 100644 --- a/action.yml +++ b/action.yml @@ -12,8 +12,10 @@ inputs: default: latest outputs: - fontist-version: {} - cache-hit: {} + fontist-version: + value: ${{ steps.setup-fontist.outputs.fontist-version }} + cache-hit: + value: ${{ steps.setup-fontist.outputs.cache-hit }} runs: using: composite @@ -23,4 +25,6 @@ runs: ruby-version: ruby env: GITHUB_PATH: ${{ runner.temp }}/GITHUB_PATH - - uses: ./setup-fontist + - id: setup-fontist + uses: ./setup-fontist + with: ${{ inputs }} diff --git a/bun.lockb b/bun.lockb index b611a929845cff00dd4f0a034f3ae482ca354664..d8e9442241b876547a33895306390b197741f9ad 100755 GIT binary patch delta 809 zcmbtSUr3Wt6u3q$c^WB-_7s-M?>h&do+!%+~)+1PiIvXKbKub4qHMJ_vge zR)@%f^r4;t$@&P2d@-<>2+F4(3VbLiD+uaQrSlCx=)D8yp8Gq$dpY;q-&tLvt4nmb zhD)>%LTU+_&KHGJDJvA~5$h0Rj%YAC4TNYhBCMW!j9C3o{`W2x&v0dGU2L5`?3fiY zANyVBo;qI4EsU)=v+Jtj&9=U|L(jrN^>F9w&9nDj!iK^unw1GH$Lqmvif}V}$eH}G zp;1HD*v0+P!=t(g4Z^p&F7*VK;ISlyf+4^?H^8PbqT0e_6b7{+E^LHcogZ9ErTEZP zp+V`T328x-B1P|(0Gbpfd>mbYeiB_WDN^yi>CXRL4>$ZW!fjg;u32>O({@x%$&O(M z%X#5|r5CJL9elASDGzR2FML2WYe~`oyhpBV(*ciM5N52W;h=IaT*P(~_7w$Gn3*f+ zVaoAJ{K_t9Xg9<=Zs5Ask)lax3Z17XU^Em^`LG4A_$1Uw>+!Ql09{H+-_b7Z;ZtV- zGU0{+Sy@?=8rtu1F}I8PWbI|ukO?rJ`3aGyL)H};FLN_DA@cml$|J)wFY}6(@Vh;{ zJUz1R9G&8s$IpC3o}LYCo){`{0s&{x2@J%qsu@ delta 825 zcmbVKO=uHQ5Z?E?k;LX_6O2t!Xb@|%iQVSM-8J1NRY)Yd#;Q#ysDxS@BtqMmrp1cZ zdJuZBP#qMbpdy}xLUr*V_R@nMwRqJW3RbkBh~P;CXJb|i-W(Xd*>85<%zNJ~&6A~h zvS6m^Hiltr3^VOU+=y7UGmHiC1ELkN*7(LW)4Yzyxc+~sT&Prvg|c>-&Jgq6iN%iM z8&ml@>-ApiJT|-IX*^~b?S8p-?bADhR|P^-G`kl25f>gQA+$Wlmb_Q6}*(^ zU@9nSAB7XmBn_#qOC$p?y86fgXjP6A6~-0W6vOtrwZ}>eaYr$f(D5yqU5!|VTDPp~ z+8K&)Bp(S0;jkbZ>KU3~CMrY(EH(5sRKtuYgoF^oxWO53^%#3&C~hWsSr7$Dn~N`R zpjA6uNP4#71ofpc8dDO`DYTj$7LuNfv1P`NP`yh;(g#3WKl9(xe`}_G*T9eDMY`gE z^Qlz($mmd^GFd8&ohlbgl|A*ab8vj55sejwCva!qr+(Vtdu|&*R)K7809Ld6;7d-a XbFZ>3h+E)wu8m0Ww(lmK4BYw!p3KqE diff --git a/package.json b/package.json index 7d2a762..e189ade 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,20 @@ { "type": "module", - "devDependencies": { - "@types/bun": "latest", - "@types/semver": "^7.5.6" - }, - "peerDependencies": { - "typescript": "^5.0.0", - "prettier": "^3.2.4", - "@types/node": "^20.11.7" - }, "packageManager": "bun@1.0.25", "dependencies": { "@actions/core": "^1.10.1", "@actions/github": "^6.0.0", "@actions/tool-cache": "^2.0.1", "@octokit/auth-unauthenticated": "^5.0.1", - "execa": "^8.0.1", - "semver": "^7.5.4" + "semver": "^7.5.4", + "execa": "^8.0.1" + }, + "devDependencies": { + "@types/node": "^20.10.4", + "@types/semver": "^7.5.6", + "prettier": "^3.1.1", + "typescript": "^5.3.3", + "@types/bun": "latest" }, "scripts": { "build": "bun build ./src/main.ts --outdir=dist --target=node", diff --git a/src/main.ts b/src/main.ts index 8854d15..841676e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,13 +9,12 @@ import { delimiter, join } from "node:path" import { mkdir, readFile, rm, writeFile } from "node:fs/promises" const token = core.getInput("fontist-token"); -// const octokit = token -// ? github.getOctokit(token) -// : github.getOctokit(undefined!, { -// authStrategy: createUnauthenticatedAuth, -// auth: { reason: "no 'fontist-token' input" }, -// }); -const octokit = github.getOctokit(token) +const octokit = token + ? github.getOctokit(token) + : github.getOctokit(undefined!, { + authStrategy: createUnauthenticatedAuth, + auth: { reason: "no 'fontist-token' input" }, + }); const versionRaw = core.getInput("fontist-version"); const tags = await octokit.paginate(octokit.rest.repos.listTags, { From 2350c702d1bb3a4d0b29ade94d08b2145e0a73ce Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 19:23:27 +0000 Subject: [PATCH 14/37] touch file --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index bf7eda9..5812a9a 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,7 @@ outputs: runs: using: composite steps: + - run: touch "$RUNNER_TEMP/GITHUB_PATH" - uses: ruby/setup-ruby@v1 with: ruby-version: ruby From 6d6eac60948025af8eedee94a97eb32165f88129 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 19:24:24 +0000 Subject: [PATCH 15/37] shell field --- action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 5812a9a..a8617aa 100644 --- a/action.yml +++ b/action.yml @@ -20,7 +20,8 @@ outputs: runs: using: composite steps: - - run: touch "$RUNNER_TEMP/GITHUB_PATH" + - shell: bash + run: touch "$RUNNER_TEMP/GITHUB_PATH" - uses: ruby/setup-ruby@v1 with: ruby-version: ruby From 73118e861ed95619083e2617f187ef291af64fb9 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 20:33:07 +0000 Subject: [PATCH 16/37] strip v prefix --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 841676e..7e28161 100644 --- a/src/main.ts +++ b/src/main.ts @@ -21,7 +21,7 @@ const tags = await octokit.paginate(octokit.rest.repos.listTags, { owner: "fontist", repo: "fontist", }); -const versions = tags.map((tag) => tag.name); +const versions = tags.map((tag) => tag.name.slice(1)); const version = semver.maxSatisfying(versions, versionRaw === "latest" ? "*" : versionRaw)!; core.debug(`Resolved version: v${version}`); if (!version) throw new DOMException(`${versionRaw} resolved to ${version}`); From 88831240ee0623a28fc1e7d26a3d893559176515 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 20:36:10 +0000 Subject: [PATCH 17/37] bindir --- src/main.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 7e28161..3206c14 100644 --- a/src/main.ts +++ b/src/main.ts @@ -53,6 +53,8 @@ if (!found) { found = cacheDir } -core.addPath(found); +core.addPath(join(found, "bindir")); core.setOutput("fontist-version", version); core.info(`✅ Fontist v${version} installed!`); + +await $({ stdio: "inherit" })`fontist update` From 9f8585ada3b59a59e80a3981e287d3f494371f21 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 20:37:45 +0000 Subject: [PATCH 18/37] fmt --- src/main.ts | 55 ++++++++++++++++++++++++++++----------------------- tsconfig.json | 4 ++-- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/main.ts b/src/main.ts index 3206c14..ee96037 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,12 +1,12 @@ #!/usr/bin/env node -import { $ } from "execa" -import * as core from "@actions/core" -import * as tc from "@actions/tool-cache" -import * as github from "@actions/github" -import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated" -import * as semver from "semver" -import { delimiter, join } from "node:path" -import { mkdir, readFile, rm, writeFile } from "node:fs/promises" +import { $ } from "execa"; +import * as core from "@actions/core"; +import * as tc from "@actions/tool-cache"; +import * as github from "@actions/github"; +import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated"; +import * as semver from "semver"; +import { delimiter, join } from "node:path"; +import { mkdir, readFile, rm, writeFile } from "node:fs/promises"; const token = core.getInput("fontist-token"); const octokit = token @@ -22,39 +22,44 @@ const tags = await octokit.paginate(octokit.rest.repos.listTags, { repo: "fontist", }); const versions = tags.map((tag) => tag.name.slice(1)); -const version = semver.maxSatisfying(versions, versionRaw === "latest" ? "*" : versionRaw)!; +const version = semver.maxSatisfying( + versions, + versionRaw === "latest" ? "*" : versionRaw, +)!; core.debug(`Resolved version: v${version}`); if (!version) throw new DOMException(`${versionRaw} resolved to ${version}`); let found = tc.find("fontist", version); -core.setOutput("cache-hit", !!found) +core.setOutput("cache-hit", !!found); if (!found) { - const githubPath = await readFile(join(process.env.RUNNER_TEMP!, "GITHUB_PATH"), "utf8") - const githubPathItems = githubPath.trimEnd().split(/\r?\n/) - const extraPath = githubPathItems.join(delimiter) + const githubPath = await readFile( + join(process.env.RUNNER_TEMP!, "GITHUB_PATH"), + "utf8", + ); + const githubPathItems = githubPath.trimEnd().split(/\r?\n/); + const extraPath = githubPathItems.join(delimiter); - let cacheDir = join(process.env.RUNNER_TEMP!, Math.random().toString()) + let cacheDir = join(process.env.RUNNER_TEMP!, Math.random().toString()); await mkdir(cacheDir); - cacheDir = await tc.cacheDir(cacheDir, "fontist", version) + cacheDir = await tc.cacheDir(cacheDir, "fontist", version); try { - const { all } = await $({ - all: true, + await $({ + stdio: "inherit", env: { PATH: `${process.env.PATH}${delimiter}${extraPath}`, - } - })`gem install fontist --version ${version} --install-dir ${join(cacheDir, "install-dir")} --bindir ${join(cacheDir, "bindir")}` - core.info(all!) + }, + })`gem install fontist --version ${version} --install-dir ${join(cacheDir, "install-dir")} --bindir ${join(cacheDir, "bindir")}`; } catch (error) { - core.error(`Failure inside setup block. Removing tool cache folder.`) - await rm(cacheDir, { recursive: true, force: true }) - throw error + core.error(`Failure inside setup block. Removing tool cache folder.`); + await rm(cacheDir, { recursive: true, force: true }); + throw error; } - found = cacheDir + found = cacheDir; } core.addPath(join(found, "bindir")); core.setOutput("fontist-version", version); core.info(`✅ Fontist v${version} installed!`); -await $({ stdio: "inherit" })`fontist update` +await $({ stdio: "inherit" })`fontist update`; diff --git a/tsconfig.json b/tsconfig.json index dcd8fc5..4cce410 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,6 +17,6 @@ "skipLibCheck": true, "strict": true, "noFallthroughCasesInSwitch": true, - "forceConsistentCasingInFileNames": true - } + "forceConsistentCasingInFileNames": true, + }, } From ee89e823a0808bc6c3b7678abc49d8e36e07c5b6 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 20:43:56 +0000 Subject: [PATCH 19/37] different path strat --- src/main.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index ee96037..fb6b565 100644 --- a/src/main.ts +++ b/src/main.ts @@ -37,7 +37,7 @@ if (!found) { "utf8", ); const githubPathItems = githubPath.trimEnd().split(/\r?\n/); - const extraPath = githubPathItems.join(delimiter); + process.env.PATH = [process.env.PATH, ...githubPathItems].join(delimiter); let cacheDir = join(process.env.RUNNER_TEMP!, Math.random().toString()); await mkdir(cacheDir); @@ -45,16 +45,12 @@ if (!found) { try { await $({ stdio: "inherit", - env: { - PATH: `${process.env.PATH}${delimiter}${extraPath}`, - }, })`gem install fontist --version ${version} --install-dir ${join(cacheDir, "install-dir")} --bindir ${join(cacheDir, "bindir")}`; } catch (error) { core.error(`Failure inside setup block. Removing tool cache folder.`); await rm(cacheDir, { recursive: true, force: true }); throw error; } - found = cacheDir; } From 59c21cfa30262774c94718725d7ecfb388479921 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 21:13:37 +0000 Subject: [PATCH 20/37] just bindir --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index fb6b565..315c854 100644 --- a/src/main.ts +++ b/src/main.ts @@ -45,7 +45,7 @@ if (!found) { try { await $({ stdio: "inherit", - })`gem install fontist --version ${version} --install-dir ${join(cacheDir, "install-dir")} --bindir ${join(cacheDir, "bindir")}`; + })`gem install fontist --version ${version} --bindir ${join(cacheDir, "bindir")}`; } catch (error) { core.error(`Failure inside setup block. Removing tool cache folder.`); await rm(cacheDir, { recursive: true, force: true }); From 7ce2bd7b8f6cfde52982e6851e86e8202a45d07e Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 21:30:46 +0000 Subject: [PATCH 21/37] update desc --- README.md | 24 ++++++++++++++++++------ action.yml | 6 ++++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b7a03c9..73c0d05 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,17 @@ 💎 Uses Ruby to install the fontist Ruby gem \ 🟦 Works with Windows \ -🔠 Lets you install additional fonts +🐧 Works with Ubuntu \ +🍎 Works with macOS \ +⚡ Caches installation in `$RUNNER_TOOL_CACHE` ## Usage ![GitHub Actions](https://img.shields.io/static/v1?style=for-the-badge&message=GitHub+Actions&color=2088FF&logo=GitHub+Actions&logoColor=FFFFFF&label=) ![GitHub](https://img.shields.io/static/v1?style=for-the-badge&message=GitHub&color=181717&logo=GitHub&logoColor=FFFFFF&label=) +**🚀 Here's what you're after:** + ```yml on: push jobs: @@ -31,19 +35,27 @@ jobs: - run: fontist install "Fira Code" ``` -**⚠️ This action takes a while** (~1 minute). There's currently **no caching**. [Caching is planned for the future.](#TODO) +💡 You can use `fontist manifest-install manifest.yml` to install fonts listed in a manifest file similar to `package.json`, `requirements.txt`, and `Cargo.toml`. ### Inputs -- **`setup-ruby`:** Whether or not to run [ruby/setup-ruby](https://github.com/ruby/setup-ruby) or to assume that the user has supplied an appropriate global Ruby installation. Defaults to `true`. Set this to `false` to provide your own custom Ruby installation. +- **`fontist-version`:** The version of Fontist to install. This can be an exact version lile `1.10.0` or a semver range such as `1.x` or `~1.15.0`. The default value is `latest`. + +- **`fontist-token`:** The GitHub token to use when fetching the version list from fontist/fontist. You shouldn't have to touch this. The default is the `github.token` if you're on github.com or unauthenticated (rate limited) if you're not on github.com. + +### Outputs + +- **`fontist-version`:** The version of Fontist that was installed. This will be something like 16.0.0 or similar. -- **`fontist-version`:** An exact version of the fontist Ruby gem to install. Defaults to `1.19.0`. +- **`cache-hit`:** Whether or not Fontist was restored from the runner's cache or download anew. ## Development -![GNU Bash](https://img.shields.io/static/v1?style=for-the-badge&message=GNU+Bash&color=4EAA25&logo=GNU+Bash&logoColor=FFFFFF&label=) +![Bun](https://img.shields.io/static/v1?style=for-the-badge&message=Bun&color=000000&logo=Bun&logoColor=FFFFFF&label=) +![Node.js](https://img.shields.io/static/v1?style=for-the-badge&message=Node.js&color=339933&logo=Node.js&logoColor=FFFFFF&label=) +![Ruby](https://img.shields.io/static/v1?style=for-the-badge&message=Ruby&color=CC342D&logo=Ruby&logoColor=FFFFFF&label=) -TODO: Add development section +This action uses a hack to install Ruby using [ruby/setup-ruby](https://github.com/ruby/setup-ruby) but without adding it to the `$PATH`. Then, we run `gem install fontist` using that un-`$PATH`-ed Ruby version and expose only the `fontist` executable. The action is bundled using [Bun](https://bun.sh/) to a single file on each GitHub release. ## Contributions diff --git a/action.yml b/action.yml index a8617aa..c8df701 100644 --- a/action.yml +++ b/action.yml @@ -6,10 +6,12 @@ branding: color: purple inputs: - fontist-token: - default: ${{ github.server_url == 'https://github.com' && github.token || '' }} fontist-version: + description: The version of Fontist to install. This can be an exact version lile '1.10.0' or a semver range such as '1.x' or '~1.15.0'. The default value is 'latest'. default: latest + fontist-token: + description: The GitHub token to use when fetching the version list from fontist/fontist. You shouldn't have to touch this. The default is the 'github.token' if you're on github.com or unauthenticated (rate limited) if you're not on github.com. + default: ${{ github.server_url == 'https://github.com' && github.token || '' }} outputs: fontist-version: From 49d74f4bb9491967fc023e6313149a728e9d301a Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 21:33:28 +0000 Subject: [PATCH 22/37] add desc to action.yml --- README.md | 2 +- action.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 73c0d05..ac041b2 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ jobs: ### Outputs -- **`fontist-version`:** The version of Fontist that was installed. This will be something like 16.0.0 or similar. +- **`fontist-version`:** The version of Fontist that was installed. This will be something like `1.10.0` or similar. - **`cache-hit`:** Whether or not Fontist was restored from the runner's cache or download anew. diff --git a/action.yml b/action.yml index c8df701..f233b2b 100644 --- a/action.yml +++ b/action.yml @@ -15,8 +15,10 @@ inputs: outputs: fontist-version: + description: The version of Fontist that was installed. This will be something like '1.10.0' or similar. value: ${{ steps.setup-fontist.outputs.fontist-version }} cache-hit: + description: Whether or not Fontist was restored from the runner's cache or download anew. value: ${{ steps.setup-fontist.outputs.cache-hit }} runs: From 62a93a33da78b052c3288f3cbafaa7b88c3ea192 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 22:07:00 +0000 Subject: [PATCH 23/37] dump env --- src/main.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.ts b/src/main.ts index 315c854..6fbb11e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -59,3 +59,5 @@ core.setOutput("fontist-version", version); core.info(`✅ Fontist v${version} installed!`); await $({ stdio: "inherit" })`fontist update`; + +console.debug(process.env) From e7989b30939d359e4e1ba8c870637704ed60bdd1 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 22:31:38 +0000 Subject: [PATCH 24/37] try wrapper script --- src/main.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 6fbb11e..96ba7ea 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,7 +6,7 @@ import * as github from "@actions/github"; import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated"; import * as semver from "semver"; import { delimiter, join } from "node:path"; -import { mkdir, readFile, rm, writeFile } from "node:fs/promises"; +import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises"; const token = core.getInput("fontist-token"); const octokit = token @@ -45,7 +45,21 @@ if (!found) { try { await $({ stdio: "inherit", - })`gem install fontist --version ${version} --bindir ${join(cacheDir, "bindir")}`; + })`gem install fontist --version ${version} --install-dir ${join(cacheDir, "install-dir")} --bindir ${join(cacheDir, "bindir")}`; + + await mkdir(join(cacheDir, "bin")); + const bash = `\ +#!/bin/bash +export GEM_PATH=${join(cacheDir, "install-dir")} +export GEM_HOME=${join(cacheDir, "install-dir")} +exec ${join(cacheDir, "bindir", "fontist")} $@` + const cmd = `\ +@echo off +set GEM_PATH=${join(cacheDir, "install-dir")} +set GEM_HOME=${join(cacheDir, "install-dir")} +${join(cacheDir, "bindir", "fontist")} %*` + await writeFile(join(cacheDir, "bin", "fontist"), bash) + await writeFile(join(cacheDir, "bin", "fontist.cmd"), cmd) } catch (error) { core.error(`Failure inside setup block. Removing tool cache folder.`); await rm(cacheDir, { recursive: true, force: true }); @@ -54,10 +68,8 @@ if (!found) { found = cacheDir; } -core.addPath(join(found, "bindir")); +core.addPath(join(found, "bin")); core.setOutput("fontist-version", version); core.info(`✅ Fontist v${version} installed!`); await $({ stdio: "inherit" })`fontist update`; - -console.debug(process.env) From 1df950d44075d7f8d5fc24f088df07ff1a1a73ac Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 22:34:42 +0000 Subject: [PATCH 25/37] chmod --- src/main.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 96ba7ea..8f0838b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,7 +6,7 @@ import * as github from "@actions/github"; import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated"; import * as semver from "semver"; import { delimiter, join } from "node:path"; -import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises"; +import { chmod, cp, mkdir, readFile, rm, writeFile } from "node:fs/promises"; const token = core.getInput("fontist-token"); const octokit = token @@ -60,6 +60,8 @@ set GEM_HOME=${join(cacheDir, "install-dir")} ${join(cacheDir, "bindir", "fontist")} %*` await writeFile(join(cacheDir, "bin", "fontist"), bash) await writeFile(join(cacheDir, "bin", "fontist.cmd"), cmd) + await chmod(join(cacheDir, "bin", "fontist"), 0o755) + await chmod(join(cacheDir, "bin", "fontist.cmd"), 0o755) } catch (error) { core.error(`Failure inside setup block. Removing tool cache folder.`); await rm(cacheDir, { recursive: true, force: true }); From 3b68b986160272458a9e2c603879bb0c5389ddee Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 22:38:50 +0000 Subject: [PATCH 26/37] quote $@ --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 8f0838b..8021704 100644 --- a/src/main.ts +++ b/src/main.ts @@ -52,7 +52,7 @@ if (!found) { #!/bin/bash export GEM_PATH=${join(cacheDir, "install-dir")} export GEM_HOME=${join(cacheDir, "install-dir")} -exec ${join(cacheDir, "bindir", "fontist")} $@` +exec ${join(cacheDir, "bindir", "fontist")} "$@"` const cmd = `\ @echo off set GEM_PATH=${join(cacheDir, "install-dir")} From 2558cd414a11ae950a3585a1ed1d4eb0365451c8 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 26 Jan 2024 23:11:05 +0000 Subject: [PATCH 27/37] try this --- action.yml | 8 ++++++-- bun.lockb | Bin 22209 -> 37972 bytes package.json | 6 ++++-- setup-fontist/action.yml | 1 + src/main.ts | 30 ++++++++++++++++++++++-------- src/post.ts | 13 +++++++++++++ 6 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 src/post.ts diff --git a/action.yml b/action.yml index f233b2b..70fe9c0 100644 --- a/action.yml +++ b/action.yml @@ -12,6 +12,8 @@ inputs: fontist-token: description: The GitHub token to use when fetching the version list from fontist/fontist. You shouldn't have to touch this. The default is the 'github.token' if you're on github.com or unauthenticated (rate limited) if you're not on github.com. default: ${{ github.server_url == 'https://github.com' && github.token || '' }} + cache: + default: true outputs: fontist-version: @@ -25,12 +27,14 @@ runs: using: composite steps: - shell: bash - run: touch "$RUNNER_TEMP/GITHUB_PATH" + run: | + mkdir -p "$RUNNER_TEMP/setup-fontist" + touch "$RUNNER_TEMP/setup-fontist/GITHUB_PATH" - uses: ruby/setup-ruby@v1 with: ruby-version: ruby env: - GITHUB_PATH: ${{ runner.temp }}/GITHUB_PATH + GITHUB_PATH: ${{ runner.temp }}/setup-fontist/GITHUB_PATH - id: setup-fontist uses: ./setup-fontist with: ${{ inputs }} diff --git a/bun.lockb b/bun.lockb index d8e9442241b876547a33895306390b197741f9ad..52692346600b0ddfceb526dbb45facf2ed23bc7a 100755 GIT binary patch delta 13499 zcmeHucU)6jv*=C;B?t%tQX*ZX86Xr95dsQ=M?p{!D;gj|kWLV=5LB>XW!v?D6~$u# zv4LH%9TmaCK@k-@*u`G(&Fo}Dj^(@Wz2E)azwSEUWcJLOHEY()thE>0`A+U)T-(lE zYHzchGo{zo@TEK5U$hnak314*$XCkWvZ?svz`0)nO3fRzt4V@tk;}qOIAa7-f*{g_ z;`C%7(u4_9gsB8^ZP_wC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j07mG`uH32dr{mtS`uDynJUtDn z<?`Qtz#Wt|XpPhicIhKoTY^b+W#kg|4R4El|75558y4*>Y5)KL diff --git a/package.json b/package.json index e189ade..ef7b064 100644 --- a/package.json +++ b/package.json @@ -2,12 +2,14 @@ "type": "module", "packageManager": "bun@1.0.25", "dependencies": { + "@actions/cache": "^3.2.3", "@actions/core": "^1.10.1", "@actions/github": "^6.0.0", + "@actions/glob": "^0.4.0", "@actions/tool-cache": "^2.0.1", "@octokit/auth-unauthenticated": "^5.0.1", - "semver": "^7.5.4", - "execa": "^8.0.1" + "execa": "^8.0.1", + "semver": "^7.5.4" }, "devDependencies": { "@types/node": "^20.10.4", diff --git a/setup-fontist/action.yml b/setup-fontist/action.yml index e6cf5f7..0da61b3 100644 --- a/setup-fontist/action.yml +++ b/setup-fontist/action.yml @@ -1,3 +1,4 @@ runs: using: node20 main: ../dist/main.js + post: ../dist/post.js diff --git a/src/main.ts b/src/main.ts index 8021704..93961c3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,6 +7,15 @@ import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated"; import * as semver from "semver"; import { delimiter, join } from "node:path"; import { chmod, cp, mkdir, readFile, rm, writeFile } from "node:fs/promises"; +import * as cache from "@actions/cache" +import * as glob from "@actions/glob" + +const githubPath = await readFile( + join(process.env.RUNNER_TEMP!, "setup-fontist/GITHUB_PATH"), + "utf8", +); +const githubPathItems = githubPath.trimEnd().split(/\r?\n/); +process.env.PATH = [process.env.PATH, ...githubPathItems].join(delimiter); const token = core.getInput("fontist-token"); const octokit = token @@ -30,15 +39,8 @@ core.debug(`Resolved version: v${version}`); if (!version) throw new DOMException(`${versionRaw} resolved to ${version}`); let found = tc.find("fontist", version); -core.setOutput("cache-hit", !!found); +let cacheHit = !!found if (!found) { - const githubPath = await readFile( - join(process.env.RUNNER_TEMP!, "GITHUB_PATH"), - "utf8", - ); - const githubPathItems = githubPath.trimEnd().split(/\r?\n/); - process.env.PATH = [process.env.PATH, ...githubPathItems].join(delimiter); - let cacheDir = join(process.env.RUNNER_TEMP!, Math.random().toString()); await mkdir(cacheDir); cacheDir = await tc.cacheDir(cacheDir, "fontist", version); @@ -74,4 +76,16 @@ core.addPath(join(found, "bin")); core.setOutput("fontist-version", version); core.info(`✅ Fontist v${version} installed!`); +if (core.getBooleanInput("cache")) { + const cacheDir = join(process.env.HOME!, ".fontist") + const primaryKey = `fontist-${github.context.ref}` + core.saveState("cache-primary-key", primaryKey) + const hitKey = await cache.restoreCache([cacheDir], primaryKey) + core.saveState("cache-hit", hitKey) + cacheHit ||= !!hitKey +} + +core.setOutput("cache-hit", cacheHit) + +core.info(`Running 'fontist update'...`) await $({ stdio: "inherit" })`fontist update`; diff --git a/src/post.ts b/src/post.ts new file mode 100644 index 0000000..74162b5 --- /dev/null +++ b/src/post.ts @@ -0,0 +1,13 @@ +#!/usr/bin/env node +import * as cache from "@actions/cache"; +import * as core from "@actions/core"; +import * as glob from "@actions/glob"; +import { join } from "node:path"; + +if (core.getBooleanInput("cache")) { + const cacheDir = join(process.env.HOME!, ".fontist"); + const primaryKey = core.getState("cache-primary-key"); + const hitKey = core.getState("cache-hit-key"); + core.info(`Saving ${cacheDir} with key ${primaryKey}`); + cache.saveCache([cacheDir], primaryKey); +} From 749f8dcd7f953a30835a38c795ddb8e62d54f0c1 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Sat, 27 Jan 2024 00:39:55 +0000 Subject: [PATCH 28/37] compile post too --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ef7b064..6ef3df9 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "@types/bun": "latest" }, "scripts": { - "build": "bun build ./src/main.ts --outdir=dist --target=node", + "build": "bun build ./src/main.ts ./src/post.ts --outdir=dist --target=node", "format": "prettier -w .", "lint": "tsc --noEmit" } From bf557f53394839d2a360ab39e61d281fd8794d5a Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Sat, 27 Jan 2024 00:54:36 +0000 Subject: [PATCH 29/37] no more setup ruby --- action.yml | 17 +++-------------- setup-fontist/action.yml | 4 ---- src/main.ts | 9 +-------- src/post.ts | 2 +- 4 files changed, 5 insertions(+), 27 deletions(-) delete mode 100644 setup-fontist/action.yml diff --git a/action.yml b/action.yml index 70fe9c0..368071a 100644 --- a/action.yml +++ b/action.yml @@ -24,17 +24,6 @@ outputs: value: ${{ steps.setup-fontist.outputs.cache-hit }} runs: - using: composite - steps: - - shell: bash - run: | - mkdir -p "$RUNNER_TEMP/setup-fontist" - touch "$RUNNER_TEMP/setup-fontist/GITHUB_PATH" - - uses: ruby/setup-ruby@v1 - with: - ruby-version: ruby - env: - GITHUB_PATH: ${{ runner.temp }}/setup-fontist/GITHUB_PATH - - id: setup-fontist - uses: ./setup-fontist - with: ${{ inputs }} + using: node20 + main: dist/main.js + post: dist/post.js diff --git a/setup-fontist/action.yml b/setup-fontist/action.yml deleted file mode 100644 index 0da61b3..0000000 --- a/setup-fontist/action.yml +++ /dev/null @@ -1,4 +0,0 @@ -runs: - using: node20 - main: ../dist/main.js - post: ../dist/post.js diff --git a/src/main.ts b/src/main.ts index 93961c3..051118f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,13 +10,6 @@ import { chmod, cp, mkdir, readFile, rm, writeFile } from "node:fs/promises"; import * as cache from "@actions/cache" import * as glob from "@actions/glob" -const githubPath = await readFile( - join(process.env.RUNNER_TEMP!, "setup-fontist/GITHUB_PATH"), - "utf8", -); -const githubPathItems = githubPath.trimEnd().split(/\r?\n/); -process.env.PATH = [process.env.PATH, ...githubPathItems].join(delimiter); - const token = core.getInput("fontist-token"); const octokit = token ? github.getOctokit(token) @@ -78,7 +71,7 @@ core.info(`✅ Fontist v${version} installed!`); if (core.getBooleanInput("cache")) { const cacheDir = join(process.env.HOME!, ".fontist") - const primaryKey = `fontist-${github.context.ref}` + const primaryKey = `fontist-home` core.saveState("cache-primary-key", primaryKey) const hitKey = await cache.restoreCache([cacheDir], primaryKey) core.saveState("cache-hit", hitKey) diff --git a/src/post.ts b/src/post.ts index 74162b5..9781e0d 100644 --- a/src/post.ts +++ b/src/post.ts @@ -9,5 +9,5 @@ if (core.getBooleanInput("cache")) { const primaryKey = core.getState("cache-primary-key"); const hitKey = core.getState("cache-hit-key"); core.info(`Saving ${cacheDir} with key ${primaryKey}`); - cache.saveCache([cacheDir], primaryKey); + await cache.saveCache([cacheDir], primaryKey); } From 6d5d012b423ef2eaae6ae51e218421b7df76def8 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Sat, 27 Jan 2024 01:23:22 +0000 Subject: [PATCH 30/37] try this --- src/main.ts | 85 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 36 deletions(-) diff --git a/src/main.ts b/src/main.ts index 051118f..25ad29d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,8 +7,8 @@ import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated"; import * as semver from "semver"; import { delimiter, join } from "node:path"; import { chmod, cp, mkdir, readFile, rm, writeFile } from "node:fs/promises"; -import * as cache from "@actions/cache" -import * as glob from "@actions/glob" +import * as cache from "@actions/cache"; +import * as glob from "@actions/glob"; const token = core.getInput("fontist-token"); const octokit = token @@ -28,41 +28,54 @@ const version = semver.maxSatisfying( versions, versionRaw === "latest" ? "*" : versionRaw, )!; -core.debug(`Resolved version: v${version}`); +core.info(`Resolved version: v${version}`); if (!version) throw new DOMException(`${versionRaw} resolved to ${version}`); let found = tc.find("fontist", version); -let cacheHit = !!found +let cacheHit = !!found; if (!found) { - let cacheDir = join(process.env.RUNNER_TEMP!, Math.random().toString()); - await mkdir(cacheDir); - cacheDir = await tc.cacheDir(cacheDir, "fontist", version); - try { - await $({ - stdio: "inherit", - })`gem install fontist --version ${version} --install-dir ${join(cacheDir, "install-dir")} --bindir ${join(cacheDir, "bindir")}`; + const cacheDir = join(process.env.HOME!, ".fontist-tool-cache"); + const primaryKey = `fontist-${version}-tool-cache`; + const hitKey = core.getBooleanInput("cache") && await cache.restoreCache([cacheDir], primaryKey); + cacheHit ||= !!hitKey; + if (hitKey) { + found = cacheDir; + found = await tc.cacheDir(cacheDir, "fontist", version); + } else { + let cacheDir = join(process.env.RUNNER_TEMP!, Math.random().toString()); + await mkdir(cacheDir); + cacheDir = await tc.cacheDir(cacheDir, "fontist", version); + try { + await $({ + stdio: "inherit", + })`gem install fontist --version ${version} --install-dir ${join(cacheDir, "install-dir")} --bindir ${join(cacheDir, "bindir")}`; - await mkdir(join(cacheDir, "bin")); - const bash = `\ + await mkdir(join(cacheDir, "bin")); + + const bash = `\ #!/bin/bash export GEM_PATH=${join(cacheDir, "install-dir")} export GEM_HOME=${join(cacheDir, "install-dir")} -exec ${join(cacheDir, "bindir", "fontist")} "$@"` - const cmd = `\ -@echo off -set GEM_PATH=${join(cacheDir, "install-dir")} -set GEM_HOME=${join(cacheDir, "install-dir")} -${join(cacheDir, "bindir", "fontist")} %*` - await writeFile(join(cacheDir, "bin", "fontist"), bash) - await writeFile(join(cacheDir, "bin", "fontist.cmd"), cmd) - await chmod(join(cacheDir, "bin", "fontist"), 0o755) - await chmod(join(cacheDir, "bin", "fontist.cmd"), 0o755) - } catch (error) { - core.error(`Failure inside setup block. Removing tool cache folder.`); - await rm(cacheDir, { recursive: true, force: true }); - throw error; +exec ${join(cacheDir, "bindir", "fontist")} "$@"`; + await writeFile(join(cacheDir, "bin", "fontist"), bash); + await chmod(join(cacheDir, "bin", "fontist"), 0o755); + + const cmd = `\ +@echo off\r +set GEM_PATH=${join(cacheDir, "install-dir")}\r +set GEM_HOME=${join(cacheDir, "install-dir")}\r +${join(cacheDir, "bindir", "fontist")} %*`; + await writeFile(join(cacheDir, "bin", "fontist.cmd"), cmd); + } catch (error) { + core.error(`Failure inside setup block. Removing tool cache folder.`); + await rm(cacheDir, { recursive: true, force: true }); + throw error; + } + found = cacheDir; + if (core.getBooleanInput("cache")) { + await cache.saveCache([found], primaryKey); + } } - found = cacheDir; } core.addPath(join(found, "bin")); @@ -70,15 +83,15 @@ core.setOutput("fontist-version", version); core.info(`✅ Fontist v${version} installed!`); if (core.getBooleanInput("cache")) { - const cacheDir = join(process.env.HOME!, ".fontist") - const primaryKey = `fontist-home` - core.saveState("cache-primary-key", primaryKey) - const hitKey = await cache.restoreCache([cacheDir], primaryKey) - core.saveState("cache-hit", hitKey) - cacheHit ||= !!hitKey + const cacheDir = join(process.env.HOME!, ".fontist"); + const primaryKey = `fontist-home`; + core.saveState("cache-primary-key", primaryKey); + const hitKey = await cache.restoreCache([cacheDir], primaryKey); + core.saveState("cache-hit", hitKey); + cacheHit ||= !!hitKey; } -core.setOutput("cache-hit", cacheHit) +core.setOutput("cache-hit", cacheHit); -core.info(`Running 'fontist update'...`) +core.info(`Running 'fontist update'...`); await $({ stdio: "inherit" })`fontist update`; From 230264785a388b17c4e0972501b2e9ef4df01cd1 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Sat, 27 Jan 2024 01:23:51 +0000 Subject: [PATCH 31/37] version dep --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 25ad29d..7959385 100644 --- a/src/main.ts +++ b/src/main.ts @@ -84,7 +84,7 @@ core.info(`✅ Fontist v${version} installed!`); if (core.getBooleanInput("cache")) { const cacheDir = join(process.env.HOME!, ".fontist"); - const primaryKey = `fontist-home`; + const primaryKey = `fontist-${version}-home-fontist`; core.saveState("cache-primary-key", primaryKey); const hitKey = await cache.restoreCache([cacheDir], primaryKey); core.saveState("cache-hit", hitKey); From b9549943d8b7fddae3c2e45c1417aa37d102c095 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Sat, 27 Jan 2024 01:28:29 +0000 Subject: [PATCH 32/37] process,exit() --- src/main.ts | 4 +++- src/post.ts | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 7959385..14690ea 100644 --- a/src/main.ts +++ b/src/main.ts @@ -48,7 +48,7 @@ if (!found) { try { await $({ stdio: "inherit", - })`gem install fontist --version ${version} --install-dir ${join(cacheDir, "install-dir")} --bindir ${join(cacheDir, "bindir")}`; + })`gem install fontist --version ${version} --no-document --install-dir ${join(cacheDir, "install-dir")} --bindir ${join(cacheDir, "bindir")}`; await mkdir(join(cacheDir, "bin")); @@ -95,3 +95,5 @@ core.setOutput("cache-hit", cacheHit); core.info(`Running 'fontist update'...`); await $({ stdio: "inherit" })`fontist update`; + +process.exit(); diff --git a/src/post.ts b/src/post.ts index 9781e0d..efa665c 100644 --- a/src/post.ts +++ b/src/post.ts @@ -11,3 +11,5 @@ if (core.getBooleanInput("cache")) { core.info(`Saving ${cacheDir} with key ${primaryKey}`); await cache.saveCache([cacheDir], primaryKey); } + +process.exit(); From 8f7f32b37bb5e4060801db88bea40f038f1c6f2b Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Sat, 27 Jan 2024 02:21:34 +0000 Subject: [PATCH 33/37] reorganize with more logging --- src/main.ts | 93 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 36 deletions(-) diff --git a/src/main.ts b/src/main.ts index 14690ea..bb3d291 100644 --- a/src/main.ts +++ b/src/main.ts @@ -31,50 +31,70 @@ const version = semver.maxSatisfying( core.info(`Resolved version: v${version}`); if (!version) throw new DOMException(`${versionRaw} resolved to ${version}`); -let found = tc.find("fontist", version); -let cacheHit = !!found; -if (!found) { - const cacheDir = join(process.env.HOME!, ".fontist-tool-cache"); - const primaryKey = `fontist-${version}-tool-cache`; - const hitKey = core.getBooleanInput("cache") && await cache.restoreCache([cacheDir], primaryKey); - cacheHit ||= !!hitKey; - if (hitKey) { - found = cacheDir; - found = await tc.cacheDir(cacheDir, "fontist", version); - } else { - let cacheDir = join(process.env.RUNNER_TEMP!, Math.random().toString()); - await mkdir(cacheDir); - cacheDir = await tc.cacheDir(cacheDir, "fontist", version); - try { - await $({ - stdio: "inherit", - })`gem install fontist --version ${version} --no-document --install-dir ${join(cacheDir, "install-dir")} --bindir ${join(cacheDir, "bindir")}`; - - await mkdir(join(cacheDir, "bin")); - - const bash = `\ +const workflowCache = core.getBooleanInput("cache"); +if (workflowCache) { + core.info(`Using @actions/cache`); +} + +let found: string; +let cacheHit = false; +install_fontist: { + found = tc.find("fontist", version); + if (found) { + core.info(`Found Fontist in tool cache: ${found}`); + cacheHit = true; + break install_fontist; + } + + let cacheDir = join(process.env.RUNNER_TEMP!, Math.random().toString()); + await mkdir(cacheDir); + cacheDir = await tc.cacheDir(cacheDir, "fontist", version); + try { + if (workflowCache) { + const primaryKey = `fontist-${version}-tool-cache`; + core.info(`Attempting to restore from ${primaryKey}`) + const hitKey = await cache.restoreCache([cacheDir], primaryKey); + if (hitKey) { + core.info(`Restored Fontist from workflow cache: ${cacheDir}`) + found = cacheDir; + cacheHit = true; + break install_fontist; + } + } + + core.info(`Using RubyGems to install Fontist v${version}...`) + core.info(`Installing to ${join(cacheDir, "install-dir")}`) + core.info(`Installing binaries to ${join(cacheDir, "bindir")}`) + await $({ + stdio: "inherit", + })`gem install fontist --version ${version} --no-document --install-dir ${join(cacheDir, "install-dir")} --bindir ${join(cacheDir, "bindir")}`; + + core.info(`Creating wrapper scripts in ${join(cacheDir, "bin")}...`) + await mkdir(join(cacheDir, "bin")); + + const bash = `\ #!/bin/bash export GEM_PATH=${join(cacheDir, "install-dir")} export GEM_HOME=${join(cacheDir, "install-dir")} exec ${join(cacheDir, "bindir", "fontist")} "$@"`; - await writeFile(join(cacheDir, "bin", "fontist"), bash); - await chmod(join(cacheDir, "bin", "fontist"), 0o755); + await writeFile(join(cacheDir, "bin", "fontist"), bash); + await chmod(join(cacheDir, "bin", "fontist"), 0o755); - const cmd = `\ + const cmd = `\ @echo off\r set GEM_PATH=${join(cacheDir, "install-dir")}\r set GEM_HOME=${join(cacheDir, "install-dir")}\r ${join(cacheDir, "bindir", "fontist")} %*`; - await writeFile(join(cacheDir, "bin", "fontist.cmd"), cmd); - } catch (error) { - core.error(`Failure inside setup block. Removing tool cache folder.`); - await rm(cacheDir, { recursive: true, force: true }); - throw error; - } - found = cacheDir; - if (core.getBooleanInput("cache")) { - await cache.saveCache([found], primaryKey); - } + await writeFile(join(cacheDir, "bin", "fontist.cmd"), cmd); + + } catch (error) { + await rm(cacheDir, { recursive: true, force: true }); + throw error; + } + + if (workflowCache) { + core.info(`Trying to stash ${cacheDir} in workflow cache`) + await cache.saveCache([cacheDir], `fontist-${version}-tool-cache`); } } @@ -82,10 +102,11 @@ core.addPath(join(found, "bin")); core.setOutput("fontist-version", version); core.info(`✅ Fontist v${version} installed!`); -if (core.getBooleanInput("cache")) { +if (workflowCache) { const cacheDir = join(process.env.HOME!, ".fontist"); const primaryKey = `fontist-${version}-home-fontist`; core.saveState("cache-primary-key", primaryKey); + core.info(`Attempting to restore ${cacheDir} from ${primaryKey}`); const hitKey = await cache.restoreCache([cacheDir], primaryKey); core.saveState("cache-hit", hitKey); cacheHit ||= !!hitKey; From 6b38434a47dddc64ed81663283ab63c2a3560e52 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Sat, 27 Jan 2024 02:52:00 +0000 Subject: [PATCH 34/37] try with cache-dependency-path? --- README.md | 8 ++++++-- action.yml | 2 ++ src/main.ts | 22 ++++++++++++++++------ src/post.ts | 11 ++++++++--- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index ac041b2..36abfc7 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ 🟦 Works with Windows \ 🐧 Works with Ubuntu \ 🍎 Works with macOS \ -⚡ Caches installation in `$RUNNER_TOOL_CACHE` +⚡ Caches installation in `$RUNNER_TOOL_CACHE` and/ior the workflow cache \ +📐 Caches `~/.fontist` font installs by default using `manifest.yml` ## Usage @@ -55,7 +56,10 @@ jobs: ![Node.js](https://img.shields.io/static/v1?style=for-the-badge&message=Node.js&color=339933&logo=Node.js&logoColor=FFFFFF&label=) ![Ruby](https://img.shields.io/static/v1?style=for-the-badge&message=Ruby&color=CC342D&logo=Ruby&logoColor=FFFFFF&label=) -This action uses a hack to install Ruby using [ruby/setup-ruby](https://github.com/ruby/setup-ruby) but without adding it to the `$PATH`. Then, we run `gem install fontist` using that un-`$PATH`-ed Ruby version and expose only the `fontist` executable. The action is bundled using [Bun](https://bun.sh/) to a single file on each GitHub release. +This action tries to restore the result of `gem install fontist` from both the `$RUNNER_TOOL_CACHE` as well as the workflow cache via [@actions/cache](https://www.npmjs.com/package/@actions/cache). + +**How do I test it?** \ +Open a PR (even a draft one works) and some magic GitHub Actions will run to test your changes. ## Contributions diff --git a/action.yml b/action.yml index 368071a..81c27a3 100644 --- a/action.yml +++ b/action.yml @@ -14,6 +14,8 @@ inputs: default: ${{ github.server_url == 'https://github.com' && github.token || '' }} cache: default: true + cache-dependency-path: + default: manifest.y{a,}ml outputs: fontist-version: diff --git a/src/main.ts b/src/main.ts index bb3d291..f6f0642 100644 --- a/src/main.ts +++ b/src/main.ts @@ -104,12 +104,21 @@ core.info(`✅ Fontist v${version} installed!`); if (workflowCache) { const cacheDir = join(process.env.HOME!, ".fontist"); - const primaryKey = `fontist-${version}-home-fontist`; - core.saveState("cache-primary-key", primaryKey); - core.info(`Attempting to restore ${cacheDir} from ${primaryKey}`); - const hitKey = await cache.restoreCache([cacheDir], primaryKey); - core.saveState("cache-hit", hitKey); - cacheHit ||= !!hitKey; + const hash = await glob.hashFiles(core.getInput("cache-dependency-path")) + if (hash) { + const primaryKey = `fontist-${version}-home-fontist-${hash}`; + core.saveState("cache-primary-key", primaryKey); + core.info(`Attempting to restore ${cacheDir} from ${primaryKey}`); + const hitKey = await cache.restoreCache([cacheDir], primaryKey); + core.saveState("cache-hit", hitKey); + if (hitKey) { + core.info(`Restored ${cacheDir} from workflow cache: ${hitKey}`); + cacheHit = true; + } + } else { + core.info(`No manifest files found, skipping cache restore`); + core.info(`To enable cache, set the cache-dependency-path input OR create a manifest.yml file`) + } } core.setOutput("cache-hit", cacheHit); @@ -117,4 +126,5 @@ core.setOutput("cache-hit", cacheHit); core.info(`Running 'fontist update'...`); await $({ stdio: "inherit" })`fontist update`; +// This is an issue with '@actions/cache' somehow? https://github.com/actions/toolkit/issues/658 process.exit(); diff --git a/src/post.ts b/src/post.ts index efa665c..04012cd 100644 --- a/src/post.ts +++ b/src/post.ts @@ -7,9 +7,14 @@ import { join } from "node:path"; if (core.getBooleanInput("cache")) { const cacheDir = join(process.env.HOME!, ".fontist"); const primaryKey = core.getState("cache-primary-key"); - const hitKey = core.getState("cache-hit-key"); - core.info(`Saving ${cacheDir} with key ${primaryKey}`); - await cache.saveCache([cacheDir], primaryKey); + if (primaryKey) { + const hitKey = core.getState("cache-hit-key"); + core.info(`Saving ${cacheDir} with key ${primaryKey}`); + await cache.saveCache([cacheDir], primaryKey); + } else { + core.info(`No cache key found, skipping cache save`) + } } +// This is an issue with '@actions/cache' somehow? https://github.com/actions/toolkit/issues/658 process.exit(); From a76f9b92c153e5f9e3b06752b7fb7a4de6f0bfa0 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Sat, 27 Jan 2024 18:48:31 +0000 Subject: [PATCH 35/37] add docs for cache inputs --- README.md | 6 +++++- action.yml | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 36abfc7..31918ef 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,10 @@ jobs: - **`fontist-token`:** The GitHub token to use when fetching the version list from fontist/fontist. You shouldn't have to touch this. The default is the `github.token` if you're on github.com or unauthenticated (rate limited) if you're not on github.com. +- **`cache`:** Whether or not to use [@actions/cache](https://www.npmjs.com/package/@actions/cache) to cache things in the GitHub workflow cache. This is enabled by default. + +- **`cache-dependency-path`:** A multiline list of globs to use to derive the `~/.fontist` cache key. The default is `manifest.yml` and `manifest.yaml`. If no files are matched at runtime then the `~/.fontist` folder will not be cached. + ### Outputs - **`fontist-version`:** The version of Fontist that was installed. This will be something like `1.10.0` or similar. @@ -56,7 +60,7 @@ jobs: ![Node.js](https://img.shields.io/static/v1?style=for-the-badge&message=Node.js&color=339933&logo=Node.js&logoColor=FFFFFF&label=) ![Ruby](https://img.shields.io/static/v1?style=for-the-badge&message=Ruby&color=CC342D&logo=Ruby&logoColor=FFFFFF&label=) -This action tries to restore the result of `gem install fontist` from both the `$RUNNER_TOOL_CACHE` as well as the workflow cache via [@actions/cache](https://www.npmjs.com/package/@actions/cache). +This action tries to restore the result of `gem install fontist` from both the `$RUNNER_TOOL_CACHE` as well as the workflow cache via [@actions/cache](https://www.npmjs.com/package/@actions/cache). It then tries to restore the `~/.fontist` folder local cache from the workflow cache. **How do I test it?** \ Open a PR (even a draft one works) and some magic GitHub Actions will run to test your changes. diff --git a/action.yml b/action.yml index 81c27a3..2b773ab 100644 --- a/action.yml +++ b/action.yml @@ -13,8 +13,10 @@ inputs: description: The GitHub token to use when fetching the version list from fontist/fontist. You shouldn't have to touch this. The default is the 'github.token' if you're on github.com or unauthenticated (rate limited) if you're not on github.com. default: ${{ github.server_url == 'https://github.com' && github.token || '' }} cache: + description: Whether or not to use @actions/cache to cache things in the GitHub workflow cache. This is enabled by default. default: true cache-dependency-path: + description: A multiline list of globs to use to derive the '~/.fontist' cache key. The default is 'manifest.yml' and 'manifest.yaml'. If no files are matched at runtime then the '~/.fontist' folder will not be cached. default: manifest.y{a,}ml outputs: From ac109825ffcc9581ab509f50d0e858af33ab95d4 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Sat, 27 Jan 2024 19:00:48 +0000 Subject: [PATCH 36/37] add note about bun on windows --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 31918ef..a2a479d 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ This action tries to restore the result of `gem install fontist` from both the ` **How do I test it?** \ Open a PR (even a draft one works) and some magic GitHub Actions will run to test your changes. +Note that since [Bun doesn't support Windows yet](https://github.com/oven-sh/bun/issues/43) we can't run the `bun build` command on Windows runners. Don't worry! The action should still work ok since Bun is only used for the build step; it runs using `node ` via `using: node20` in both testing and releases. Once Bun adds Windows support remember to add back the Windows tests. 😉 + ## Contributions This GitHub Action was originally created by @jcbhmr for the From 78f46a37ed9e74e81d107320fea5b13094d676b5 Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Tue, 30 Jan 2024 18:48:04 +0800 Subject: [PATCH 37/37] Update README.md on `cache-hit` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a2a479d..772ef84 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ jobs: - **`fontist-version`:** The version of Fontist that was installed. This will be something like `1.10.0` or similar. -- **`cache-hit`:** Whether or not Fontist was restored from the runner's cache or download anew. +- **`cache-hit`:** Whether or not Fontist was restored from the runner's cache or newly downloaded. ## Development