Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- The GitHub action can now install unreleased builds:
passing a commit SHA or branch name as `version` clones the repository at that ref and builds from source with Go.
Release tags (`vX.Y.Z`) and `latest` still download pre-built binaries.

- The tar write functions (`tarDirInc`, `tarDirExc`, `tarPack`) now accept a
dictionary destination `{path: str|path, compress?: bool}`, where `compress`
overrides the extension-based gzip inference in either direction — useful
Expand Down
63 changes: 60 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,29 @@ name: 'Setup mshell'
description: 'Install the mshell concatenative shell language'
inputs:
version:
description: 'Version to install (e.g., v0.1.0). Defaults to latest.'
description: >
Version to install. A release tag (e.g., v0.1.0) or 'latest' downloads a
pre-built binary. Anything else (a commit SHA or branch name) is built
from source with Go. Defaults to latest.
required: false
default: 'latest'
runs:
using: 'composite'
steps:
- name: Determine install mode
id: mode
shell: bash
run: |
VERSION="${{ inputs.version }}"
if [ "$VERSION" = "latest" ] || [ "${VERSION#v}" != "$VERSION" ]; then
echo "mode=release" >> $GITHUB_OUTPUT
else
echo "mode=source" >> $GITHUB_OUTPUT
fi

- name: Determine platform
id: platform
if: steps.mode.outputs.mode == 'release'
shell: bash
run: |
case "${{ runner.os }}-${{ runner.arch }}" in
Expand All @@ -21,7 +36,8 @@ runs:
*) echo "Unsupported platform: ${{ runner.os }}-${{ runner.arch }}" && exit 1 ;;
esac

- name: Download and install mshell
- name: Download mshell release
if: steps.mode.outputs.mode == 'release'
shell: bash
env:
ACTION_REPO: ${{ github.action_repository }}
Expand All @@ -38,6 +54,47 @@ runs:
mkdir -p "$HOME/.mshell/bin"
curl -sL "$URL" | tar -xz -C "$HOME/.mshell/bin"

- name: Checkout mshell source
if: steps.mode.outputs.mode == 'source'
shell: bash
env:
ACTION_REPO: ${{ github.action_repository }}
run: |
VERSION="${{ inputs.version }}"
SRC_DIR="$RUNNER_TEMP/mshell-src"
rm -rf "$SRC_DIR"
git clone "https://github.com/${ACTION_REPO}" "$SRC_DIR"
git -C "$SRC_DIR" checkout "$VERSION"

- name: Set up Go
if: steps.mode.outputs.mode == 'source'
uses: actions/setup-go@v5
with:
go-version-file: ${{ runner.temp }}/mshell-src/mshell/go.mod
cache: false

- name: Build mshell from source
if: steps.mode.outputs.mode == 'source'
shell: bash
run: |
SRC_DIR="$RUNNER_TEMP/mshell-src"
mkdir -p "$HOME/.mshell/bin"

if [ "${{ runner.os }}" = "Windows" ]; then
BIN="mshell.exe"
else
BIN="mshell"
fi

cd "$SRC_DIR/mshell"
go build -o "$HOME/.mshell/bin/$BIN"

# Releases ship std.msh in the tarball; for source builds take it from the repo.
cp "$SRC_DIR/lib/std.msh" "$HOME/.mshell/bin/std.msh"

- name: Install mshell
shell: bash
run: |
# Create symlinks so both msh and mshell work
cd "$HOME/.mshell/bin"
if [ -f mshell ]; then
Expand Down Expand Up @@ -76,7 +133,7 @@ runs:
mkdir -p "$DATA_DIR/$MSH_VERSION"
mkdir -p "$CONFIG_DIR/$MSH_VERSION"

# std.msh is included in the release tarball; move it into the versioned startup location.
# std.msh is placed in the bin directory by both install modes; move it into the versioned startup location.
mv "$HOME/.mshell/bin/std.msh" "$DATA_DIR/$MSH_VERSION/std.msh"

# Create an empty init.msh so startup succeeds on first run.
Expand Down
15 changes: 15 additions & 0 deletions doc/getting-started.inc.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ <h1 id="getting-started-github-actions">GitHub Actions <a class="section-link" h
The action downloads the pre-built binary for the runner platform and installs the matching startup files automatically.
</p>

<p>
To use a build that has not been released yet, pass a commit SHA or branch name as the version.
Anything that is not <code>latest</code> and does not start with <code>v</code> is treated as a git ref:
the action clones the repository at that ref and builds from source with Go
(installed automatically via <code>actions/setup-go</code>).
</p>

<pre>
<code><span class="yaml-key">steps:</span>
- <span class="yaml-key">uses:</span> mitchpaulus/mshell@main
<span class="yaml-key">with:</span>
<span class="yaml-key">version:</span> a087dc2f
- <span class="yaml-key">run:</span> msh script.msh</code>
</pre>

<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>

<p>
Expand Down