Skip to content

Commit 8c533d6

Browse files
committed
Update scripts to support help and complex parameters
1 parent 8101d00 commit 8c533d6

27 files changed

+1291
-704
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
with:
2121
xcode-version: latest-stable
2222
- name: Build for all platforms
23-
run: bash scripts/build.sh ${{ github.event.repository.name }}
23+
run: bash scripts/build.sh

.github/workflows/docc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
with:
3737
xcode-version: latest-stable
3838
- name: Build DocC
39-
run: bash scripts/docc.sh ${{ github.event.repository.name }}
39+
run: bash scripts/docc.sh
4040
- name: Upload Artifact
4141
uses: actions/upload-pages-artifact@v3
4242
with:

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
with:
2121
xcode-version: latest-stable
2222
- name: Run tests for all platforms
23-
run: bash scripts/test.sh ${{ github.event.repository.name }}
23+
run: bash scripts/test.sh

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Daniel Saidi
3+
Copyright (c) 2024-2025 Daniel Saidi
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 28 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,92 +13,72 @@
1313

1414
# Swift Package Scripts
1515

16-
Swift Package Scripts has scripts that let you build and test your Swift Package, generate DocC documentation & XCFrameworks, and create new versions.
16+
Swift Package Scripts has Terminal scripts that can build and test your Swift Package, build DocC documentation and deploy it to GitHub Pages, generate XCFramework zip files, and create new semantic versions.
1717

1818

1919
## Scripts
2020

21-
The `scripts` filder contains the following scripts:
21+
The `scripts` folder contains the following scripts:
2222

23-
* `build.sh` - Run builds for all provided platforms.
23+
* `build.sh` - Build a target for all or some platforms.
2424
* `chmod.sh` - Runs `chmod +x` on all scripts in the script folder.
25-
* `docc.sh` - Build DocC documentation for all provided platforms.
26-
* `framework.sh` - Build an XCFramework for all provided platforms.
25+
* `docc.sh` - Build DocC documentation for all or some platforms.
26+
* `framework.sh` - Build an XCFramework for all or some platforms.
2727
* `git_default_branch.sh` - Get the default git branch name.
28-
* `package_docc.sh` - Build DocC documentation for the main Swift package.
29-
* `package_framework.sh` - Build an XCFramework for the main Swift package.
3028
* `package_name.sh` - Get the name of the main Swift package.
31-
* `package_version.sh` - Create a new version for the main Swift package.
32-
* `sync_from.sh` - Sync the scripts folder from a Swift Package Scripts folder.
33-
* `test.sh` - Run the project unit tests for all provided platforms.
34-
* `version.sh` - Create a new version with validation and test steps.
35-
* `version_bump.sh` - Bump the version number and push a new version tag.
36-
* `version_number.sh` - Get the current git version number.
37-
* `version_validate_git.sh` - Validate that a git repo is ready for release.
38-
* `version_validate_target.sh` - Validate that a target is ready for release.
29+
* `release.sh` - Make a release build with several validation steps.
30+
* `release_validate.sh` - Validate the current branch for release.
31+
* `sync_from.sh` - Sync `scripts` from a Swift Package Scripts folder.
32+
* `test.sh` - Test a target on all or some platforms.
33+
* `version_bump.sh` - Bump the current version number and create a new tag.
34+
* `version_number.sh` - Get the current version number from the latest tag.
3935

40-
Note that you may have to run `chmod +x <SCRIPT>` to be able to run a script.
36+
Note that you have to run `chmod +x <SCRIPT>` to be able to run a script for the first time. You can use `chmod.sh` to do this for all `scripts`.
4137

4238

39+
## GitHub Actions
4340

44-
## Installation
45-
46-
Swift Package Scripts can be installed to your computer by cloning the repository:
47-
48-
```
49-
git clone https://github.com/danielsaidi/SwiftPackageScripts.git
50-
```
41+
The `.github` folder contains the following GitHub Actions workflows:
5142

52-
You can then navigate to the folder and sync the scripts to any older folder on your machine.
43+
* `build.yml` - Build the package for all or some platforms.
44+
* `docc.yml` - Build DocC documentation and deploy it to GitHub Pages.
45+
* `test.yml` - Test the package on all or some platforms.
5346

