Skip to content

Commit d10b1b1

Browse files
authored
Update action to auto merge PRs and create release (#37)
* Update action to auto merge PRs and create release * Login to different account to review PRs
1 parent 65b57d5 commit d10b1b1

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

.github/workflows/package.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212
- name: Checkout
1313
uses: actions/checkout@v2
1414

15-
- name: Authorize
16-
run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
17-
1815
- name: Release
1916
run: cd .scripts && sh ./package.sh
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
REVIEWER_TOKEN: ${{ secrets.REVIEWER_TOKEN }}

.scripts/package.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,25 @@ generate_swift_package () {
260260
template_replace $package "// GENERATE BINARIES" $binaries; rm -f $binaries
261261
}
262262

263+
login_default() {
264+
echo "$GITHUB_TOKEN" | gh auth login --with-token
265+
}
266+
267+
login_reviewer() {
268+
echo "$REVIEWER_TOKEN" | gh auth login --with-token
269+
}
270+
263271
commit_changes() {
264272
branch=$1
265273
git checkout -b $branch
266274
git add .
267275
git commit -m"Updated Package.swift and sources for latest firebase sdks"
268276
git push -u origin $branch
269277
gh pr create --fill
278+
login_reviewer
279+
gh pr review --approve
280+
login_default
281+
gh pr merge --squash
270282
}
271283

272284
# Exit when any command fails
@@ -277,6 +289,8 @@ set -o pipefail
277289
firebase_repo="https://github.com/firebase/firebase-ios-sdk"
278290
xcframeworks_repo="https://github.com/afresh-technologies/firebase-ios-sdk-xcframeworks"
279291

292+
login_default
293+
280294
# Release versions
281295
latest=$(latest_release_number $firebase_repo)
282296
current=$(latest_release_number $xcframeworks_repo)
@@ -329,13 +343,13 @@ if [[ $latest != $current || $debug ]]; then
329343
mv "$scratch/$package" "$package"
330344

331345
# Skips deploy
332-
# if [[ $skip_release ]]; then echo "Done."; exit 0; fi
346+
if [[ $skip_release ]]; then echo "Done."; exit 0; fi
333347

334348
# Deploy to repository
335349
echo "Merging changes to Github..."
336350
commit_changes "release/$latest"
337351
echo "Creating release draft"
338-
echo "Release $latest" | gh release create --target "release/$latest" --draft $latest $scratch/dist/*.xcframework.zip
352+
echo "Release $latest" | gh release create --title "$latest" --target "release/$latest" $latest $scratch/dist/*.xcframework.zip
339353
else
340354
echo "$current is up to date."
341355
fi

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ The `Package.swift` and `Sources` files are automatically generated via a [scrip
5353
The script performs the following actions:
5454
- Downloads the latest release from https://github.com/firebase/firebase-ios-sdk
5555
- Parses the Firebase.zip to generate Package.swift and Sources/
56-
- Commits changes on a new branch and creates a PR
57-
- Creates a draft release, with a tag that mirrors the Firebase release. The draft release includes the assets needed for the swift package
56+
- Commits changes on a new branch, creates, and merges a PR
57+
- Publishes a release, with a tag that mirrors the Firebase release. The release includes the assets needed for the swift package
5858
5959
## Running the script locally
6060
- Install github cli: `$ brew install gh`

0 commit comments

Comments
 (0)