Skip to content

Commit 60a1de7

Browse files
authored
Merge branch 'main' into patch-1
2 parents 5451953 + 2cedc32 commit 60a1de7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2290
-2051
lines changed

.github/workflows/build_release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ on:
77
description: "Version of swiftly to build release artifacts"
88
required: true
99
type: string
10-
default: "0.4.0"
10+
default: "1.1.0"
1111
skip:
1212
description: "Perform release checks, such as the git tag, and swift version, or '--skip' to skip that."
1313
required: true
1414
type: string
1515
default: "--skip"
1616

1717
env:
18-
SWIFTLY_BOOTSTRAP_VERSION: 0.4.0-dev
18+
SWIFTLY_BOOTSTRAP_VERSION: 1.0.0
1919

2020
jobs:
2121
buildrelease:

.github/workflows/pull_request.yml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [main]
88

99
env:
10-
SWIFTLY_BOOTSTRAP_VERSION: 0.4.0-dev
10+
SWIFTLY_BOOTSTRAP_VERSION: 1.0.0
1111

1212
jobs:
1313
soundness:
@@ -50,14 +50,49 @@ jobs:
5050
- name: Prepare the action
5151
run: ./scripts/prep-gh-action.sh --install-swiftly
5252
- name: Build Artifact
53-
run: swift run build-swiftly-release --use-rhel-ubi9 --skip "999.0.0"
53+
run: swift run build-swiftly-release --test --skip "999.0.0"
5454
- name: Upload Artifact
5555
uses: actions/upload-artifact@v4
5656
with:
5757
name: swiftly-release-x86_64
5858
path: .build/release/swiftly-*.tar.gz
5959
if-no-files-found: error
6060
retention-days: 1
61+
- name: Upload Tests
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: swiftly-tests-x86_64
65+
path: .build/debug/test-swiftly-linux-x86_64.tar.gz
66+
if-no-files-found: error
67+
retention-days: 1
68+
69+
releasetest:
70+
name: Test Release / ${{matrix.shell.pkg}}
71+
needs: releasebuildcheck
72+
runs-on: ubuntu-latest
73+
strategy:
74+
fail-fast: false
75+
matrix:
76+
shell: [
77+
{"pkg": "bash", "bin": "/bin/bash"},
78+
{"pkg": "zsh", "bin": "/bin/zsh"},
79+
{"pkg": "fish", "bin": "/bin/fish"}
80+
]
81+
container:
82+
image: "ubuntu:24.04"
83+
steps:
84+
- name: Prepare System
85+
run: apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install ca-certificates gpg tzdata ${{matrix.shell.pkg}} && chsh -s ${{matrix.shell.bin}}
86+
- name: Download Release
87+
uses: actions/download-artifact@v4
88+
with:
89+
name: swiftly-release-x86_64
90+
- name: Download Tests
91+
uses: actions/download-artifact@v4
92+
with:
93+
name: swiftly-tests-x86_64
94+
- name: Extract and Run Workflow Tests
95+
run: cp swiftly-*.tar.gz /root/swiftly.tar.gz && cp test-swiftly-*.tar.gz /root && cd /root && tar zxf test-swiftly-*.tar.gz && ./test-swiftly -y ./swiftly.tar.gz
6196

6297
formatcheck:
6398
name: Format Check

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.0.3
1+
6.1.0

DESIGN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ CC=clang swiftly run +latest make
341341

342342
## Detailed Design
343343

344-
Swiftly itself will be a SPM project consisting of several executable products, one per supported platform, and all of these will share the core module that handles argument parsing, printing help information, and dispatching commands. Each platform’s executable will be built to statically link the stdlib so that they can be run without having installed Swift first.
344+
Swiftly itself will be a SwiftPM project consisting of several executable products, one per supported platform, and all of these will share the core module that handles argument parsing, printing help information, and dispatching commands. Each platform’s executable will be built to statically link the stdlib so that they can be run without having installed Swift first.
345345

