rtx -> mise

This commit is contained in:
Jeff Dickey 2024-01-02 16:16:49 -06:00
parent b2bd646a01
commit 2c307d8ed6
No known key found for this signature in database
GPG key ID: 584DADE86724B407
10 changed files with 118 additions and 118 deletions

View file

@ -40,8 +40,8 @@ jobs:
tool_versions: ${{ matrix.tool_versions }} tool_versions: ${{ matrix.tool_versions }}
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: rtx --version - run: mise --version
- run: rtx exec -- node --version - run: mise exec -- node --version
- run: which node - run: which node
- run: node -v - run: node -v
specific_version: specific_version:
@ -51,9 +51,9 @@ jobs:
- uses: ./ - uses: ./
with: with:
cache_save: ${{ github.ref_name == 'main' }} cache_save: ${{ github.ref_name == 'main' }}
cache_key_prefix: rtx-v1 cache_key_prefix: mise-v1
version: 2023.12.23 version: 2023.12.23
rtx_toml: | mise_toml: |
[tools] [tools]
bun = "1" bun = "1"
- run: which bun - run: which bun

View file

@ -14,17 +14,17 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: jdx/rtx-action@v1 - uses: jdx/mise-action@v1
with: with:
version: 2023.12.0 # [default: latest] rtx version to install version: 2023.12.0 # [default: latest] mise version to install
install: true # [default: true] run `rtx install` install: true # [default: true] run `mise install`
cache: true # [default: true] cache rtx using GitHub's cache cache: true # [default: true] cache mise using GitHub's cache
# automatically write this .tool-versions file # automatically write this .tool-versions file
experimental: true # [default: false] enable experimental features experimental: true # [default: false] enable experimental features
tool_versions: | tool_versions: |
shellcheck 0.9.0 shellcheck 0.9.0
# or, if you prefer .rtx.toml format: # or, if you prefer .mise.toml format:
rtx_toml: | mise_toml: |
[tools] [tools]
shellcheck = "0.9.0" shellcheck = "0.9.0"
- run: shellcheck scripts/*.sh - run: shellcheck scripts/*.sh
@ -32,19 +32,19 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: jdx/rtx-action@v1 - uses: jdx/mise-action@v1
# .tool-versions will be read from repo root # .tool-versions will be read from repo root
- run: node ./my_app.js - run: node ./my_app.js
``` ```
Alternatively, rtx is easy to use in GitHub Actions even without this: Alternatively, mise is easy to use in GitHub Actions even without this:
```yaml ```yaml
jobs: jobs:
build: build:
steps: steps:
- run: | - run: |
curl https://rtx.jdx.dev/install.sh | sh curl https://mise.jdx.dev/install.sh | sh
echo "$HOME/.local/share/rtx/bin" >> $GITHUB_PATH echo "$HOME/.local/share/mise/bin" >> $GITHUB_PATH
echo "$HOME/.local/share/rtx/shims" >> $GITHUB_PATH echo "$HOME/.local/share/mise/shims" >> $GITHUB_PATH
``` ```

View file

@ -1,5 +1,5 @@
name: rtx action name: mise action
description: Actions for working with rtx runtime manager description: Actions for working with mise runtime manager
author: Jeff Dickey <@jdx> author: Jeff Dickey <@jdx>
branding: branding:
icon: arrow-down-circle icon: arrow-down-circle
@ -7,27 +7,27 @@ branding:
inputs: inputs:
version: version:
required: false required: false
description: The version of rtx to use. If not specified, will use the latest release. description: The version of mise to use. If not specified, will use the latest release.
rtx_dir: mise_dir:
required: false required: false
description: | description: |
The directory that rtx will be installed to, defaults to $HOME/.local/share/rtx The directory that mise will be installed to, defaults to $HOME/.local/share/mise
Or $XDG_DATA_HOME/rtx if $XDG_DATA_HOME is set. Or $XDG_DATA_HOME/mise if $XDG_DATA_HOME is set.
Or $RTX_DATA_DIR if $RTX_DATA_DIR is set. Or $MISE_DATA_DIR if $MISE_DATA_DIR is set.
tool_versions: tool_versions:
required: false required: false
description: If present, this value will be written to the .tool-versions file description: If present, this value will be written to the .tool-versions file
rtx_toml: mise_toml:
required: false required: false
description: If present, this value will be written to the .rtx.toml file description: If present, this value will be written to the .mise.toml file
install: install:
required: false required: false
default: "true" default: "true"
description: if false, will not run `rtx install` description: if false, will not run `mise install`
install_dir: install_dir:
required: false required: false
default: "." default: "."
description: The directory that `rtx install` will be executed in description: The directory that `mise install` will be executed in
cache: cache:
required: false required: false
default: "true" default: "true"
@ -38,7 +38,7 @@ inputs:
description: if false, action will not write to cache description: if false, action will not write to cache
cache_key_prefix: cache_key_prefix:
required: false required: false
default: "rtx-v0" default: "mise-v0"
description: The prefix key to use for the cache, change this to invalidate the cache description: The prefix key to use for the cache, change this to invalidate the cache
experimental: experimental:
required: false required: false

82
dist/index.js generated vendored
View file

@ -82932,17 +82932,17 @@ const utils_1 = __nccwpck_require__(1314);
async function run() { async function run() {
try { try {
await setToolVersions(); await setToolVersions();
await setRtxToml(); await setMiseToml();
if (core.getBooleanInput('cache')) { if (core.getBooleanInput('cache')) {
await restoreRTXCache(); await restoreMiseCache();
} }
else { else {
core.setOutput('cache-hit', false); core.setOutput('cache-hit', false);
} }
const version = core.getInput('version'); const version = core.getInput('version');
await setupRTX(version); await setupMise(version);
await setEnvVars(); await setEnvVars();
await testRTX(); await testMise();
if (core.getBooleanInput('install')) { if (core.getBooleanInput('install')) {
await rtxInstall(); await rtxInstall();
} }
@ -82962,46 +82962,46 @@ async function setEnvVars() {
core.exportVariable(k, v); core.exportVariable(k, v);
} }
}; };
set('RTX_TRUSTED_CONFIG_PATHS', process.cwd()); set('MISE_TRUSTED_CONFIG_PATHS', process.cwd());
set('RTX_YES', '1'); set('MISE_YES', '1');
set('RTX_EXPERIMENTAL', getExperimental() ? '1' : '0'); set('MISE_EXPERIMENTAL', getExperimental() ? '1' : '0');
const shimsDir = path.join((0, utils_1.rtxDir)(), 'shims'); const shimsDir = path.join((0, utils_1.miseDir)(), 'shims');
core.info(`Adding ${shimsDir} to PATH`); core.info(`Adding ${shimsDir} to PATH`);
core.addPath(shimsDir); core.addPath(shimsDir);
} }
async function restoreRTXCache() { async function restoreMiseCache() {
core.startGroup('Restoring rtx cache'); core.startGroup('Restoring mise cache');
const cachePath = (0, utils_1.rtxDir)(); const cachePath = (0, utils_1.miseDir)();
const fileHash = await glob.hashFiles(`**/.tool-versions\n**/.rtx.toml`); const fileHash = await glob.hashFiles(`**/.tool-versions\n**/.mise.toml`);
const prefix = core.getInput('cache_key_prefix') || 'rtx-v0'; const prefix = core.getInput('cache_key_prefix') || 'mise-v0';
const primaryKey = `${prefix}-${getOS()}-${os.arch()}-${fileHash}`; const primaryKey = `${prefix}-${getOS()}-${os.arch()}-${fileHash}`;
core.saveState('CACHE', core.getBooleanInput('cache_save') ?? true); core.saveState('CACHE', core.getBooleanInput('cache_save') ?? true);
core.saveState('PRIMARY_KEY', primaryKey); core.saveState('PRIMARY_KEY', primaryKey);
core.saveState('RTX_DIR', cachePath); core.saveState('MISE_DIR', cachePath);
const cacheKey = await cache.restoreCache([cachePath], primaryKey); const cacheKey = await cache.restoreCache([cachePath], primaryKey);
core.setOutput('cache-hit', Boolean(cacheKey)); core.setOutput('cache-hit', Boolean(cacheKey));
if (!cacheKey) { if (!cacheKey) {
core.info(`rtx cache not found for ${primaryKey}`); core.info(`mise cache not found for ${primaryKey}`);
return; return;
} }
core.saveState('CACHE_KEY', cacheKey); core.saveState('CACHE_KEY', cacheKey);
core.info(`rtx cache restored from key: ${cacheKey}`); core.info(`mise cache restored from key: ${cacheKey}`);
} }
async function setupRTX(version) { async function setupMise(version) {
core.startGroup(version ? `Setup rtx@${version}` : 'Setup rtx'); core.startGroup(version ? `Setup mise@${version}` : 'Setup mise');
const rtxBinDir = path.join((0, utils_1.rtxDir)(), 'bin'); const miseBinDir = path.join((0, utils_1.miseDir)(), 'bin');
const url = version const url = version
? `https://rtx.jdx.dev/v${version}/rtx-v${version}-${getOS()}-${os.arch()}` ? `https://mise.jdx.dev/v${version}/mise-v${version}-${getOS()}-${os.arch()}`
: `https://rtx.jdx.dev/rtx-latest-${getOS()}-${os.arch()}`; : `https://mise.jdx.dev/mise-latest-${getOS()}-${os.arch()}`;
await fs.promises.mkdir(rtxBinDir, { recursive: true }); await fs.promises.mkdir(miseBinDir, { recursive: true });
await exec.exec('curl', [ await exec.exec('curl', [
'-fsSL', '-fsSL',
url, url,
'--output', '--output',
path.join(rtxBinDir, 'rtx') path.join(miseBinDir, 'mise')
]); ]);
await exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')]); await exec.exec('chmod', ['+x', path.join(miseBinDir, 'mise')]);
core.addPath(rtxBinDir); core.addPath(miseBinDir);
} }
function getExperimental() { function getExperimental() {
const experimentalString = core.getInput('experimental'); const experimentalString = core.getInput('experimental');
@ -83013,10 +83013,10 @@ async function setToolVersions() {
await writeFile('.tool-versions', toolVersions); await writeFile('.tool-versions', toolVersions);
} }
} }
async function setRtxToml() { async function setMiseToml() {
const toml = core.getInput('rtx_toml'); const toml = core.getInput('mise_toml');
if (toml) { if (toml) {
await writeFile('.rtx.toml', toml); await writeFile('.mise.toml', toml);
} }
} }
function getOS() { function getOS() {
@ -83027,11 +83027,11 @@ function getOS() {
return process.platform; return process.platform;
} }
} }
const testRTX = async () => rtx(['--version']); const testMise = async () => mise(['--version']);
const rtxInstall = async () => rtx(['install']); const rtxInstall = async () => mise(['install']);
const rtx = async (args) => core.group(`Running rtx ${args.join(' ')}`, async () => { const mise = async (args) => core.group(`Running mise ${args.join(' ')}`, async () => {
const cwd = core.getInput('install_dir') || process.cwd(); const cwd = core.getInput('install_dir') || process.cwd();
return exec.exec('rtx', args, { cwd }); return exec.exec('mise', args, { cwd });
}); });
const writeFile = async (p, body) => core.group(`Writing ${p}`, async () => { const writeFile = async (p, body) => core.group(`Writing ${p}`, async () => {
core.info(`Body:\n${body}`); core.info(`Body:\n${body}`);
@ -83071,22 +83071,22 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.rtxDir = void 0; exports.miseDir = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const os = __importStar(__nccwpck_require__(2037)); const os = __importStar(__nccwpck_require__(2037));
const path = __importStar(__nccwpck_require__(1017)); const path = __importStar(__nccwpck_require__(1017));
function rtxDir() { function miseDir() {
const dir = core.getState('RTX_DIR'); const dir = core.getState('MISE_DIR');
if (dir) if (dir)
return dir; return dir;
const { RTX_DATA_DIR, XDG_DATA_HOME } = process.env; const { MISE_DATA_DIR, XDG_DATA_HOME } = process.env;
if (RTX_DATA_DIR) if (MISE_DATA_DIR)
return RTX_DATA_DIR; return MISE_DATA_DIR;
if (XDG_DATA_HOME) if (XDG_DATA_HOME)
return path.join(XDG_DATA_HOME, 'rtx'); return path.join(XDG_DATA_HOME, 'mise');
return path.join(os.homedir(), '.local/share/rtx'); return path.join(os.homedir(), '.local/share/mise');
} }
exports.rtxDir = rtxDir; exports.miseDir = miseDir;
/***/ }), /***/ }),

