| 
4 | 4 | 
 
  | 
5 | 5 |   | 
6 | 6 | 
 
  | 
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.  | 
8 | 8 | 
 
  | 
9 | 9 | 
 
  | 
10 | 10 | ## Scripts  | 
11 | 11 | 
 
  | 
12 |  | -The `scripts` filder contains the following scripts:  | 
 | 12 | +The `scripts` folder contains the following scripts:  | 
13 | 13 | 
 
  | 
14 |  | -* `build.sh` - Run builds for all provided platforms.  | 
 | 14 | +* `build.sh` - Build a target for all or some platforms.  | 
15 | 15 | * `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.  | 
18 | 18 | * `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.  | 
21 | 19 | * `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.  | 
30 | 26 | 
 
  | 
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`.  | 
32 | 28 | 
 
  | 
33 | 29 | 
 
  | 
 | 30 | +## GitHub Actions  | 
34 | 31 | 
 
  | 
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:  | 
46 | 33 | 
 
  | 
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.  | 
50 | 37 | 
 
  | 
 | 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.  | 
51 | 39 | 
 
  | 
52 | 40 | 
 
  | 
53 |  | -## Sync scripts  | 
 | 41 | +## Installation  | 
54 | 42 | 
 
  | 
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:  | 
56 | 44 | 
 
  | 
57 |  | -```shell  | 
58 |  | -./sync_to.sh ../MyOtherProject  | 
 | 45 | +```  | 
 | 46 | +git clone https://github.com/danielsaidi/SwiftPackageScripts.git  | 
59 | 47 | ```  | 
60 | 48 | 
 
  | 
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.  | 
64 | 50 | 
 
  | 
65 | 51 | ```shell  | 
66 |  | -./scripst/sync_from.sh ../SwiftPackageScripts  | 
 | 52 | +./sync_to.sh ../AnotherProjectFolder  | 
67 | 53 | ```  | 
68 | 54 | 
 
  | 
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.  | 
71 | 56 | 
 
  | 
72 | 57 | 
 
  | 
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  | 
107 | 59 | 
 
  | 
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.  | 
110 | 61 | 
 
  | 
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; }  | 
115 | 62 | 
 
  | 
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  | 
123 | 64 | 
 
  | 
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.  | 
125 | 66 | 
 
  | 
126 | 67 | 
 
  | 
 | 68 | +## Documentation  | 
127 | 69 | 
 
  | 
128 |  | -## Package-specific scripts  | 
 | 70 | +For more information about these scripts, and how to set up project-specific scripts, see the online [here][Documentation].  | 
129 | 71 | 
 
  | 
130 |  | -The `package_` prefixed scripts will by default grab the target name from the main `Package.swift` file.  | 
131 | 72 | 
 
  | 
132 |  | -You can still pass in custom branches and platforms to these scripts, if you want to customize them.  | 
 | 73 | +## Contact  | 
133 | 74 | 
 
  | 
 | 75 | +Feel free to reach out if you have questions or if you want to contribute in any way:  | 
134 | 76 | 
 
  | 
 | 77 | +* Website: [danielsaidi.com][Website]  | 
 | 78 | +* Mastodon: [@danielsaidi@mastodon.social][Mastodon]  | 
 | 79 | +* Twitter: [@danielsaidi][Twitter]  | 
 | 80 | +* E-mail: [daniel.saidi@gmail.com][Email]  | 
135 | 81 | 
 
  | 
136 |  | -## Sample Package  | 
137 | 82 | 
 
  | 
138 |  | -This repository has a sample package that is used to test that everything works as expected.  | 
 | 83 | +## License  | 
139 | 84 | 
 
  | 
 | 85 | +Swift Package Scripts is available under the MIT license. See the [LICENSE][License] file for more info.  | 
140 | 86 | 
 
  | 
141 | 87 | 
 
  | 
142 | 88 | [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  | 
146 | 93 | [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  | 
0 commit comments