346346
Within the core module, the following protocol will be defined:
347347

@@ -440,7 +440,7 @@ Determining whether the system has these installed or not is a bit of a tricky p
440440

441441
If neither of these steps find the package, then we'll consider the dependency as not installed, and print a message that shows users how to install it using the system package manager (e.g. `apt` on Ubuntu).
442442

443-
SPM has some code for detecting system libraries too, so it's possible we could integrate that here instead of using this approach.
443+
SwiftPM has some code for detecting system libraries too, so it's possible we could integrate that here instead of using this approach.
444444

445445
#### Downloading a toolchain
446446

Documentation/SwiftlyDocs.docc/SwiftlyDocs.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Install and manage your Swift programming language toolchains.
66
@DisplayName("Swiftly")
77
}
88

9+
Swiftly helps you to easily install different Swift toolchains locally on your account.
10+
It provides a single path to install, update, remove, or run commands with a specific Swift toolchain.
11+
912
## Topics
1013

1114
- <doc:getting-started>
Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,95 @@
1-
# Install Swiftly Automatically
1+
# Install swiftly automatically
22

33
Automatically install swiftly and Swift toolchains.
44

55
This guide helps you to automate the installation of swiftly and toolchains so that it can run unattended, for example in build or continous integration systems.
6-
We assume that you have working understanding of your build system. The examples are based on a typical Unix environment.
6+
This guide assumes that you have working understanding of your build system.
7+
The examples are based on a typical Unix environment.
78

8-
First, download the swiftly binary from swift.org for your operating system (e.g. Linux) and processor architecture (e.g. arm64, or x86_64). Here's an example using the popular curl command.
9+
### Download the binary
10+
11+
First, download the swiftly binary from swift.org for your operating system (for example, Linux) and processor architecture (for example `arm64` or `x86_64`).
12+
Here's an example using the popular curl command.
913

1014
```
11-
curl -L <location_of_swiftly_swift_org> > swiftly.tar.gz
15+
curl -L https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz > swiftly.tar.gz
1216
tar zxf swiftly.tar.gz
1317
```
1418

15-
On macOS you can download the pkg file and extract it like this from the command-line:
19+
On macOS, download the pkg file and extract it like this from the command-line:
1620

1721
```
18-
curl -L <location_of_swiftly_swift_org> > swiftly.pkg
22+
curl -L https://download.swift.org/swiftly/darwin/swiftly.pkg > swiftly.pkg
1923
installer -pkg swiftly.pkg -target CurrentUserHomeDirectory
2024
```
2125

22-
> Tip: If you are using Linux you will need the "ca-certificates" package for the root certificate authorities that will establish the trust that swiftly needs to make API requests that it needs. This package is frequently pre-installed on end-user environments, but may not be present in more minimal installations.
26+
> Tip: If you are using Linux you will need GPG and the "ca-certificates" package for the root certificate authorities that will establish the trust that swiftly needs to make API requests that it needs. This package is frequently pre-installed on end-user environments, but may not be present in more minimal installations.
27+
28+
### Install swiftly
2329

24-
Once swiftly is downloaded you can run the init subcommand to finish the installation. This command will print verbose outputs, assume yes for all prompts, and skip the automatic installation of the latest swift toolchain:
30+
Once swiftly is downloaded, run the `init` subcommand to finish the installation.
31+
The following example command prints verbose outputs, assume yes for all prompts, and skips the automatic installation of the latest swift toolchain:
2532

2633
```
2734
./swiftly init --verbose --assume-yes --skip-install # the swiftly binary is extracted to ~/local/bin/swiftly on macOS
2835
```
2936

