Swift CLI release tool for Git repos and Swift Packages
You can install Rocket with SPM
- Add or amend a Package.swift
- Add this dependency
.package(url: "https://github.com/f-meloni/Rocket", from: "0.1.0")
- Then you can run
swift run rocket 1.0.0
where1.0.0
is the version that you want to release
Create a file called .rocket.yml
with your steps inside
---
steps:
- script:
content: ruby Scripts/update_changelog.rb
- git_add:
paths:
- CHANGELOG.md
- commit:
message: "Releasing version $VERSION"
- tag
- push
With PackageConfig (https://github.com/orta/PackageConfig) you can put the configuration at the end of your Package.swift
#if canImport(PackageConfig)
import PackageConfig
let config = PackageConfig([
"rocket": ["steps":
[
["script": ["content": "ruby Scripts/update_changelog.rb"]]
["git_add": ["paths": ["CHANGELOG.md"]]],
["commit": ["message": "Releasing version $VERSION"]],
"tag",
"push"
]
]
])
If you use the before
and/or after
keys
e.g.
---
before:
- script:
content: echo "Testing Release for $VERSION"
after:
- script:
content: echo "released $VERSION"
Rocket will execute some default steps between the before and after steps:
-
echo "Testing Release for $VERSION"
-
hide_dev_dependencies
-
commit
-
unhide_dev_dependencies
-
commit (message: "Unhide dev dependencies")
-
echo "released $VERSION"
When you release a package you want that who adds it as dependency downloads just the dependencies that are really needed to your package.
This is why Rocket introduces the concept of dev dependency, if you have in your package some scripts e.g. swiftformat you can add them as dev dependencies (by adding // dev
after them) and they will be commented by the hide_dev_dependencies
step and uncommented from the unhide_dev_dependencies
.
That is also valid for the dependencies that are used just from test targets, but in that case you will have to add the test target as dev dependency too.
Some examples are:
- https://github.com/danger/swift/blob/master/Package.swift
- https://github.com/f-meloni/Rocket/blob/master/Package.swift
- https://github.com/f-meloni/Logger/blob/master/Package.swift
Runs a command line script
Parameters:
content: String
(required): the script content
Adds the files to the git's staging area
Parameters:
paths: [String]
(optional): The paths you want to add to the staging area - default: [.]
Commits on git
Parameters:
message: String
(optional): The commit message - default: "Version $VERSION"
no_verify: Bool
(optional): bypasses the pre-commit and commit-msg hooks default: false
Tags the current version
Pushes the current changes
Parameters:
remote: String
(optional): The name of the remote you want to push to - default: "origin"
branch: String
(optional): The name of the branch you want to push - default: "master"
Comment the dev dependencies on your Package.swift
to avoid them to be shipped with your release
Dev dependencies are all the lines in the Package.swift
file with // dev
Parameters:
package_path: String
(optional): The relative path to your Package.swift
file - default: "Package.swift"
Uncomment the dev dependencies on your Package.swift
after you released.
Parameters:
package_path: String
(optional): The relative path to your Package.swift
file - default: "Package.swift"
Compile and run a script file written in swift
The version is passed to the script as first parameter
Parameters:
script_path: String
(required): The relative path to the swift script
arguments: [String]
(optional): Additional arguments for the swift script
You can use the variable $VERSION
inside the steps to refer to the version you are releasing
- Add a step to execute script files written in swift
- Add a step to comment the dev dependencies on the
Package.swift
- Add a step to create Github releases