77
88TMP_ROOT=$( mktemp -d)
99WORKTREE_TO_REMOVE=" "
10- STAGING_ONLY=false
11- EXTRA_EMPTY_COMMIT=false
1210
1311# shellcheck disable=SC2317
1412cleanup () {
@@ -33,12 +31,6 @@ main() {
3331 git_configure_release_user
3432 git config user.email " $CLA_SIGNED_GITHUB_EMAIL "
3533
36- if [ " $STAGING_ONLY " = true ]; then
37- step " Update mapbox/maps-ios@publisher-staging"
38- maps_ios_upload_docs
39- exit 0
40- fi
41-
4234 brew_install_if_needed gh
4335
4436 step " Update mapbox/ios-sdk"
@@ -50,49 +42,6 @@ main() {
5042 exit 0
5143}
5244
53- maps_ios_upload_docs () {
54- STAGING_BRANCH_NAME=" publisher-staging"
55- info " Checkout $STAGING_BRANCH_NAME worktree"
56- local staging_docs_path=" $TMP_ROOT /docs-staging"
57- git worktree add " $staging_docs_path " " $STAGING_BRANCH_NAME " --quiet
58- WORKTREE_TO_REMOVE=" $staging_docs_path "
59-
60- git -C " $staging_docs_path " reset --hard origin/publisher-production --quiet
61-
62- info " Copy docs from $DOCS_PATH "
63- cp -r " $DOCS_PATH " " $staging_docs_path /$VERSION "
64-
65- pushd " $staging_docs_path " > /dev/null || exit 1
66- git_configure_release_user
67- git config user.email " $CLA_SIGNED_GITHUB_EMAIL "
68-
69- git remote set-url origin " https://x-access-token:$( mbx-ci github writer public token) @github.com/mapbox/mapbox-maps-ios.git"
70-
71- info " Commit"
72- git add .
73- git commit -m " Add documentation for v$VERSION " --quiet
74-
75- info " Push"
76- git push --force --verbose
77-
78- if [ " $STAGING_ONLY " = true ]; then
79- git push --force --verbose
80- else
81- VERSION_BRANCH_NAME=" docs/$VERSION "
82- git checkout -b " $VERSION_BRANCH_NAME "
83- git push --set-upstream origin " $VERSION_BRANCH_NAME " --force --verbose
84- fi
85-
86- if [ " $EXTRA_EMPTY_COMMIT " = true ]; then
87- info " Add empty commit to trigger CI"
88- sleep 10 # Avoid CI sometimes cancelling the "Trigger CI" build
89- git commit --allow-empty -m " Trigger CI" --quiet
90- git push --force --verbose
91- fi
92-
93- popd > /dev/null
94- }
95-
9645should_update_version () {
9746 local new=$1
9847 local current=$2
@@ -111,7 +60,7 @@ ios_sdk_update_versions() {
11160
11261 info " Clone repository"
11362 [[ -d $IOS_SDK_REPO_PATH ]] && rm -rf " $IOS_SDK_REPO_PATH "
114- git clone " https://x-access-token:$( mbx-ci github writer private token ) @github.com/mapbox/ios-sdk.git" " $IOS_SDK_REPO_PATH " --branch publisher-production --depth=1 --quiet
63+ git clone " https://x-access-token:$GITHUB_WRITER_PRIVATE_TOKEN @github.com/mapbox/ios-sdk.git" " $IOS_SDK_REPO_PATH " --branch publisher-production --depth=1 --quiet
11564
11665 pushd " $IOS_SDK_REPO_PATH " || exit 1
11766
@@ -146,9 +95,9 @@ ios_sdk_update_versions() {
14695ios_sdk_open_pr () {
14796 local body=" * Release ${VERSION} documentation — Maps SDK for iOS
14897 Staging URL: https://docs.tilestream.net/ios/maps/api/$VERSION /index.html"
149- GITHUB_TOKEN_WRITER=$( mbx-ci github writer private token )
98+ GITHUB_TOKEN_WRITER=$GITHUB_WRITER_PRIVATE_TOKEN
15099
151- PR_URL=$( GITHUB_TOKEN=$GITHUB_TOKEN_WRITER \
100+ PR_URL=$( GITHUB_TOKEN=$GITHUB_WRITER_PRIVATE_TOKEN \
152101 gh pr create \
153102 --repo mapbox/ios-sdk \
154103 --base publisher-production \
@@ -157,46 +106,24 @@ ios_sdk_open_pr() {
157106 --label " Maps SDK" \
158107 --label " update" \
159108 --body " $body " )
160- GITHUB_TOKEN=" $GITHUB_TOKEN_WRITER " gh pr merge --auto --squash " $PR_URL "
109+ GITHUB_TOKEN=" $GITHUB_WRITER_PRIVATE_TOKEN " gh pr merge --auto --squash " $PR_URL "
161110
162- repeat_command_until_it_fails " approve_pr" 15 20
111+ # repeat_command_until_it_fails "approve_pr" 15 20
163112
164113 info " New PR: $PR_URL "
165114 pwd
166115 popd
167116 echo " $PR_URL " > " ios-sdk-pr.txt"
117+
118+ if [[ -n " ${GITHUB_STEP_SUMMARY:- } " ]]; then
119+ echo " Docs PR: $PR_URL " >> $GITHUB_STEP_SUMMARY
120+ fi
168121}
169122
170123# shellcheck disable=SC2317
171124approve_pr () {
172- GITHUB_TOKEN=$( mbx-ci github writer private token) gh pr review " $PR_URL " --approve
173- }
174-
175- print_usage () {
176- cat << HELP_USAGE
177- Usage:
178- $0 -p docs_path
179-
180- -p Path to the generated docs to upload
181- -s To upload docs to staging only
182- -e Push an extra empty commit to trigger CI
183- HELP_USAGE
125+ GITHUB_TOKEN=$GITHUB_WRITER_PRIVATE_TOKEN gh pr review " $PR_URL " --approve
184126}
185127
186- while getopts ' p:se' flag; do
187- case " ${flag} " in
188- p) DOCS_PATH=" $OPTARG "
189- if [[ ! -d $DOCS_PATH ]]; then
190- exit 1
191- fi
192- ;;
193- s) STAGING_ONLY=true
194- ;;
195- e) EXTRA_EMPTY_COMMIT=true
196- ;;
197- * ) print_usage ;;
198- esac
199- done
200-
201128set -x
202129main
0 commit comments