30-
Swiftly is installed, but the current shell may not yet be updated with the new environment variables, such as the PATH. The init command prints instructions on how to update the current shell environment without opening a new shell. This is an example of the output taken from Linux, but the details might be different for other OSes, username, or shell.
37+
Swiftly is installed, but the current shell may not yet be updated with the new environment variables, such as `PATH`.
38+
The `init` command prints instructions on how to update the current shell environment without opening a new shell.
39+
The following output is an example from Linux, the details might be different for other OSes, username, or shell:
3140

3241
```
3342
To begin using installed swiftly from your current shell, first run the following command:
3443
3544
. "/root/.local/share/swiftly/env.sh"
3645
```
3746

38-
> Note: on macOS systems you may need to run 'hash -r' to recalculate the zsh PATH cache when installing swiftly and toolchains.
47+
> Note: on macOS, run 'hash -r' to recalculate the zsh PATH cache when installing swiftly and toolchains.
48+
49+
You can go ahead and add this command to the list of commands in your build script so that the build can proceed to call swiftly from the path.
50+
51+
### Install a toolchain
3952

40-
You can go ahead and add this command to the list of commands in your build script so that the build can proceed to call swiftly from the path. The usual next step is to install a specific swift toolchain like this:
53+
The usual next step is to install a specific swift toolchain using the `install` command with the `--post-install-file` option:
4154

4255
```
4356
swiftly install 5.10.1 --post-install-file=post-install.sh
4457
```
4558

46-
It's possible that there will be some post-installation steps to prepare the build system for using the swift toolchain. The `post-install-file` option gives a file, post-install.sh, that is created if there are post installation steps for this toolchain. You can check if the file exists and run it to perform those final steps. If the build runs as the root user you can check it and run it like this in a typical Unix shell:
59+
It's possible that there will be some post-installation steps to prepare the system for using the swift toolchain.
60+
If additional post-install steps are needed to use the toolchain they are written to the file you specified; `post-install.sh` in the example above.
61+
You can check if the file exists and run it to perform those final steps.
62+
If the build runs as the root user you can check it and run it like this in a typical Unix shell:
4763

4864
```
4965
if [ -f post-install.sh ]; then
5066
. post-install.sh
5167
fi
5268
```
5369

54-
> Note: If the build system runs your script as a regular user then you will need to take this into account by either pre-installing the toolchain's system dependencies or running the `post-install.sh` script in a secure manner as the administrative user.
70+
> Note: If the system runs your script as a regular user then you will need to take this into account by either pre-installing the toolchain's system dependencies or running the `post-install.sh` script in a secure manner as the administrative user.
71+
72+
### Customize the installation
5573

5674
If you want to install swiftly, or the binaries that it manages into different locations these can be customized using environment variables before running `swiftly init`.
5775

58-
```
59-
SWIFTLY_HOME_DIR - The location of the swiftly configuration files, and environment scripts
60-
SWIFTLY_BIN_DIR - The location of the swiftly binary and toolchain symbolic links (e.g. swift, swiftc, etc.)
61-
```
76+
- term `SWIFTLY_HOME_DIR`: The location of the swiftly configuration files, and environment scripts
77+
- term `SWIFTLY_BIN_DIR`: The location of the swiftly binary and toolchain symbolic links (for example swift, swiftc, and so on)
78+
- term `TMPDIR`: The temporary directory swiftly uses to hold large files, such as downloads, until it cleans them up.
6279

63-
Sometimes the build system platform can't be automatically detected, or isn't supported by swift. You can provide the platform as an option to the swiftly init subcommand:
80+
Sometimes swiftly can't automatically detect the system platform, or isn't supported by swift.
81+
You can provide the platform as an option to the `swiftly init` subcommand:
6482

6583
```
6684
swiftly init --platform=<platform_name>
6785
```
6886

69-
There are other customizable options, such as overwrite. For more details about the available options, check the help:
87+
There are other customizable options, such as overwrite.
88+
For more details about the available options, check the help:
7089

7190
```
7291
swiftly init --help
7392
```
7493

