Skip to content

Commit f08695d

Browse files
committed
Allow source build in GitHub actions
1 parent a087dc2 commit f08695d

3 files changed

Lines changed: 79 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- The GitHub action can now install unreleased builds:
13+
passing a commit SHA or branch name as `version` clones the repository at that ref and builds from source with Go.
14+
Release tags (`vX.Y.Z`) and `latest` still download pre-built binaries.
15+
1216
- The tar write functions (`tarDirInc`, `tarDirExc`, `tarPack`) now accept a
1317
dictionary destination `{path: str|path, compress?: bool}`, where `compress`
1418
overrides the extension-based gzip inference in either direction — useful

action.yml

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,29 @@ name: 'Setup mshell'
22
description: 'Install the mshell concatenative shell language'
33
inputs:
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'
811
runs:
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
@@ -21,7 +36,8 @@ runs:
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 }}
@@ -38,6 +54,47 @@ runs:
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
@@ -76,7 +133,7 @@ runs:
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.

doc/getting-started.inc.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,21 @@ <h1 id="getting-started-github-actions">GitHub Actions <a class="section-link" h
9696
The action downloads the pre-built binary for the runner platform and installs the matching startup files automatically.
9797
</p>
9898

99+
<p>
100+
To use a build that has not been released yet, pass a commit SHA or branch name as the version.
101+
Anything that is not <code>latest</code> and does not start with <code>v</code> is treated as a git ref:
102+
the action clones the repository at that ref and builds from source with Go
103+
(installed automatically via <code>actions/setup-go</code>).
104+
</p>
105+
106+
<pre>
107+
<code><span class="yaml-key">steps:</span>
108+
- <span class="yaml-key">uses:</span> mitchpaulus/mshell@main
109+
<span class="yaml-key">with:</span>
110+
<span class="yaml-key">version:</span> a087dc2f
111+
- <span class="yaml-key">run:</span> msh script.msh</code>
112+
</pre>
113+
99114
<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>
100115

101116
<p>

0 commit comments

Comments
 (0)