@@ -2,14 +2,29 @@ name: 'Setup mshell'
22description : ' Install the mshell concatenative shell language'
33inputs :
44 version :
5- description : ' Version to install (e.g., v0.1.0). Defaults to latest.'
5+ description : >
6+ Version to install. A release tag (e.g., v0.1.0) or 'latest' downloads a
7+ pre-built binary. Anything else (a commit SHA or branch name) is built
8+ from source with Go. Defaults to latest.
69 required : false
710 default : ' latest'
811runs :
912 using : ' composite'
1013 steps :
14+ - name : Determine install mode
15+ id : mode
16+ shell : bash
17+ run : |
18+ VERSION="${{ inputs.version }}"
19+ if [ "$VERSION" = "latest" ] || [ "${VERSION#v}" != "$VERSION" ]; then
20+ echo "mode=release" >> $GITHUB_OUTPUT
21+ else
22+ echo "mode=source" >> $GITHUB_OUTPUT
23+ fi
24+
1125 - name : Determine platform
1226 id : platform
27+ if : steps.mode.outputs.mode == 'release'
1328 shell : bash
1429 run : |
1530 case "${{ runner.os }}-${{ runner.arch }}" in
2136 *) echo "Unsupported platform: ${{ runner.os }}-${{ runner.arch }}" && exit 1 ;;
2237 esac
2338
24- - name : Download and install mshell
39+ - name : Download mshell release
40+ if : steps.mode.outputs.mode == 'release'
2541 shell : bash
2642 env :
2743 ACTION_REPO : ${{ github.action_repository }}
3854 mkdir -p "$HOME/.mshell/bin"
3955 curl -sL "$URL" | tar -xz -C "$HOME/.mshell/bin"
4056
57+ - name : Checkout mshell source
58+ if : steps.mode.outputs.mode == 'source'
59+ shell : bash
60+ env :
61+ ACTION_REPO : ${{ github.action_repository }}
62+ run : |
63+ VERSION="${{ inputs.version }}"
64+ SRC_DIR="$RUNNER_TEMP/mshell-src"
65+ rm -rf "$SRC_DIR"
66+ git clone "https://github.com/${ACTION_REPO}" "$SRC_DIR"
67+ git -C "$SRC_DIR" checkout "$VERSION"
68+
69+ - name : Set up Go
70+ if : steps.mode.outputs.mode == 'source'
71+ uses : actions/setup-go@v5
72+ with :
73+ go-version-file : ${{ runner.temp }}/mshell-src/mshell/go.mod
74+ cache : false
75+
76+ - name : Build mshell from source
77+ if : steps.mode.outputs.mode == 'source'
78+ shell : bash
79+ run : |
80+ SRC_DIR="$RUNNER_TEMP/mshell-src"
81+ mkdir -p "$HOME/.mshell/bin"
82+
83+ if [ "${{ runner.os }}" = "Windows" ]; then
84+ BIN="mshell.exe"
85+ else
86+ BIN="mshell"
87+ fi
88+
89+ cd "$SRC_DIR/mshell"
90+ go build -o "$HOME/.mshell/bin/$BIN"
91+
92+ # Releases ship std.msh in the tarball; for source builds take it from the repo.
93+ cp "$SRC_DIR/lib/std.msh" "$HOME/.mshell/bin/std.msh"
94+
95+ - name : Install mshell
96+ shell : bash
97+ run : |
4198 # Create symlinks so both msh and mshell work
4299 cd "$HOME/.mshell/bin"
43100 if [ -f mshell ]; then
76133 mkdir -p "$DATA_DIR/$MSH_VERSION"
77134 mkdir -p "$CONFIG_DIR/$MSH_VERSION"
78135
79- # std.msh is included in the release tarball ; move it into the versioned startup location.
136+ # std.msh is placed in the bin directory by both install modes ; move it into the versioned startup location.
80137 mv "$HOME/.mshell/bin/std.msh" "$DATA_DIR/$MSH_VERSION/std.msh"
81138
82139 # Create an empty init.msh so startup succeeds on first run.
0 commit comments