4
package-lock.json generated
View file

@ -1,11 +1,11 @@
{ {
"name": "rtx-action", "name": "mise-action",
"version": "1.3.2", "version": "1.3.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "rtx-action", "name": "mise-action",
"version": "1.3.2", "version": "1.3.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {

View file

@ -1,16 +1,16 @@
{ {
"name": "rtx-action", "name": "mise-action",
"description": "rtx tool setup action", "description": "mise tool setup action",
"version": "1.3.2", "version": "1.3.2",
"author": "jdx", "author": "jdx",
"private": true, "private": true,
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/jdx/rtx-action.git" "url": "git+https://github.com/jdx/mise-action.git"
}, },
"keywords": [ "keywords": [
"actions", "actions",
"rtx", "mise",
"setup" "setup"
], ],
"exports": { "exports": {

View file

@ -1,18 +1,18 @@
import * as cache from '@actions/cache' import * as cache from '@actions/cache'
import * as core from '@actions/core' import * as core from '@actions/core'
import * as fs from 'fs' import * as fs from 'fs'
import { rtxDir } from './utils' import { miseDir } from './utils'
export async function run(): Promise<void> { export async function run(): Promise<void> {
try { try {
await cacheRTXTools() await cacheMiseTools()
} catch (error) { } catch (error) {
if (error instanceof Error) core.setFailed(error.message) if (error instanceof Error) core.setFailed(error.message)
else throw error else throw error
} }
} }
async function cacheRTXTools(): Promise<void> { async function cacheMiseTools(): Promise<void> {
if (!core.getState('CACHE')) { if (!core.getState('CACHE')) {
core.info('Skipping saving cache') core.info('Skipping saving cache')
return return
@ -20,7 +20,7 @@ async function cacheRTXTools(): Promise<void> {
const state = core.getState('CACHE_KEY') const state = core.getState('CACHE_KEY')
const primaryKey = core.getState('PRIMARY_KEY') const primaryKey = core.getState('PRIMARY_KEY')
const cachePath = rtxDir() const cachePath = miseDir()
if (!fs.existsSync(cachePath)) { if (!fs.existsSync(cachePath)) {
throw new Error(`Cache folder path does not exist on disk: ${cachePath}`) throw new Error(`Cache folder path does not exist on disk: ${cachePath}`)

View file

@ -5,23 +5,23 @@ import * as glob from '@actions/glob'
import * as fs from 'fs' import * as fs from 'fs'
import * as os from 'os' import * as os from 'os'
import * as path from 'path' import * as path from 'path'
import { rtxDir } from './utils' import { miseDir } from './utils'
async function run(): Promise<void> { async function run(): Promise<void> {
try { try {
await setToolVersions() await setToolVersions()
await setRtxToml() await setMiseToml()
if (core.getBooleanInput('cache')) { if (core.getBooleanInput('cache')) {
await restoreRTXCache() await restoreMiseCache()
} else { } else {
core.setOutput('cache-hit', false) core.setOutput('cache-hit', false)
} }
const version = core.getInput('version') const version = core.getInput('version')
await setupRTX(version) await setupMise(version)
await setEnvVars() await setEnvVars()
await testRTX() await testMise()
if (core.getBooleanInput('install')) { if (core.getBooleanInput('install')) {
await rtxInstall() await rtxInstall()
} }
@ -39,53 +39,53 @@ async function setEnvVars(): Promise<void> {
core.exportVariable(k, v) core.exportVariable(k, v)
} }
} }
set('RTX_TRUSTED_CONFIG_PATHS', process.cwd()) set('MISE_TRUSTED_CONFIG_PATHS', process.cwd())
set('RTX_YES', '1') set('MISE_YES', '1')
set('RTX_EXPERIMENTAL', getExperimental() ? '1' : '0') set('MISE_EXPERIMENTAL', getExperimental() ? '1' : '0')
const shimsDir = path.join(rtxDir(), 'shims') const shimsDir = path.join(miseDir(), 'shims')
core.info(`Adding ${shimsDir} to PATH`) core.info(`Adding ${shimsDir} to PATH`)
core.addPath(shimsDir) core.addPath(shimsDir)
} }
async function restoreRTXCache(): Promise<void> { async function restoreMiseCache(): Promise<void> {
core.startGroup('Restoring rtx cache') core.startGroup('Restoring mise cache')
const cachePath = rtxDir() const cachePath = miseDir()
const fileHash = await glob.hashFiles(`**/.tool-versions\n**/.rtx.toml`) const fileHash = await glob.hashFiles(`**/.tool-versions\n**/.mise.toml`)
const prefix = core.getInput('cache_key_prefix') || 'rtx-v0' const prefix = core.getInput('cache_key_prefix') || 'mise-v0'
const primaryKey = `${prefix}-${getOS()}-${os.arch()}-${fileHash}` const primaryKey = `${prefix}-${getOS()}-${os.arch()}-${fileHash}`
core.saveState('CACHE', core.getBooleanInput('cache_save') ?? true) core.saveState('CACHE', core.getBooleanInput('cache_save') ?? true)
core.saveState('PRIMARY_KEY', primaryKey) core.saveState('PRIMARY_KEY', primaryKey)
core.saveState('RTX_DIR', cachePath) core.saveState('MISE_DIR', cachePath)
const cacheKey = await cache.restoreCache([cachePath], primaryKey) const cacheKey = await cache.restoreCache([cachePath], primaryKey)
core.setOutput('cache-hit', Boolean(cacheKey)) core.setOutput('cache-hit', Boolean(cacheKey))
if (!cacheKey) { if (!cacheKey) {
core.info(`rtx cache not found for ${primaryKey}`) core.info(`mise cache not found for ${primaryKey}`)
return return
} }
core.saveState('CACHE_KEY', cacheKey) core.saveState('CACHE_KEY', cacheKey)
core.info(`rtx cache restored from key: ${cacheKey}`) core.info(`mise cache restored from key: ${cacheKey}`)
} }
async function setupRTX(version: string | undefined): Promise<void> { async function setupMise(version: string | undefined): Promise<void> {
core.startGroup(version ? `Setup rtx@${version}` : 'Setup rtx') core.startGroup(version ? `Setup mise@${version}` : 'Setup mise')
const rtxBinDir = path.join(rtxDir(), 'bin') const miseBinDir = path.join(miseDir(), 'bin')
const url = version const url = version
? `https://rtx.jdx.dev/v${version}/rtx-v${version}-${getOS()}-${os.arch()}` ? `https://mise.jdx.dev/v${version}/mise-v${version}-${getOS()}-${os.arch()}`
: `https://rtx.jdx.dev/rtx-latest-${getOS()}-${os.arch()}` : `https://mise.jdx.dev/mise-latest-${getOS()}-${os.arch()}`
await fs.promises.mkdir(rtxBinDir, { recursive: true }) await fs.promises.mkdir(miseBinDir, { recursive: true })
await exec.exec('curl', [ await exec.exec('curl', [
'-fsSL', '-fsSL',
url, url,
'--output', '--output',
path.join(rtxBinDir, 'rtx') path.join(miseBinDir, 'mise')
]) ])
await exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')]) await exec.exec('chmod', ['+x', path.join(miseBinDir, 'mise')])
core.addPath(rtxBinDir) core.addPath(miseBinDir)
} }
function getExperimental(): boolean { function getExperimental(): boolean {
@ -100,10 +100,10 @@ async function setToolVersions(): Promise<void> {
} }
} }
async function setRtxToml(): Promise<void> { async function setMiseToml(): Promise<void> {
const toml = core.getInput('rtx_toml') const toml = core.getInput('mise_toml')
if (toml) { if (toml) {
await writeFile('.rtx.toml', toml) await writeFile('.mise.toml', toml)
} }
} }
@ -116,12 +116,12 @@ function getOS(): string {
} }
} }
const testRTX = async (): Promise<number> => rtx(['--version']) const testMise = async (): Promise<number> => mise(['--version'])
const rtxInstall = async (): Promise<number> => rtx(['install']) const rtxInstall = async (): Promise<number> => mise(['install'])
const rtx = async (args: string[]): Promise<number> => const mise = async (args: string[]): Promise<number> =>
core.group(`Running rtx ${args.join(' ')}`, async () => { core.group(`Running mise ${args.join(' ')}`, async () => {
const cwd = core.getInput('install_dir') || process.cwd() const cwd = core.getInput('install_dir') || process.cwd()
return exec.exec('rtx', args, { cwd }) return exec.exec('mise', args, { cwd })
}) })
const writeFile = async (p: fs.PathLike, body: string): Promise<void> => const writeFile = async (p: fs.PathLike, body: string): Promise<void> =>

View file

@ -2,13 +2,13 @@ import * as core from '@actions/core'
import * as os from 'os' import * as os from 'os'
import * as path from 'path' import * as path from 'path'
export function rtxDir(): string { export function miseDir(): string {
const dir = core.getState('RTX_DIR') const dir = core.getState('MISE_DIR')
if (dir) return dir if (dir) return dir
const { RTX_DATA_DIR, XDG_DATA_HOME } = process.env const { MISE_DATA_DIR, XDG_DATA_HOME } = process.env
if (RTX_DATA_DIR) return RTX_DATA_DIR if (MISE_DATA_DIR) return MISE_DATA_DIR
if (XDG_DATA_HOME) return path.join(XDG_DATA_HOME, 'rtx') if (XDG_DATA_HOME) return path.join(XDG_DATA_HOME, 'mise')
return path.join(os.homedir(), '.local/share/rtx') return path.join(os.homedir(), '.local/share/mise')
} }