75-
In summary, swiftly can be installed and install toolchains unattended on build and CI-style systems. This HOWTO guide has outlined the process to script the process covering some of the different options available to you.
94+
In summary, swiftly can be installed and install toolchains unattended on build and CI-style systems.
95+
This guide has outlined the process to script the process covering some of the different options available to you.

Documentation/SwiftlyDocs.docc/getting-started.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
# Getting Started with Swiftly
1+
# Getting started with swiftly
22

3-
Start using swiftly and swift.
3+
Start using swiftly and Swift.
44

55
To get started with swiftly you can download it from [swift.org](https://swift.org/download), and extract the package.
66

77
@TabNavigator {
88
@Tab("Linux") {
9-
If you are using Linux then you can verify and extract the archive like this:
9+
If you are using Linux then you can download the binary:
1010

1111
```
12-
tar zxf swiftly-x.y.z.tar.gz
12+
curl -L https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz > swiftly.tar.gz
13+
tar zxf swiftly.tar.gz
1314
```
1415

1516
Now run swiftly init to finish the installation:
@@ -20,21 +21,24 @@ To get started with swiftly you can download it from [swift.org](https://swift.o
2021
}
2122

2223
@Tab("macOS") {
23-
On macOS you can either run the pkg installer from the command-line like this or just run the package by double-clicking on it (not recommended):
24+
On macOS you can either run the pkg installer from the command-line like this or run the package by double-clicking on it (not recommended):
2425

2526
```
26-
installer -pkg swift-x.y.z.pkg -target CurrentUserHomeDirectory
27+
curl -L https://download.swift.org/swiftly/darwin/swiftly.pkg > swiftly.pkg
28+
installer -pkg swiftly.pkg -target CurrentUserHomeDirectory
2729
```
2830

29-
Now run swiftly init to finish the installation:
31+
Once the package is installed, run `swiftly init` to finish the installation:
3032

3133
```
32-
~/usr/local/bin/swiftly init
34+
~/.swiftly/bin/swiftly init
3335
```
3436
}
3537
}
3638

37-
Swiftly will install itself and download the latest available Swift toolchain. Follow the prompts for any additional steps. Once everything is done you can begin using swift.
39+
Swiftly installs itself and downloads the latest available Swift toolchain.
40+
Follow the prompts for any additional steps that may be required.
41+
Once everything is done you can begin using swift.
3842

3943
```
4044
$ swift --version
@@ -72,20 +76,22 @@ Uninstall this toolchain after you're finished with it:
7276
$ swiftly uninstall main-snapshot
7377
```
7478

75-
# Proxy
79+
## Installing toolchains through an HTTP proxy
7680

7781
Swiftly downloads a list of toolchains from https://www.swift.org/ and retrieves them from CDN via https://download.swift.org.
78-
If your environment requires a proxy, Swiftly will attempt to use the standard environment variables `http_proxy`, `HTTP_PROXY`, `https_proxy` or `HTTPS_PROXY` to determine which proxy server to use instead of making a direct connection.
82+
If your environment requires a proxy, Swiftly attempts to use the standard environment variables `http_proxy`, `HTTP_PROXY`, `https_proxy` or `HTTPS_PROXY` to determine which proxy server to use instead of making a direct connection.
7983

8084
To download latest nightly snapshot using a proxy:
8185
```
8286
$ export https_proxy=http://proxy:3128
8387
$ swiftly install main-snapshot
8488
```
8589

86-
# See Also:
90+
## See Also:
8791

92+
- [Add shell autocompletions](shell-autocompletion)
8893
- [Install Toolchains](install-toolchains)
8994
- [Using Toolchains](use-toolchains)
9095
- [Uninstall Toolchains](uninstall-toolchains)
9196
- [Swiftly CLI Reference](swiftly-cli-reference)
97+

Documentation/SwiftlyDocs.docc/install-toolchains.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
# Install Swift Toolchains
1+
# Install Swift toolchains
22

33
Install swift toolchains with Swiftly.
44

5-
Installing a swift toolchain using swiftly involves downloading it securely and extracting it into a well-known location in your account. Here we will guide you through the different ways you can install a swift toolchain. You will need to install swiftly first. The [Getting Started](getting-started.md) guide is a good place to start with swiftly.
5+
Installing a swift toolchain using swiftly involves downloading it securely and extracting it into a well-known location in your account.
6+
This guides you through the different ways you can install a swift toolchain.
7+
Follow the [Getting Started](getting-started.md) guide to install swiftly.
68

79
The easiest way to install a swift toolchain is to select the latest stable release:
810

911
```
1012
$ swiftly install latest
1113
```
1214

13-
> Note: After you install a toolchain there may be certain system dependencies that are needed. Swiftly will provide instructions.
15+
> Note: After you install a toolchain there may be certain system dependencies that are needed.
16+
Swiftly provides instructions for any additional dependencies that need to be installed.
1417

15-
If this is the only toolchain that is installed then swiftly will automatically "use" it so that when you run swift (or any other toolchain command) it will be this version.
18+
If this is the only installed toolchain, swiftly automatically uses it. When you run `swift` (or another toolchain command), it uses the installed version.
1619

1720
```
1821
$ swift --version
@@ -21,7 +24,8 @@ Swift version 5.8.1 (swift-5.8.1-RELEASE)
2124
Target: x86_64-unknown-linux-gnu
2225
```
2326

24-
You can be very specific about the released version that you want. We can install the 5.6.1 version like this:
27+
You can be very specific about the released version to install.
28+
For example, the following command installs the 5.6.1 toolchain version:
2529

2630
```
2731
$ swiftly install 5.6.1
@@ -33,13 +37,13 @@ Once you've installed more than one toolchain you may notice that swift is on th
3337
$ swiftly use 5.6.1
3438
```
3539

36-
You can also combine install and use into one command to automate this process with the `--use` switch on the install subcommand:
40+
You can combine `install` and `use` into one command with the `--use` switch on the `install` subcommand:
3741

3842
```
3943
$ swiftly install --use 5.7.1
4044
```
4145

42-
Sometimes you want the latest available patch of a minor release, such as 5.7. Let's omit the patch number so that we get the latest patch.
46+
Sometimes you want the latest available patch of a minor release, such as 5.7. If you omit the patch number from the release you request, swiftly installs the latest patch.
4347

4448
```
4549
$ swiftly install 5.7

Documentation/SwiftlyDocs.docc/shell-autocompletion.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Add Shell Auto-completions
1+
# Add shell auto-completions
22

3-
Generate shell auto-completions for Swiftly.
3+
Generate shell autocompletions for swiftly.
44

5-
Swiftly can generate shell auto-completion scripts for your shell to automatically complete subcommands, arguments, options and flags. It does this using the [swift-argument-parser](https://apple.github.io/swift-argument-parser/documentation/argumentparser/installingcompletionscripts/), which has support for Bash, Z shell, and Fish.
5+
Swiftly can generate shell autocompletion scripts for your shell to automatically complete subcommands, arguments, options and flags. It does this using the [swift-argument-parser](https://apple.github.io/swift-argument-parser/documentation/argumentparser/installingcompletionscripts/), which has support for Bash, Z shell, and Fish.
66

77
You can ask swiftly to generate the script using the hidden `--generate-completion-script` flag with the type of shell like this:
88

@@ -63,4 +63,4 @@ swiftly --generate-completion-script <shell>
6363
}
6464
}
6565

66-
Once you have installed the completions you can type out a swiftly command, and press a special key (e.g. tab) and the shell will show you the available subcommand, argument, or options to make it easier to assemble a working command-line.
66+
Once you have installed the completions you can type out a swiftly command, and press a special key (for example, tab) and the shell will show you the available subcommand, argument, or options to make it easier to assemble a working command-line.

0 commit comments

Comments
 (0)