Skip to content

Commit 5689d02

Browse files
committed
Use a curlbash script for installing swiftly
1 parent 8ca64da commit 5689d02

File tree

5 files changed

+42
-30
lines changed

5 files changed

+42
-30
lines changed

_data/new-data/install/linux/releases.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,7 @@ latest-release:
33
pre-code-text: |
44
The Swiftly installer manages Swift and its dependencies. It supports switching between different versions and downloading updates.
55
headline: Swiftly
6-
tabs:
7-
- label: Bash
8-
code: |-
9-
curl -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz && \
10-
tar zxf swiftly-$(uname -m).tar.gz && \
11-
./swiftly init --quiet-shell-followup && \
12-
. "${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}/env.sh" && \
13-
hash -r
14-
- label: Fish
15-
code: |-
16-
curl -O https://download.swift.org/swiftly/linux/swiftly-(uname -m).tar.gz && \
17-
tar zxf swiftly-(uname -m).tar.gz && \
18-
./swiftly init --quiet-shell-followup && \
19-
set -q SWIFTLY_HOME_DIR && source "$SWIFTLY_HOME_DIR/env.fish" || source ~/.local/share/swiftly/env.fish
6+
code: curl -fsSL https://swift.org/swiftly-install | sh
207
links:
218
- href: 'https://raw.githubusercontent.com/swiftlang/swiftly/refs/heads/main/LICENSE.txt'
229
copy: 'License: Apache-2.0'

_data/new-data/install/macos/releases.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,7 @@ latest-release:
33
pre-code-text: |
44
To download toolchains from Swift.org, use the Swiftly toolchain installer. Swift.org toolchains support Static Linux SDK, include experimental features like Embedded Swift and support for WebAssembly.
55
headline: Swiftly
6-
tabs:
7-
- label: Bash
8-
code: |
9-
curl -O https://download.swift.org/swiftly/darwin/swiftly.pkg && \
10-
installer -pkg swiftly.pkg -target CurrentUserHomeDirectory && \
11-
~/.swiftly/bin/swiftly init --quiet-shell-followup && \
12-
. "${SWIFTLY_HOME_DIR:-$HOME/.swiftly}/env.sh" && \
13-
hash -r
14-
- label: Fish
15-
code: |
16-
curl -O https://download.swift.org/swiftly/darwin/swiftly.pkg && \
17-
installer -pkg swiftly.pkg -target CurrentUserHomeDirectory && \
18-
~/.swiftly/bin/swiftly init --quiet-shell-followup && \
19-
set -q SWIFTLY_HOME_DIR && source "$SWIFTLY_HOME_DIR/env.fish" || source ~/.swiftly/env.fish
6+
code: curl -fsSL https://swift.org/swiftly-install | sh
207
links:
218
- href: 'https://raw.githubusercontent.com/swiftlang/swiftly/refs/heads/main/LICENSE.txt'
229
copy: 'License: Apache-2.0'

install/linux/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ title: Install Swift - Linux
88
<div class="content">
99
<div class="release-box section">
1010
<div class="content">
11-
{% include new-includes/components/code-box.html with-tabs = true content = site.data.new-data.install.linux.releases.latest-release.swiftly %}
11+
{% include new-includes/components/code-box.html content = site.data.new-data.install.linux.releases.latest-release.swiftly %}
1212
</div>
1313
</div>
1414
<div class="release-box section">

install/macos/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ title: Install Swift - macOS
1111
<div class="content">
1212
<div class="release-box section">
1313
<div class="content">
14-
{% include new-includes/components/code-box.html with-tabs = true content = site.data.new-data.install.macos.releases.latest-release.swiftly%}
14+
{% include new-includes/components/code-box.html content = site.data.new-data.install.macos.releases.latest-release.swiftly%}
1515
</div>
1616
</div>
1717
<div class="release-box section">

swiftly-install

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash -e
2+
# Install script for Swiftly
3+
# Usage: curl -fsSL https://swift.org/swiftly-install | sh
4+
OS_NAME=$(uname -s)
5+
OS_ARCH=$(uname -m)
6+
TMPDIR=$(mktemp -d)
7+
8+
cd ${TMPDIR}
9+
10+
case "$OS_NAME" in
11+
"Linux")
12+
curl -fsSLO https://download.swift.org/swiftly/linux/swiftly-${OS_ARCH}.tar.gz
13+
tar zxf swiftly-${OS_ARCH}.tar.gz
14+
./swiftly init
15+
SWIFTLY_HOME_DIR=${SWIFTLY_HOME_DIR:-$HOME/.swiftly}
16+
;;
17+
"Darwin")
18+
curl -fsSLO https://download.swift.org/swiftly/darwin/swiftly.pkg
19+
installer -pkg swiftly.pkg -target CurrentUserHomeDirectory
20+
~/.swiftly/bin/swiftly init
21+
SWIFTLY_HOME_DIR=${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}
22+
;;
23+
*)
24+
echo "Unknown platform: $OS_NAME"
25+
echo "This script supports Linux and Darwin/macOS only"
26+
exit 1
27+
;;
28+
esac
29+
30+
echo "Swiftly installed! Run the following command to set up your environment:"
31+
PARENT_SHELL=$(ps -o comm= -p "$PPID")
32+
if [ "$PARENT_SHELL" = "fish" ]; then
33+
echo "source ${SWIFTLY_HOME_DIR}/env.fish"
34+
else
35+
# Not fish: assume sh-compatible (bash/zsh)
36+
echo "source ${SWIFTLY_HOME_DIR}/env.sh"
37+
fi
38+

0 commit comments

Comments
 (0)