47+
These workflows use `main` as git branch. Change this in each file to trigger the workflows for other branches. As the files are not part of the sync, you have to copy them manually.
5448

5549

56-
## Support My Work
57-
58-
You can [become a sponsor][Sponsors] to help me dedicate more time on my various [open-source tools][OpenSource]. Every contribution, no matter the size, makes a real difference in keeping these tools free and actively developed.
59-
60-
61-
62-
## Sync scripts
50+
## Installation
6351

64-
The `sync_to.sh` script can be used to sync the entire `scripts` folder to another folder:
52+
Swift Package Scripts can be installed to your computer by cloning the repository:
6553

66-
```shell
67-
./sync_to.sh ../MyOtherProject
54+
```
55+
git clone https://github.com/danielsaidi/SwiftPackageScripts.git
6856
```
6957

70-
This will remove any already existing folder, and replace it with the latest version.
71-
72-
You can also run `scripts/sync_from.sh` from another folder, to update its scripts folder:
58+
You can then navigate to the folder and sync the scripts to any older folder, using the `scripts/sync_to.sh` script.
7359

7460
```shell
75-
./scripst/sync_from.sh ../SwiftPackageScripts
61+
./sync_to.sh ../AnotherProjectFolder
7662
```
7763

78-
This means that you can easily keep your projects in sync with your local copy of this project.
79-
80-
64+
This will remove any already existing folder, and replace it with the latest version. After the first sync, you can use `scripts/sync_from.sh` in the project folder to sync from another folder.
8165

82-
## GitHub integrations
8366

84-
The `.github/workflows` folder contains `build` and `docc` runner files that are used to run tests and build DocC documentation with GitHub Actions on every push to the main branch.
85-
86-
These GitHub scripts are not part of the sync. You can manually copy them to your own project to integrate these scripts with GitHub Actions.
67+
## Support My Work
8768

69+
You can [become a sponsor][Sponsors] to help me dedicate more time on my various [open-source tools][OpenSource]. Every contribution, no matter the size, makes a real difference in keeping these tools free and actively developed.
8870

8971

9072
## Sample Package
9173

9274
This repository has a sample package that is used to test that everything works as expected.
9375

9476

95-
9677
## Documentation
9778

9879
For more information about these scripts, and how to set up project-specific scripts, see the online [here][Documentation].
9980

10081

101-
10282
## Contact
10383

10484
Feel free to reach out if you have questions or if you want to contribute in any way:
@@ -109,11 +89,9 @@ Feel free to reach out if you have questions or if you want to contribute in any
10989
* E-mail: [daniel.saidi@gmail.com][Email]
11090

11191

112-
11392
## License
11493

115-
SystemNotification is available under the MIT license. See the [LICENSE][License] file for more info.
116-
94+
Swift Package Scripts is available under the MIT license. See the [LICENSE][License] file for more info.
11795

11896

11997
[Email]: mailto:daniel.saidi@gmail.com

RELEASE_NOTES.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
# RELEASE NOTES
22

33

4+
## 1.0
5+
6+
This version updates all `.github` and `scripts` scripts.
7+
8+
## ✨ Features
9+
10+
* `scripts` are rewritten from scratch with better argument parsing and --help support.
11+
* `scripts` that need a target now use the package name as default target, if possible.
12+
13+
## 💡 Changes
14+
15+
* `.github` no longer pass in repository name as target, which makes them less brittle.
16+
17+
## 💥 Breaking changes
18+
19+
* `scripts` now use a different input argument format.
20+
* `scripts` no longer contains package-specific scripts.
21+
22+
23+
424
## 0.5
525

626
This version updates all `.github` and `scripts` scripts.

Sources/SwiftPackageScripts/Documentation.docc/SwiftPackageScripts.md

Lines changed: 47 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -4,143 +4,94 @@
44

55
![SwiftPackageScripts logotype](Logo.png)
66

7-
Swift Package Scripts has scripts that let you easily build and test your Swift Package, generate DocC documentation and XCFrameworks, and create new versions.
7+
Swift Package Scripts has Terminal scripts that can build and test your Swift Package, build DocC documentation and deploy it to GitHub Pages, generate XCFramework zip files, and create new semantic versions.
88

99

1010
## Scripts
1111

12-
The `scripts` filder contains the following scripts:
12+
The `scripts` folder contains the following scripts:
1313

14-
* `build.sh` - Run builds for all provided platforms.
14+
* `build.sh` - Build a target for all or some platforms.
1515
* `chmod.sh` - Runs `chmod +x` on all scripts in the script folder.
16-
* `docc.sh` - Build DocC documentation for all provided platforms.
17-
* `framework.sh` - Build an XCFramework for all provided platforms.
16+
* `docc.sh` - Build DocC documentation for all or some platforms.
17+
* `framework.sh` - Build an XCFramework for all or some platforms.
1818
* `git_default_branch.sh` - Get the default git branch name.
19-
* `package_docc.sh` - Build DocC documentation for the main Swift package.
20-
* `package_framework.sh` - Build an XCFramework for the main Swift package.
2119
* `package_name.sh` - Get the name of the main Swift package.
22-
* `package_version.sh` - Create a new version for the main Swift package.
23-
* `sync_from.sh` - Sync the scripts folder from a Swift Package Scripts folder.
24-
* `test.sh` - Run the project unit tests for all provided platforms.
25-
* `version.sh` - Create a new version with validation and test steps.
26-
* `version_bump.sh` - Bump the version number and push a new version tag.
27-
* `version_number.sh` - Get the current git version number.
28-
* `version_validate_git.sh` - Validate that a git repo is ready for release.
29-
* `version_validate_target.sh` - Validate that a target is ready for release.
20+
* `release.sh` - Make a release build with several validation steps.
21+
* `release_validate.sh` - Validate the current branch for release.
22+
* `sync_from.sh` - Sync `scripts` from a Swift Package Scripts folder.
23+
* `test.sh` - Test a target on all or some platforms.
24+
* `version_bump.sh` - Bump the current version number and create a new tag.
25+
* `version_number.sh` - Get the current version number from the latest tag.
3026

31-
Note that you may have to run `chmod +x <SCRIPT>` to be able to run a script.
27+
Note that you have to run `chmod +x <SCRIPT>` to be able to run a script for the first time. You can use `chmod.sh` to do this for all `scripts`.
3228

3329

30+
## GitHub Actions
3431

35-
## Installation
36-
37-
Swift Package Scripts can be installed to your computer by cloning the repository:
38-
39-
```
40-
git clone https://github.com/danielsaidi/SwiftPackageScripts.git
41-
```
42-
43-
You can then navigate to the folder and sync the scripts to any older folder on your machine.
44-
45-
32+
The `.github` folder contains the following GitHub Actions workflows:
4633

47-
## Support My Work
48-
49-
You can [become a sponsor][Sponsors] to help me dedicate more time on my various [open-source tools][OpenSource]. Every contribution, no matter the size, makes a real difference in keeping these tools free and actively developed.
34+
* `build.yml` - Build the package for all or some platforms.
35+
* `docc.yml` - Build DocC documentation and deploy it to GitHub Pages.
36+
* `test.yml` - Test the package on all or some platforms.
5037

38+
These workflows use `main` as git branch. Change this in each file to trigger the workflows for other branches. As the files are not part of the sync, you have to copy them manually.
5139

5240

53-
## Sync scripts
41+
## Installation
5442

55-
The `sync_to.sh` script can be used to sync the entire `scripts` folder to another folder:
43+
Swift Package Scripts can be installed to your computer by cloning the repository:
5644

57-
```shell
58-
./sync_to.sh ../MyOtherProject
45+
```
46+
git clone https://github.com/danielsaidi/SwiftPackageScripts.git
5947
```
6048

