diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..101878577 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,38 @@ +name: 'Release' +on: + release: + # runs for stable and pre-releases + types: [published] + +jobs: + cancel-previous-workflow: + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@01ce38bf961b4e243a6342cbade0dbc8ba3f0432 # pin@0.12.0 + with: + access_token: ${{ github.token }} + + release: + name: Release + runs-on: macos-latest + env: + COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} # Using Manoel's token for now + + steps: + - name: Git checkout + uses: actions/checkout@v4 + + - name: Install Cocoapods + run: gem install cocoapods + + - name: Update version + run: ./scripts/bump-version.sh ${{ github.event.release.tag_name }} + + - name: Commit & push + run: | + echo "Tag name from github.ref_name: ${{ github.event.release.target_commitish }}" + ./scripts/commit-code.sh ${{ github.event.release.target_commitish }} + + - name: Release + run: make releaseCocoaPods diff --git a/CHANGELOG.md b/CHANGELOG.md index de7bced9f..e52a73074 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Next +## 3.0.0-alpha.1 + +- First alpha of the new major version of the iOS SDK + ## 2.1.0 - 2023-10-10 - isFeatureEnabled now returns false if disabled [#74](https://github.com/PostHog/posthog-ios/pull/74) diff --git a/Makefile b/Makefile index a33074c47..a17e2e479 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build buildSdk buildExample format swiftLint swiftFormat test lint bootstrap +.PHONY: build buildSdk buildExample format swiftLint swiftFormat test lint bootstrap releaseCocoaPods build: buildSdk buildExample @@ -27,3 +27,6 @@ bootstrap: gem install xcpretty brew install swiftlint brew install swiftformat + +releaseCocoaPods: + pod trunk push PostHog.podspec --allow-warnings diff --git a/PostHog/PostHogVersion.swift b/PostHog/PostHogVersion.swift index 1e2bac0b2..9a12a4db9 100644 --- a/PostHog/PostHogVersion.swift +++ b/PostHog/PostHogVersion.swift @@ -7,4 +7,5 @@ import Foundation +// if you change this, make sure to also change it in the podspec and check if the script scripts/bump-version.sh still works let postHogVersion = "3.0.0-alpha.1" diff --git a/PostHog/Utils/Data+Gzip.swift b/PostHog/Utils/Data+Gzip.swift index 1ff4d0f41..37a76f34f 100644 --- a/PostHog/Utils/Data+Gzip.swift +++ b/PostHog/Utils/Data+Gzip.swift @@ -28,7 +28,7 @@ */ // issues importing scoped classes -//import struct Foundation.Data +// import struct Foundation.Data import Foundation #if os(Linux) diff --git a/PostHogTests/PostHogTest.swift b/PostHogTests/PostHogTest.swift index c40446b4a..f4ae5e312 100644 --- a/PostHogTests/PostHogTest.swift +++ b/PostHogTests/PostHogTest.swift @@ -1,6 +1,6 @@ +import Foundation import Nimble import Quick -import Foundation @testable import PostHog diff --git a/PostHogTests/SessionManagerTest.swift b/PostHogTests/SessionManagerTest.swift index 60f051fa9..cdea13026 100644 --- a/PostHogTests/SessionManagerTest.swift +++ b/PostHogTests/SessionManagerTest.swift @@ -5,10 +5,10 @@ // Created by Ben White on 22.03.23. // +import Foundation import Nimble @testable import PostHog import Quick -import Foundation class SessionManagerTest: QuickSpec { override func spec() { diff --git a/PostHogTests/StorageTest.swift b/PostHogTests/StorageTest.swift index 97bc0f1d3..13a56c050 100644 --- a/PostHogTests/StorageTest.swift +++ b/PostHogTests/StorageTest.swift @@ -5,9 +5,9 @@ // Created by Ben White on 08.02.23. // +import Foundation import Nimble import Quick -import Foundation @testable import PostHog diff --git a/RELEASING.md b/RELEASING.md index fddd0ffd1..330968899 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,22 +1,14 @@ -# Releasing - -1. Update the version in `PostHog.podspec`, `PostHog/Info.plist`, and `version` in `PostHog/Classes/PHGPostHog.m` to the next release version. -2. Update the `CHANGELOG.md` for the impending release. -3. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version). -4. `git tag -a X.Y.Z -m "Version X.Y.Z"` (where X.Y.Z is the new version). -5. `git push && git push --tags`. -6. `pod trunk push PostHog.podspec --allow-warnings`. -7. Go to [GH Releases](https://github.com/PostHog/posthog-ios/releases) and create a new release from the tag you just pushed. Copy the changelog entry into the description and publish the release. - -## On Apple Silicon - -Run this first: - -```bash -sudo arch -x86_64 gem install ffi -arch -x86_64 pod install -``` - -Then, [configure XCode CLI tools](https://stackoverflow.com/questions/29108172/how-do-i-fix-the-xcrun-unable-to-find-simctl-error). - -Finally, prepend `arch -x86_64` to the pod command in the steps above. +Releasing +========= + + 1. Update the CHANGELOG.md with the version and date + 2. Go to [GH Releases](https://github.com/PostHog/posthog-ios/releases) + 3. Choose a tag name (e.g. `3.0.0`), this is the version number of the release. + 1. Preview releases follow the pattern `3.0.0-alpha.1`, `3.0.0-beta.1`, `3.0.0-RC.1` + 4. Choose a release name (e.g. `3.0.0`), ideally it matches the above. + 5. Write a description of the release. + 6. Publish the release. + 7. GH Action (release.yml) is doing everything else automatically. + 1. SPM uses the tag name to determine the version, directly from the repo. + 2. CocoaPods are published. + 8. Done. diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh new file mode 100755 index 000000000..7ef882a81 --- /dev/null +++ b/scripts/bump-version.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# ./scripts/bump-version.sh +# eg ./scripts/bump-version.sh "3.0.0-alpha.1" + +set -eux + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $SCRIPT_DIR/.. + +NEW_VERSION="$1" + +# Replace `postHogVersion` with the given version +perl -pi -e "s/postHogVersion = \".*\"/postHogVersion = \"$NEW_VERSION\"/" PostHog/PostHogVersion.swift + +# Replace `s.version` with the given version +perl -pi -e "s/s.version = \".*\"/s.version = \"$NEW_VERSION\"/" PostHog.podspec diff --git a/scripts/commit-code.sh b/scripts/commit-code.sh new file mode 100755 index 000000000..28b071dd9 --- /dev/null +++ b/scripts/commit-code.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -euo pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $SCRIPT_DIR/.. + +GITHUB_BRANCH="${1}" + +if [[ $(git status) == *"nothing to commit"* ]]; then + echo "Nothing to commit." +else + echo "Going to push the changes." + git config --global user.name 'PostHog Github Bot' + git config --global user.email 'github-bot@posthog.com' + git fetch + git checkout ${GITHUB_BRANCH} + git commit -am "Update version" + git push --set-upstream origin ${GITHUB_BRANCH} +fi