Skip to content

Commit b0e33eb

Browse files
authored
Add action.yml (#133)
* Add action.yml Let's us use mshell for other projects GitHub actions * Add more docs, make sure mshell and msh both work in the action
1 parent 5b3d327 commit b0e33eb

4 files changed

Lines changed: 104 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
- Bin map file and `msh bin` CLI commands for binary overrides
3535
- `msh completions` subcommand for bash, fish, nushell, and elvish
3636
- CLI syntax highlighting for environment variables
37+
- GitHub Action for installing mshell in CI workflows
3738
- Append stderr redirection with `2>>`
3839
- Combined stdout/stderr redirection with `&>` (truncate) and `&>>` (append)
3940
- Same-path detection when using `>` and `2>` with identical paths (shares single file descriptor)

action.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: 'Setup mshell'
2+
description: 'Install the mshell concatenative shell language'
3+
inputs:
4+
version:
5+
description: 'Version to install (e.g., v0.1.0). Defaults to latest.'
6+
required: false
7+
default: 'latest'
8+
runs:
9+
using: 'composite'
10+
steps:
11+
- name: Determine platform
12+
id: platform
13+
shell: bash
14+
run: |
15+
case "${{ runner.os }}-${{ runner.arch }}" in
16+
Linux-X64) echo "asset=linux_amd64" >> $GITHUB_OUTPUT ;;
17+
Linux-ARM64) echo "asset=linux_arm64" >> $GITHUB_OUTPUT ;;
18+
macOS-X64) echo "asset=darwin_amd64" >> $GITHUB_OUTPUT ;;
19+
macOS-ARM64) echo "asset=darwin_arm64" >> $GITHUB_OUTPUT ;;
20+
Windows-X64) echo "asset=windows_amd64" >> $GITHUB_OUTPUT ;;
21+
*) echo "Unsupported platform: ${{ runner.os }}-${{ runner.arch }}" && exit 1 ;;
22+
esac
23+
24+
- name: Download and install mshell
25+
shell: bash
26+
run: |
27+
VERSION="${{ inputs.version }}"
28+
ASSET="${{ steps.platform.outputs.asset }}"
29+
30+
if [ "$VERSION" = "latest" ]; then
31+
URL="https://github.com/${{ github.repository }}/releases/latest/download/${ASSET}.tar.gz"
32+
else
33+
URL="https://github.com/${{ github.repository }}/releases/download/${VERSION}/${ASSET}.tar.gz"
34+
fi
35+
36+
mkdir -p "$HOME/.mshell/bin"
37+
curl -sL "$URL" | tar -xz -C "$HOME/.mshell/bin"
38+
39+
# Create symlinks so both msh and mshell work
40+
cd "$HOME/.mshell/bin"
41+
if [ -f mshell ]; then
42+
ln -sf mshell msh
43+
elif [ -f msh ]; then
44+
ln -sf msh mshell
45+
elif [ -f mshell.exe ]; then
46+
cp mshell.exe msh.exe
47+
elif [ -f msh.exe ]; then
48+
cp msh.exe mshell.exe
49+
fi
50+
51+
echo "$HOME/.mshell/bin" >> $GITHUB_PATH
52+
53+
- name: Download standard library
54+
shell: bash
55+
run: |
56+
VERSION="${{ inputs.version }}"
57+
if [ "$VERSION" = "latest" ]; then
58+
curl -sL "https://raw.githubusercontent.com/${{ github.repository }}/main/lib/std.msh" -o "$HOME/.mshell/std.msh"
59+
else
60+
curl -sL "https://raw.githubusercontent.com/${{ github.repository }}/${VERSION}/lib/std.msh" -o "$HOME/.mshell/std.msh"
61+
fi
62+
echo "MSHSTDLIB=$HOME/.mshell/std.msh" >> $GITHUB_ENV

doc/base.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,18 @@
282282
color: #8A2BE2;
283283
}
284284

285+
.yaml-key {
286+
color: #0F4C81;
287+
}
288+
289+
.yaml-string {
290+
color: #FF0000;
291+
}
292+
293+
.yaml-comment {
294+
color: #008000;
295+
}
296+
285297
</style>
286298
</head>
287299
<body>
@@ -293,6 +305,7 @@ <h1>mshell</h1>
293305
<a href="getting-started.html">Getting Started</a>
294306
<ul class="nav-ul nav-sub">
295307
<li><a href="getting-started.html#getting-started-installation">Installation</a></li>
308+
<li><a href="getting-started.html#getting-started-github-actions">GitHub Actions</a></li>
296309
<li><a href="getting-started.html#getting-started-editor-support">Editor Support</a></li>
297310
</ul>
298311
</li>

doc/getting-started.inc.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,34 @@ <h2 id="getting-started-installation-stdlib">2) Set up the standard library</h2>
7373
<a href="https://github.com/mitchpaulus/mshell/blob/main/install.sh" target="_blank" rel="noopener noreferrer">install.sh</a>.
7474
</p>
7575

76+
<h1 id="getting-started-github-actions">GitHub Actions <a class="section-link" href="#getting-started-github-actions" aria-label="Permalink">§</a> <a class="back-to-top" href="#getting-started-top">Back to top</a></h1>
77+
78+
<p>
79+
To use <code>mshell</code> in GitHub Actions workflows, use the official action:
80+
</p>
81+
82+
<pre>
83+
<code><span class="yaml-key">steps:</span>
84+
- <span class="yaml-key">uses:</span> mitchpaulus/mshell@v1
85+
- <span class="yaml-key">run:</span> msh script.msh</code>
86+
</pre>
87+
88+
<p>
89+
To pin a specific version:
90+
</p>
91+
92+
<pre>
93+
<code><span class="yaml-key">steps:</span>
94+
- <span class="yaml-key">uses:</span> mitchpaulus/mshell@main
95+
<span class="yaml-key">with:</span>
96+
<span class="yaml-key">version:</span> v0.8.0
97+
- <span class="yaml-key">run:</span> msh script.msh</code>
98+
</pre>
99+
100+
<p>
101+
The action downloads the pre-built binary for the runner platform and sets up the <code>MSHSTDLIB</code> environment variable automatically.
102+
</p>
103+
76104
<h1 id="getting-started-editor-support">Editor Support <a class="section-link" href="#getting-started-editor-support" aria-label="Permalink">§</a> <a class="back-to-top" href="#getting-started-top">Back to top</a></h1>
77105

78106
<p>

0 commit comments

Comments
 (0)