61-
This will remove any already existing folder, and replace it with the latest version.
62-
63-
You can also run `scripts/sync_from.sh` from another folder, to update its scripts folder:
49+
You can then navigate to the folder and sync the scripts to any older folder, using the `scripts/sync_to.sh` script.
6450

6551
```shell
66-
./scripst/sync_from.sh ../SwiftPackageScripts
52+
./sync_to.sh ../AnotherProjectFolder
6753
```
6854

69-
This means that you can easily keep your projects in sync with your local copy of this project.
70-
55+
This will remove any already existing folder, and replace it with the latest version. After the first sync, you can use `scripts/sync_from.sh` in the project folder to sync from another folder.
7156

7257

73-
## GitHub integrations
74-
75-
The `.github/workflows` folder contains `build` and `docc` runner files, that are used by GitHub Actions to tests and update the GitHub hosted documentation on every push to the main branch.
76-
77-
78-
79-
## Project-specific scripts
80-
81-
While these scripts cover many use-cases, you may still want to create project-specific scripts.
82-
83-
For instance, a closed-source package that only targets iOS could set up a release script that always generates DocC, an XCFramework and a new version tag for the package:
84-
85-
```swift
86-
#!/bin/bash
87-
88-
# Documentation:
89-
# This package-specific script builds a new release of the package.
90-
# This script builds DocC, a framework, then creates a version tag.
91-
# You can pass in a custom BRANCH to make the non-main branch pass validation.
92-
93-
# Usage:
94-
# package_release.sh <BRANCH default:main>
95-
# e.g. `bash scripts/package_release.sh master`
96-
97-
# Exit immediately if a command exits with non-zero status
98-
set -e
99-
100-
# Get branch name
101-
BRANCH_NAME_SCRIPT="scripts/git_default_branch.sh"
102-
DEFAULT_BRANCH=$("$BRANCH_NAME_SCRIPT") || { echo "Failed to get branch name"; exit 1; }
103-
BRANCH_NAME=${1:-$DEFAULT_BRANCH}
104-
105-
# Define platforms
106-
PLATFORMS="iOS"
58+
## Support My Work
10759

108-
# Get package name
109-
PACKAGE_NAME=$("scripts/package_name.sh") || { echo "Failed to get package name"; exit 1; }
60+
You can [become a sponsor][Sponsors] to help me dedicate more time on my various [open-source tools][OpenSource]. Every contribution, no matter the size, makes a real difference in keeping these tools free and actively developed.
11061

111-
# Build all package deliverables
112-
bash "scripts/package_docc.sh" $PLATFORMS || { echo "DocC script failed"; exit 1; }
113-
bash "scripts/package_framework.sh" $PLATFORMS || { echo "Framework script failed"; exit 1; }
114-
bash "scripts/package_version.sh" $BRANCH_NAME || { echo "Version script failed"; exit 1; }
11562

116-
# Manual step - print checksum
117-
echo ""
118-
echo "***** CHECKSUM *****"
119-
swift package compute-checksum .build/$PACKAGE_NAME.zip
120-
echo "********************"
121-
echo ""
122-
```
63+
## Sample Package
12364

