-
Notifications
You must be signed in to change notification settings - Fork 55
broad swiftly-doc content edit pass #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,94 @@ | ||
# Install Swiftly Automatically | ||
# Install swiftly automatically | ||
|
||
Automatically install swiftly and Swift toolchains. | ||
|
||
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. | ||
We assume that you have working understanding of your build system. The examples are based on a typical Unix environment. | ||
This guide assumes that you have working understanding of your build system. | ||
The examples are based on a typical Unix environment. | ||
|
||
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. | ||
### Download the binary | ||
|
||
First, download the swiftly binary from swift.org for your operating system (for example, Linux) and processor architecture (for example `arm64` or `x86_64`). | ||
Here's an example using the popular curl command. | ||
|
||
``` | ||
curl -L <location_of_swiftly_swift_org> > swiftly.tar.gz | ||
curl -L https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz > swiftly.tar.gz | ||
tar zxf swiftly.tar.gz | ||
``` | ||
|
||
On macOS you can download the pkg file and extract it like this from the command-line: | ||
On macOS, download the pkg file and extract it like this from the command-line: | ||
|
||
``` | ||
curl -L <location_of_swiftly_swift_org> > swiftly.pkg | ||
installer -pkg swiftly.pkg -target CurrentUserHomeDirectory | ||
``` | ||
|
||
> 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. | ||
> 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. | ||
### Install swiftly | ||
|
||
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: | ||
Once swiftly is downloaded, run the `init` subcommand to finish the installation. | ||
The following example command prints verbose outputs, assume yes for all prompts, and skips the automatic installation of the latest swift toolchain: | ||
|
||
``` | ||
./swiftly init --verbose --assume-yes --skip-install # the swiftly binary is extracted to ~/local/bin/swiftly on macOS | ||
``` | ||
|
||
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. | ||
Swiftly is installed, but the current shell may not yet be updated with the new environment variables, such as `PATH`. | ||
The `init` command prints instructions on how to update the current shell environment without opening a new shell. | ||
The following output is an example from Linux, the details might be different for other OSes, username, or shell: | ||
|
||
``` | ||
To begin using installed swiftly from your current shell, first run the following command: | ||
. "/root/.local/share/swiftly/env.sh" | ||
``` | ||
|
||
> Note: on macOS systems you may need to run 'hash -r' to recalculate the zsh PATH cache when installing swiftly and toolchains. | ||
> Note: on macOS, run 'hash -r' to recalculate the zsh PATH cache when installing swiftly and toolchains. | ||
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. | ||
|
||
### Install a toolchain | ||
|
||
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: | ||
The usual next step is to install a specific swift toolchain using the `install` command with the `--post-install-file` option: | ||
|
||
``` | ||
swiftly install 5.10.1 --post-install-file=post-install.sh | ||
``` | ||
|
||
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: | ||
It's possible that there will be some post-installation steps to prepare the system for using the swift toolchain. | ||
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. | ||
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: | ||
|
||
``` | ||
if [ -f post-install.sh ]; then | ||
. post-install.sh | ||
fi | ||
``` | ||
|
||
> 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. | ||
> 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. | ||
### Customize the installation | ||
|
||
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`. | ||
|
||
``` | ||
SWIFTLY_HOME_DIR - The location of the swiftly configuration files, and environment scripts | ||
SWIFTLY_BIN_DIR - The location of the swiftly binary and toolchain symbolic links (e.g. swift, swiftc, etc.) | ||
``` | ||
- term `SWIFTLY_HOME_DIR`: The location of the swiftly configuration files, and environment scripts | ||
- term `SWIFTLY_BIN_DIR`: The location of the swiftly binary and toolchain symbolic links (for example swift, swiftc, and so on) | ||
|
||
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: | ||
Sometimes swiftly can't automatically detect the system platform, or isn't supported by swift. | ||
You can provide the platform as an option to the `swiftly init` subcommand: | ||
|
||
``` | ||
swiftly init --platform=<platform_name> | ||
``` | ||
|
||
There are other customizable options, such as overwrite. For more details about the available options, check the help: | ||
There are other customizable options, such as overwrite. | ||
For more details about the available options, check the help: | ||
|
||
``` | ||
swiftly init --help | ||
``` | ||
|
||
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. | ||
In summary, swiftly can be installed and install toolchains unattended on build and CI-style systems. | ||
This guide has outlined the process to script the process covering some of the different options available to you. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Getting Started with Swiftly | ||
# Getting started with swiftly | ||
|
||
Start using swiftly and swift. | ||
Start using swiftly and Swift. | ||
|
||
To get started with swiftly you can download it from [swift.org](https://swift.org/download), and extract the package. | ||
|
||
|
@@ -20,21 +20,23 @@ To get started with swiftly you can download it from [swift.org](https://swift.o | |
} | ||
|
||
@Tab("macOS") { | ||
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): | ||
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): | ||
|
||
``` | ||
installer -pkg swift-x.y.z.pkg -target CurrentUserHomeDirectory | ||
|
||
``` | ||
|
||
Now run swiftly init to finish the installation: | ||
Once the package is installed, run `swiftly init` to finish the installation: | ||
|
||
``` | ||
~/usr/local/bin/swiftly init | ||
|
||
``` | ||
} | ||
} | ||
|
||
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. | ||
Swiftly installs itself and downloads the latest available Swift toolchain. | ||
Follow the prompts for any additional steps that may be required. | ||
Once everything is done you can begin using swift. | ||
|
||
``` | ||
$ swift --version | ||
|
@@ -72,10 +74,10 @@ Uninstall this toolchain after you're finished with it: | |
$ swiftly uninstall main-snapshot | ||
``` | ||
|
||
# Proxy | ||
# Installing toolchains through a proxy | ||
|
||
|
||
Swiftly downloads a list of toolchains from https://www.swift.org/ and retrieves them from CDN via https://download.swift.org. | ||
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. | ||
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. | ||
|
||
To download latest nightly snapshot using a proxy: | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Now that the download URL's are established, can you update this curl command here for macOS too?