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

View file

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

View file

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

82
dist/index.js generated vendored
View file

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

View file

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

View file

@ -1,18 +1,18 @@
import * as cache from '@actions/cache'
import * as core from '@actions/core'
import * as fs from 'fs'
import { rtxDir } from './utils'
import { miseDir } from './utils'
export async function run(): Promise<void> {
try {
await cacheRTXTools()
await cacheMiseTools()
} catch (error) {
if (error instanceof Error) core.setFailed(error.message)
else throw error
}
}
async function cacheRTXTools(): Promise<void> {
async function cacheMiseTools(): Promise<void> {
if (!core.getState('CACHE')) {
core.info('Skipping saving cache')
return
@ -20,7 +20,7 @@ async function cacheRTXTools(): Promise<void> {
const state = core.getState('CACHE_KEY')
const primaryKey = core.getState('PRIMARY_KEY')
const cachePath = rtxDir()
const cachePath = miseDir()
if (!fs.existsSync(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 os from 'os'
import * as path from 'path'
import { rtxDir } from './utils'
import { miseDir } from './utils'
async function run(): Promise<void> {
try {
await setToolVersions()
await setRtxToml()
await setMiseToml()
if (core.getBooleanInput('cache')) {
await restoreRTXCache()
await restoreMiseCache()
} else {
core.setOutput('cache-hit', false)
}
const version = core.getInput('version')
await setupRTX(version)
await setupMise(version)
await setEnvVars()
await testRTX()
await testMise()
if (core.getBooleanInput('install')) {
await rtxInstall()
}
@ -39,53 +39,53 @@ async function setEnvVars(): Promise<void> {
core.exportVariable(k, v)
}
}
set('RTX_TRUSTED_CONFIG_PATHS', process.cwd())
set('RTX_YES', '1')
set('RTX_EXPERIMENTAL', getExperimental() ? '1' : '0')
set('MISE_TRUSTED_CONFIG_PATHS', process.cwd())
set('MISE_YES', '1')
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.addPath(shimsDir)
}
async function restoreRTXCache(): Promise<void> {
core.startGroup('Restoring rtx cache')
const cachePath = rtxDir()
const fileHash = await glob.hashFiles(`**/.tool-versions\n**/.rtx.toml`)
const prefix = core.getInput('cache_key_prefix') || 'rtx-v0'
async function restoreMiseCache(): Promise<void> {
core.startGroup('Restoring mise cache')
const cachePath = miseDir()
const fileHash = await glob.hashFiles(`**/.tool-versions\n**/.mise.toml`)
const prefix = core.getInput('cache_key_prefix') || 'mise-v0'
const primaryKey = `${prefix}-${getOS()}-${os.arch()}-${fileHash}`
core.saveState('CACHE', core.getBooleanInput('cache_save') ?? true)
core.saveState('PRIMARY_KEY', primaryKey)
core.saveState('RTX_DIR', cachePath)
core.saveState('MISE_DIR', cachePath)
const cacheKey = await cache.restoreCache([cachePath], primaryKey)
core.setOutput('cache-hit', Boolean(cacheKey))
if (!cacheKey) {
core.info(`rtx cache not found for ${primaryKey}`)
core.info(`mise cache not found for ${primaryKey}`)
return
}
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> {
core.startGroup(version ? `Setup rtx@${version}` : 'Setup rtx')
const rtxBinDir = path.join(rtxDir(), 'bin')
async function setupMise(version: string | undefined): Promise<void> {
core.startGroup(version ? `Setup mise@${version}` : 'Setup mise')
const miseBinDir = path.join(miseDir(), 'bin')
const url = version
? `https://rtx.jdx.dev/v${version}/rtx-v${version}-${getOS()}-${os.arch()}`
: `https://rtx.jdx.dev/rtx-latest-${getOS()}-${os.arch()}`
await fs.promises.mkdir(rtxBinDir, { recursive: true })
? `https://mise.jdx.dev/v${version}/mise-v${version}-${getOS()}-${os.arch()}`
: `https://mise.jdx.dev/mise-latest-${getOS()}-${os.arch()}`
await fs.promises.mkdir(miseBinDir, { recursive: true })
await exec.exec('curl', [
'-fsSL',
url,
'--output',
path.join(rtxBinDir, 'rtx')
path.join(miseBinDir, 'mise')
])
await exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')])
core.addPath(rtxBinDir)
await exec.exec('chmod', ['+x', path.join(miseBinDir, 'mise')])
core.addPath(miseBinDir)
}
function getExperimental(): boolean {
@ -100,10 +100,10 @@ async function setToolVersions(): Promise<void> {
}
}
async function setRtxToml(): Promise<void> {
const toml = core.getInput('rtx_toml')
async function setMiseToml(): Promise<void> {
const toml = core.getInput('mise_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 rtxInstall = async (): Promise<number> => rtx(['install'])
const rtx = async (args: string[]): Promise<number> =>
core.group(`Running rtx ${args.join(' ')}`, async () => {
const testMise = async (): Promise<number> => mise(['--version'])
const rtxInstall = async (): Promise<number> => mise(['install'])
const mise = async (args: string[]): Promise<number> =>
core.group(`Running mise ${args.join(' ')}`, async () => {
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> =>

View file

@ -2,13 +2,13 @@ import * as core from '@actions/core'
import * as os from 'os'
import * as path from 'path'
export function rtxDir(): string {
const dir = core.getState('RTX_DIR')
export function miseDir(): string {
const dir = core.getState('MISE_DIR')
if (dir) return dir
const { RTX_DATA_DIR, XDG_DATA_HOME } = process.env
if (RTX_DATA_DIR) return RTX_DATA_DIR
if (XDG_DATA_HOME) return path.join(XDG_DATA_HOME, 'rtx')
const { MISE_DATA_DIR, XDG_DATA_HOME } = process.env
if (MISE_DATA_DIR) return MISE_DATA_DIR
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')
}