-
Notifications
You must be signed in to change notification settings - Fork 49
Merge installation logic into swiftly as an init subcommand #127
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 25 commits
9eb8c91
c272921
2801b53
f2609dc
3af19ac
eeb9d36
b64f4bd
dd15324
1d3bb26
1cd01be
c8cb477
763b284
72b7025
a2a6d4b
ef9ee05
7f9fb9e
56672ec
6bf4ab9
c4f87cb
4e0ed6e
11d112a
373be6a
886865f
0aa21e0
7081738
361bc2f
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Install Swiftly Automatically | ||
|
||
Swiftly can be installed automatically in places like build/CI systems. | ||
|
||
This guide will help you to script to the installation of swiftly and toolchains so that it can be unattended. We assume that you have working understanding of your build system. The examples are based on a typical Unix environment. | ||
|
||
First, download a swiftly binary from a trusted source, such as your artifact repository, or a well-known website for the operating system (e.g. Linux) and processor architecture (e.g. arm64, or x86_64). Here's an example using the popular curl command. | ||
|
||
``` | ||
curl -L <trusted_location_of_swiftly> > swiftly | ||
``` | ||
|
||
> 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. | ||
|
||
Once swiftly is downloaded you can run the init subcommand to finish the installation. This command will use the default initialization options and proceed without prompting. | ||
|
||
``` | ||
./swiftly init --assume-yes | ||
``` | ||
|
||
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 (and users): | ||
|
||
``` | ||
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 recalcuate 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. The usual next step is to install a specific swift toolchain like this: | ||
|
||
``` | ||
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: | ||
|
||
``` | ||
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. | ||
|
||
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.) | ||
``` | ||
|
||
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: | ||
|
||
``` | ||
swiftly init --platform=<platform_name> | ||
``` | ||
|
||
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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,12 @@ To download swiftly and install Swift, run the following in your terminal, then | |
curl -L https://swiftlang.github.io/swiftly/swiftly-install.sh | bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We either need to edit this script to download the correct version of swiftly (Linux or mac) and run swiftly init or get rid of this line in the docs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the same kind of problem with the readme. People might be reading this from the main branch of swiftpackageindex.com and want the latest release, which is using the shell script installer. We'll need to sweep all of the documentation when we release to switch over to the new method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok we should create a separate PR with documentation changes |
||
``` | ||
|
||
Alternatively, you can download the swiftly binary and install itself like this: | ||
|
||
``` | ||
swiftly init | ||
``` | ||
|
||
Once swiftly is installed you can use it to install the latest available swift toolchain like this: | ||
|
||
``` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,11 @@ To download swiftly and install Swift, run the following in your terminal, then | |
curl -L https://swiftlang.github.io/swiftly/swiftly-install.sh | bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We either need to edit this script to download the correct version of swiftly (Linux or mac) and run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is tricky since this README is one of the places where people see how to install swiftly, but it's a few commits newer than the last release. Also, it's unclear if we are going to cut a release or not that still makes use of the shell script, which will still technically work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should stick to one installation method. If we add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah that's probably a good idea ... i think the maximum installation complexity i'd expect is "choose macOS or linux". Even that can probably be avoided in the script. Hopefully no manual architecture detection "are you on arm64 or amd64?!". manually choosing the arch is not the end of the world, but it can be harder than it looks, to beginners. |
||
``` | ||
|
||
Alternatively, you can download the swiftly binary and it can install itself: | ||
``` | ||
swiftly init | ||
``` | ||
|
||
### Basic usage | ||
|
||
``` | ||
|
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.
Need to make it clear this is for Linux, maybe provide macOS version as well
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.
env.sh
is not accurate, forfish
, it'll beenv.fish
.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.
Right, I'm hoping to make this an illustrative example of something that an integrator would look for from the swiftly output so that they can automate it. I'll see if I can make the description above highlight that this is just an example and can be different depending on the environment (e.g. Windows or Fish)