Skip to content

Commit 9669ae8

Browse files
committed
Merge branch 'main' of github.com:cmcgee1024/swiftly into reduce_gh_action_prep
2 parents e8cd991 + 150e93a commit 9669ae8

File tree

20 files changed

+369
-131
lines changed

20 files changed

+369
-131
lines changed

.github/workflows/build_release.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
description: "Version of swiftly to build release artifacts"
88
required: true
99
type: string
10-
default: "0.3.0"
10+
default: "0.4.0-dev"
1111
skip:
1212
description: "Perform release checks, such as the git tag, and swift version, or '--skip' to skip that."
1313
required: true
@@ -23,10 +23,19 @@ jobs:
2323
steps:
2424
- name: Checkout repository
2525
uses: actions/checkout@v4
26-
- name: Build Artifact
27-
run: swift run build-swiftly-release ${{ inputs.skip }} ${{ inputs.version }}
28-
- name: Upload Artifact
26+
- name: Build Release Artifact
27+
run: swift run build-swiftly-release --use-rhel-ubi9 ${{ inputs.skip }} ${{ inputs.version }}
28+
- name: Upload Release Artifact
2929
uses: actions/upload-artifact@v4
3030
with:
31+
name: swiftly-release-x86_64
3132
path: .build/release/swiftly-*.tar.gz
3233
if-no-files-found: error
34+
- name: Build Documentation Artifacts
35+
run: swift package --allow-writing-to-directory .build/docs generate-documentation --target SwiftlyDocs --output-path .build/docs
36+
- name: Upload Documentation Artifacts
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: swiftly-docs
40+
path: .build/docs/**
41+
if-no-files-found: error

.github/workflows/pull_request.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jobs:
2323
name: Test
2424
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
2525
with:
26-
# Amazon Linux 2 won't work with GH infrastructure
2726
linux_os_versions: "[\"jammy\", \"focal\", \"rhel-ubi9\", \"noble\", \"bookworm\", \"fedora39\"]"
2827
# We only care about the current stable release, because that's where we make our swiftly releases
2928
linux_exclude_swift_versions: "[{\"swift_version\": \"nightly-main\"},{\"swift_version\": \"nightly-6.0\"},{\"swift_version\": \"5.8\"},{\"swift_version\": \"5.9\"},{\"swift_version\": \"5.10\"}]"
@@ -39,10 +38,11 @@ jobs:
3938
- name: Checkout repository
4039
uses: actions/checkout@v4
4140
- name: Build Artifact
42-
run: swift run build-swiftly-release --skip "999.0.0"
41+
run: swift run build-swiftly-release --use-rhel-ubi9 --skip "999.0.0"
4342
- name: Upload Artifact
4443
uses: actions/upload-artifact@v4
4544
with:
45+
name: swiftly-release-x86_64
4646
path: .build/release/swiftly-*.tar.gz
4747
if-no-files-found: error
4848
retention-days: 1
@@ -57,3 +57,25 @@ jobs:
5757
linux_pre_build_command: ./scripts/prep-gh-action.sh
5858
linux_build_command: swift run swiftformat --lint --dryrun . || (echo "Please run 'swift run swiftformat .' to format the source code."; exit 1)
5959
enable_windows_checks: false
60+
61+
docscheck:
62+
name: Documentation Check
63+
runs-on: ubuntu-latest
64+
container:
65+
image: "swift:6.0-noble"
66+
steps:
67+
- name: Checkout repository
68+
uses: actions/checkout@v4
69+
- name: Prepare the action
70+
run: ./scripts/prep-gh-action.sh && ./scripts/install-libarchive.sh
71+
- name: Generate Swiftly CLI Reference and Check for Differences
72+
run: swift package plugin --allow-writing-to-package-directory generate-docs-reference && git config --global --add safe.directory $(pwd) && git diff --exit-code Documentation/SwiftlyDocs.docc/swiftly-cli-reference.md || (echo "The documentation hasn't been updated with the latest swiftly command-line reference. Please run 'swift package plugin generate-docs-reference' and commit/push the changes."; exit 1)
73+
- name: Generate Documentation Set
74+
run: swift package --allow-writing-to-directory .build/docs generate-documentation --target SwiftlyDocs --output-path .build/docs
75+
- name: Upload Documentation Artifacts
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: swiftly-docs
79+
path: .build/docs/**
80+
if-no-files-found: error
81+
retention-days: 1

Documentation/SwiftlyDocs.docc/automated-install.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@ Swiftly can be installed automatically in places like build/CI systems.
44

55
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.
66

7-
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.
7+
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.
88

99
```
10-
curl -L <trusted_location_of_swiftly> > swiftly
10+
curl -L <location_of_swiftly_swift_org> > swiftly.tar.gz
11+
tar zxf swiftly.tar.gz
12+
```
13+
14+
On macOS you can download the pkg file and extract it like this from the command-line:
15+
16+
```
17+
curl -L <location_of_swiftly_swift_org> > swiftly.pkg
18+
installer -pkg swiftly.pkg -target CurrentUserHomeDirectory
1119
```
1220

1321
> 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.
1422
15-
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.
23+
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:
1624

1725
```
18-
./swiftly init --assume-yes
26+
./swiftly init --verbose --assume-yes --skip-install # the swiftly binary is extracted to ~/local/bin/swiftly on macOS
1927
```
2028

2129
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.

Documentation/SwiftlyDocs.docc/getting-started.md

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,45 @@
11
# Getting Started with Swiftly
22

3-
To download swiftly and install Swift, run the following in your terminal, then follow the on-screen instructions:
3+
Start using swiftly and swift.
44

5-
```
6-
curl -L https://swiftlang.github.io/swiftly/swiftly-install.sh | bash
7-
```
5+
To get started with swiftly you can download it from [swift.org](https://swift.org/download), and extract the package.
86

9-
Alternatively, you can download the swiftly binary and install itself like this:
7+
@TabNavigator {
8+
@Tab("Linux") {
9+
If you are using Linux then you can verify and extract the archive like this:
1010

11-
```
12-
swiftly init
13-
```
11+
```
12+
tar zxf swiftly-x.y.z.tar.gz
13+
```
1414

15-
Once swiftly is installed you can use it to install the latest available swift toolchain like this:
15+
Now run swiftly init to finish the installation:
1616

17-
```
18-
$ swiftly install latest
17+
```
18+
./swiftly init
19+
```
20+
}
1921

20-
Fetching the latest stable Swift release...
21-
Installing Swift 5.8.1
22-
Downloaded 488.5 MiB of 488.5 MiB
23-
Extracting toolchain...
24-
Swift 5.8.1 installed successfully!
22+
@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):
2524

25+
```
26+
installer -pkg swift-x.y.z.pkg -target CurrentUserHomeDirectory
27+
```
28+
29+
Now run swiftly init to finish the installation:
30+
31+
```
32+
~/usr/local/bin/swiftly init
33+
```
34+
}
35+
}
36+
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.
38+
39+
```
2640
$ swift --version
2741
28-
Swift version 5.8.1 (swift-5.8.1-RELEASE)
42+
Swift version 6.0.1 (swift-6.0.1-RELEASE)
2943
Target: x86_64-unknown-linux-gnu
3044
3145
$ swift build # Build with the latest (5.8.1) toolchain

Documentation/SwiftlyDocs.docc/swiftly-cli-reference.md

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ swiftly [--version] [--help]
2323
Install a new toolchain.
2424

2525
```
26-
swiftly install [<version>] [--use] [--verify|no-verify] [--post-install-file=<post-install-file>] [--assume-yes] [--version] [--help]
26+
swiftly install [<version>] [--use] [--verify|no-verify] [--post-install-file=<post-install-file>] [--assume-yes] [--verbose] [--version] [--help]
2727
```
2828

2929
**version:**
@@ -81,6 +81,11 @@ written to this file as commands that can be run after the installation.
8181
*Disable confirmation prompts by assuming 'yes'*
8282

8383

84+
**--verbose:**
85+
86+
*Enable verbose reporting from swiftly*
87+
88+
8489
**--version:**
8590

8691
*Show the version.*
@@ -143,7 +148,7 @@ Note that listing available snapshots before the latest release (major and minor
143148
Set the in-use toolchain. If no toolchain is provided, print the currently in-use toolchain, if any.
144149

145150
```
146-
swiftly use [--print-location] [--global-default] [--assume-yes] [<toolchain>] [--version] [--help]
151+
swiftly use [--print-location] [--global-default] [--assume-yes] [--verbose] [<toolchain>] [--version] [--help]
147152
```
148153

149154
**--print-location:**
@@ -161,6 +166,11 @@ swiftly use [--print-location] [--global-default] [--assume-yes] [<toolchain>] [
161166
*Disable confirmation prompts by assuming 'yes'*
162167

163168

169+
**--verbose:**
170+
171+
*Enable verbose reporting from swiftly*
172+
173+
164174
**toolchain:**
165175

166176
*The toolchain to use.*
@@ -210,7 +220,7 @@ Likewise, the latest snapshot associated with a given development branch can be
210220
Remove an installed toolchain.
211221

212222
```
213-
swiftly uninstall <toolchain> [--assume-yes] [--version] [--help]
223+
swiftly uninstall <toolchain> [--assume-yes] [--verbose] [--version] [--help]
214224
```
215225

216226
**toolchain:**
@@ -249,6 +259,11 @@ Finally, all installed toolchains can be uninstalled by specifying 'all':
249259
*Disable confirmation prompts by assuming 'yes'*
250260

251261

262+
**--verbose:**
263+
264+
*Enable verbose reporting from swiftly*
265+
266+
252267
**--version:**
253268

254269
*Show the version.*
@@ -309,7 +324,7 @@ The installed snapshots for a given devlopment branch can be listed by specifyin
309324
Update an installed toolchain to a newer version.
310325

311326
```
312-
swiftly update [<toolchain>] [--assume-yes] [--verify|no-verify] [--post-install-file=<post-install-file>] [--version] [--help]
327+
swiftly update [<toolchain>] [--assume-yes] [--verbose] [--verify|no-verify] [--post-install-file=<post-install-file>] [--version] [--help]
313328
```
314329

315330
**toolchain:**
@@ -355,6 +370,11 @@ A specific snapshot toolchain can be updated by including the date:
355370
*Disable confirmation prompts by assuming 'yes'*
356371

357372

373+
**--verbose:**
374+
375+
*Enable verbose reporting from swiftly*
376+
377+
358378
**--verify|no-verify:**
359379

360380
*Verify the toolchain's PGP signature before proceeding with installation.*
@@ -385,7 +405,7 @@ written to this file as commands that can be run after the installation.
385405
Perform swiftly initialization into your user account.
386406

387407
```
388-
swiftly init [--no-modify-profile] [--overwrite] [--platform=<platform>] [--assume-yes] [--version] [--help]
408+
swiftly init [--no-modify-profile] [--overwrite] [--platform=<platform>] [--skip-install] [--assume-yes] [--verbose] [--version] [--help]
389409
```
390410

391411
**--no-modify-profile:**
@@ -400,14 +420,24 @@ swiftly init [--no-modify-profile] [--overwrite] [--platform=<platform>] [--assu
400420

401421
**--platform=\<platform\>:**
402422

403-
*Specify the current Linux platform for swiftly.*
423+
*Specify the current Linux platform for swiftly*
424+
425+
426+
**--skip-install:**
427+
428+
*Skip installing the latest toolchain*
404429

405430

406431
**--assume-yes:**
407432

408433
*Disable confirmation prompts by assuming 'yes'*
409434

410435

436+
**--verbose:**
437+
438+
*Enable verbose reporting from swiftly*
439+
440+
411441
**--version:**
412442

413443
*Show the version.*
@@ -425,9 +455,19 @@ swiftly init [--no-modify-profile] [--overwrite] [--platform=<platform>] [--assu
425455
Update the version of swiftly itself.
426456

427457
```
428-
swiftly self-update [--version] [--help]
458+
swiftly self-update [--assume-yes] [--verbose] [--version] [--help]
429459
```
430460

461+
**--assume-yes:**
462+
463+
*Disable confirmation prompts by assuming 'yes'*
464+
465+
466+
**--verbose:**
467+
468+
*Enable verbose reporting from swiftly*
469+
470+
431471
**--version:**
432472

433473
*Show the version.*

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ Ongoing maintenance and stewardship of this project is led by the [SSWG](https:/
66

77
### Installation
88

9-
To download swiftly and install Swift, run the following in your terminal, then follow the on-screen instructions.
9+
Install swiftly using a script (hosted from this repository) using the command:
10+
1011
```
1112
curl -L https://swiftlang.github.io/swiftly/swiftly-install.sh | bash
1213
```
1314

14-
Alternatively, you can download the swiftly binary and it can install itself:
15+
In the future, download the swiftly package from [swift.org](https://swift.org/download) and it can install itself with init:
16+
1517
```
1618
swiftly init
1719
```

Sources/LinuxPlatform/Linux.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public struct Linux: Platform {
327327
}
328328
}
329329

330-
public func install(from tmpFile: URL, version: ToolchainVersion) throws {
330+
public func install(from tmpFile: URL, version: ToolchainVersion, verbose: Bool) throws {
331331
guard tmpFile.fileExists() else {
332332
throw Error(message: "\(tmpFile) doesn't exist")
333333
}
@@ -348,7 +348,14 @@ public struct Linux: Platform {
348348
let relativePath = name.drop { c in c != "/" }.dropFirst()
349349

350350
// prepend /path/to/swiftlyHomeDir/toolchains/<toolchain> to each file name
351-
return toolchainDir.appendingPathComponent(String(relativePath))
351+
let destination = toolchainDir.appendingPathComponent(String(relativePath))
352+
353+
if verbose {
354+
SwiftlyCore.print("\(destination.path)")
355+
}
356+
357+
// prepend /path/to/swiftlyHomeDir/toolchains/<toolchain> to each file name
358+
return destination
352359
}
353360
}
354361

@@ -390,7 +397,7 @@ public struct Linux: Platform {
390397
FileManager.default.temporaryDirectory.appendingPathComponent("swiftly-\(UUID())")
391398
}
392399

393-
public func verifySignature(httpClient: SwiftlyHTTPClient, archiveDownloadURL: URL, archive: URL) async throws {
400+
public func verifySignature(httpClient: SwiftlyHTTPClient, archiveDownloadURL: URL, archive: URL, verbose: Bool) async throws {
394401
SwiftlyCore.print("Downloading toolchain signature...")
395402
let sigFile = self.getTempFilePath()
396403
let _ = FileManager.default.createFile(atPath: sigFile.path, contents: nil)
@@ -405,7 +412,7 @@ public struct Linux: Platform {
405412

406413
SwiftlyCore.print("Verifying toolchain signature...")
407414
do {
408-
try self.runProgram("gpg", "--verify", sigFile.path, archive.path)
415+
try self.runProgram("gpg", "--verify", sigFile.path, archive.path, quiet: !verbose)
409416
} catch {
410417
throw Error(message: "Signature verification failed: \(error).")
411418
}

0 commit comments

Comments
 (0)