|
| 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 |
0 commit comments