Skip to content

Commit

Permalink
Improve the release script and publishing instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Oliveri committed Aug 31, 2018
1 parent f1f54da commit 582a62c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
33 changes: 27 additions & 6 deletions Scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# Note that this script must be executed from the root directory
# of the swift-sdk, NOT inside the Scripts directory

### IMPORTANT ###: Make sure you understand what this script does before executing it!
# Comment out the DANGER ZONE sections below if you want to be extra careful

declare -a allPods=(
"IBMWatsonAssistantV1.podspec"
"IBMWatsonConversationV1.podspec"
Expand All @@ -23,18 +26,36 @@ declare -a allPods=(
)

git fetch --tags
releaseVersion=$(git describe --abbrev=0 --tags)

# Update podspec versions and release to Cocoapods
for podspec in "${allPods[@]}"
do
podVersion=$(grep -o 'version.*=.*[0-9]' $podspec | cut -f 2 -d "'")
latestRelease=$(git describe --abbrev=0 --tags)
podVersion=$(grep -o 'version.*=.*[0-9.][0-9.][0-9]' $podspec | cut -f 2 -d "'")
# Only release to Cocoapods if the pod's version is behind the latest git tag version
if [[ $latestRelease > $podVersion ]]; then
sed -i '' -e "/s.version/s/${podVersion}/${latestRelease}/g" $podspec
pod trunk push $podspec
if [[ $releaseVersion > $podVersion ]]; then
sed -i '' -e "/s.version/s/${podVersion}/${releaseVersion}/g" $podspec
### DANGER ZONE ###
pod trunk push $podspec --allow-warnings
### DANGER ZONE ###
fi
done

# Update README with new version
readmeVersion=$(grep -m 1 -o '~>.*[0-9.][0-9.][0-9]' README.md | cut -f 2 -d " ")
sed -i '' -e "s/${readmeVersion}/${releaseVersion}/g" README.md


# Commit the podspec updates, move the git tag, and push to Github
git add *.podspec
git commit -m "Release SDK version ${releaseVersion}"
### DANGER ZONE ###
git push
### DANGER ZONE ###
git tag -d $releaseVersion
git push --delete origin $releaseVersion
git tag $releaseVersion
git push origin $releaseVersion

# Builds WatsonDeveloperCloud.framework.zip, which needs to be uploaded to Github under the latest release
sh ./Scripts/generate-binaries.sh
sh ./Scripts/generate-binaries.sh
11 changes: 8 additions & 3 deletions docs/publishing-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ The following tasks should be completed before publishing a release. Track the p

#### Publish Release

- [ ] After pull request is merged into master, create a new git tag on the latest commit in master, and push to Github
- [ ] Add release notes on Github, explaining what changed in this version
- [ ] Execute `Scripts/release.sh` to publish new version to Cocoapods and build the SDK archive `WatsonDeveloperCloud.framework.zip`
**Note**: Perform these steps in your side branch, *after* getting approvals on your code reviews, but *before* merging your pull request to master.

- [ ] Create a new git tag (with the new version) on the latest commit in master, and push to Github
- [ ] [**Optional**] If you haven't done so, get set up with [Cocoapods Trunk](https://guides.cocoapods.org/making/getting-setup-with-trunk.html). You will need to be given permissions by an owner of this SDK to release to Cocoapods.
- [ ] Execute `Scripts/release.sh` to publish new version to Cocoapods and build the SDK archive `WatsonDeveloperCloud.framework.zip`.
**IMPORTANT**: Make sure you understand how the `release.sh` script works before using it! It can be dangerous. If in doubt, go through the manual release process for Cocoapods, and run `Scripts/generate-binaries` to build the zip file.
- [ ] Attach `WatsonDeveloperCloud.framework.zip` to the new Github release
- [ ] Add release notes on Github, explaining what changed in this version
- [ ] Test that the new version can be successfully installed in a new app using Carthage and Cocoapods
- [ ] Merge to master!

0 comments on commit 582a62c

Please sign in to comment.