124-
This script mixed hard-coding certain always true factors, while allowing us to pass in a custom branch if needed.
65+
This repository has a sample package that is used to test that everything works as expected.
12566

12667

68+
## Documentation
12769

128-
## Package-specific scripts
70+
For more information about these scripts, and how to set up project-specific scripts, see the online [here][Documentation].
12971

130-
The `package_` prefixed scripts will by default grab the target name from the main `Package.swift` file.
13172

132-
You can still pass in custom branches and platforms to these scripts, if you want to customize them.
73+
## Contact
13374

75+
Feel free to reach out if you have questions or if you want to contribute in any way:
13476

77+
* Website: [danielsaidi.com][Website]
78+
* Mastodon: [@danielsaidi@mastodon.social][Mastodon]
79+
* Twitter: [@danielsaidi][Twitter]
80+
* E-mail: [daniel.saidi@gmail.com][Email]
13581

136-
## Sample Package
13782

138-
This repository has a sample package that is used to test that everything works as expected.
83+
## License
13984

85+
Swift Package Scripts is available under the MIT license. See the [LICENSE][License] file for more info.
14086

14187

14288
[Email]: mailto:daniel.saidi@gmail.com
143-
[Website]: https://danielsaidi.com
144-
[GitHub]: https://github.com/danielsaidi
145-
[OpenSource]: https://danielsaidi.com/opensource
89+
[Website]: https://www.danielsaidi.com
90+
[GitHub]: https://www.github.com/danielsaidi
91+
[Twitter]: https://www.twitter.com/danielsaidi
92+
[Mastodon]: https://mastodon.social/@danielsaidi
14693
[Sponsors]: https://github.com/sponsors/danielsaidi
94+
[OpenSource]: https://www.danielsaidi.com/opensource
95+
96+
[Documentation]: https://danielsaidi.github.io/SwiftPackageScripts/
97+
[License]: https://github.com/danielsaidi/SystemNotification/blob/master/LICENSE

package_version.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)