diff --git a/.circleci/config.yml b/.circleci/config.yml index fb249cad8..2cb824a5a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,14 +42,14 @@ commands: steps: - run: name: Dependencies - command: carthage bootstrap --platform all --cache-builds --configuration Debug --use-xcframeworks + command: carthage bootstrap --platform all --cache-builds --configuration Debug --use-xcframeworks install-mbx-ci: steps: - run: name: "Install MBX CI" command: | curl -Ls https://mapbox-release-engineering.s3.amazonaws.com/mbx-ci/latest/mbx-ci-darwin-amd64 > /usr/local/bin/mbx-ci - chmod 755 /usr/local/bin/mbx-ci + chmod 755 /usr/local/bin/mbx-ci setup-write-repo-access: steps: - run: @@ -61,6 +61,51 @@ commands: git config user.email "release-bot@mapbox.com" git config user.name "Mapbox Releases" +step-library: + - &restore-cache-gems + restore_cache: + keys: + - 1-gems-{{ checksum "Gemfile.lock" }} + + - &install-gems + run: + name: Install Gems + command: | + bundle config set path 'vendor/bundle' + bundle check || bundle install + + - &save-cache-gems + save_cache: + key: 1-gems-{{ checksum "Gemfile.lock" }} + paths: + - vendor/bundle + + - &restore-cache-podmaster + restore_cache: + keys: + - podmaster-cache + + - &save-cache-podmaster + save_cache: + key: podmaster-cache + paths: + - "~/.cocoapods/repos/master" + + - &prepare-netrc-file + run: + name: Prepare .netrc file + command: | + echo "machine api.mapbox.com" >> ~/.netrc + echo "login mapbox" >> ~/.netrc + echo "password $SDK_REGISTRY_TOKEN" >> ~/.netrc + chmod 0600 ~/.netrc + + - &add-github-to-known-hosts + run: + name: Add GitHub to known hosts + command: | + for ip in $(dig @8.8.8.8 github.com +short); do ssh-keyscan github.com,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts + jobs: detect-breaking-changes: macos: @@ -230,6 +275,64 @@ jobs: command: | git push origin $(git rev-parse --abbrev-ref HEAD):publisher-production + update-version-job: + parameters: + xcode: + type: string + default: "13.4.1" + macos: + xcode: << parameters.xcode >> + environment: + HOMEBREW_NO_AUTO_UPDATE: 1 + steps: + - checkout + - *restore-cache-gems + - *restore-cache-podmaster + - *install-gems + - *prepare-netrc-file + - *add-github-to-known-hosts + - install-mbx-ci + - run: + name: Update version + command: | + export GITHUB_WRITER_TOKEN=$(mbx-ci github writer public token) + git remote set-url origin "https://x-access-token:$GITHUB_WRITER_TOKEN@github.com/mapbox/mapbox-directions-swift" + git config --global user.email no-reply@mapbox.com && git config --global user.name mapbox-ci + VERSION=$( echo << pipeline.git.branch >> | sed 's/^trigger-update-version-//' ) + ./scripts/update-version.sh v$VERSION + - *save-cache-podmaster + - *save-cache-gems + + distribute-version-job: + parameters: + xcode: + type: string + default: "13.4.1" + macos: + xcode: << parameters.xcode >> + environment: + HOMEBREW_NO_AUTO_UPDATE: 1 + steps: + - checkout + - *restore-cache-gems + - *restore-cache-podmaster + - *install-gems + - *prepare-netrc-file + - *add-github-to-known-hosts + - install-mbx-ci + - run: + name: Update version + command: | + VERSION=$( echo << pipeline.git.branch >> | sed 's/^trigger-distribute-version-//' ) + if [[ $VERSION == *alpha* || $VERSION == *beta* || $VERSION == *rc* ]]; then + pod repo update && pod trunk push MapboxDirections-pre.podspec + else + pod repo update && pod trunk push MapboxDirections.podspec + fi + pod repo update && pod trunk push MapboxDirections.podspec + - *save-cache-podmaster + - *save-cache-gems + workflows: workflow: jobs: @@ -253,18 +356,22 @@ workflows: name: "SPM Ubuntu build" - example-app-build: name: "Build example app" - - approve-publish-documentation: - name: "Approve Publish Documentation" - type: approval - filters: &filters-tag-push + - publish-documentation: + name: "Publish Documentation" + filters: tags: only: /^v\d+\.\d+\.\d+(-.+)?$/ branches: ignore: /.*/ - - publish-documentation: - name: "Publish Documentation" - requires: - - "Approve Publish Documentation" - filters: - <<: *filters-tag-push - + update-version-workflow: + jobs: + - update-version-job: + filters: + branches: + only: /^trigger-update-version-.*/ + distribute-version-workflow: + jobs: + - distribute-version-job: + filters: + branches: + only: /^trigger-distribute-version-.*/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0603c1913..bfbefe41a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ Carthage/Checkouts /swift-package-baseline/*/MapboxDirections.json .build .vscode + +vendor/bundle/ruby/ \ No newline at end of file diff --git a/scripts/update-version.sh b/scripts/update-version.sh index b62531864..ecfb0f1c2 100755 --- a/scripts/update-version.sh +++ b/scripts/update-version.sh @@ -52,3 +52,25 @@ if [[ $1 != *alpha* && $1 != *beta* ]]; then step "Bumping API baseline" ./scripts/update-baseline.sh $1 fi + +BRANCH_NAME="update-version-${SEM_VERSION}" +git checkout -b $BRANCH_NAME +git add . +git commit -m "Update version ${SEM_VERSION}" +git push origin $BRANCH_NAME + +if [[ $SEM_VERSION =~ "alpha" || $SEM_VERSION =~ "beta" ]]; then + BASE_BRANCH_NAME="main" + else + MAJOR=${SEM_VERSION%%.*} + MINOR_TMP=${SEM_VERSION#*.} + MINOR=${MINOR_TMP%%.*} + BASE_BRANCH_NAME="release-v${MAJOR}.${MINOR}" +fi + +brew install gh +GITHUB_TOKEN=$GITHUB_WRITER_TOKEN gh pr create \ + --title "Release v${SEM_VERSION}" \ + --body "Bump version to ${SEM_VERSION}" \ + --base $BASE_BRANCH_NAME \ + --head $BRANCH_NAME