Skip to content

Commit ac8e9de

Browse files
authored
Merge pull request #105 from firebase/fix-firestore
Create update_version workflow
2 parents 75c65bc + 97dc662 commit ac8e9de

11 files changed

+285
-35
lines changed

.github/workflows/android.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ on:
1212
description: 'Firebase CPP SDK version to build against (The branch, tag or SHA to checkout)'
1313
default: ''
1414
required: false
15+
unity_branch:
16+
description: 'Unity branch to build against, empty means current branch'
17+
default: ''
1518

1619
jobs:
1720
build_android:
@@ -30,6 +33,7 @@ jobs:
3033
uses: actions/checkout@v2
3134
with:
3235
submodules: true
36+
ref: ${{ github.event.inputs.unity_branch }}
3337

3438
- name: Checkout CPP Repo
3539
uses: actions/checkout@v2

.github/workflows/ios.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ on:
1313
description: 'Firebase CPP SDK version to build against (The branch, tag or SHA to checkout)'
1414
default: ''
1515
required: false
16+
unity_branch:
17+
description: 'Unity branch to build against, empty means current branch'
18+
default: ''
1619

1720
jobs:
1821
build_ios:
@@ -31,6 +34,7 @@ jobs:
3134
uses: actions/checkout@v2
3235
with:
3336
submodules: true
37+
ref: ${{ github.event.inputs.unity_branch }}
3438

3539
- name: Checkout CPP Repo
3640
uses: actions/checkout@v2

.github/workflows/package.yml

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,18 @@ jobs:
2424
- os: ubuntu-latest
2525
package_dir: output
2626
steps:
27-
- name: fetch SDK
27+
- name: Check out base branch
2828
uses: actions/[email protected]
29+
with:
30+
fetch-depth: 0
31+
ref: ${{ github.event.inputs.baseBranch }}
32+
33+
- name: Get token for firebase-workflow-trigger
34+
uses: tibdex/github-app-token@v1
35+
id: generate-token
36+
with:
37+
app_id: ${{ secrets.WORKFLOW_TRIGGER_APP_ID }}
38+
private_key: ${{ secrets.WORKFLOW_TRIGGER_APP_PRIVATE_KEY }}
2939

3040
- name: Setup Python
3141
uses: actions/setup-python@v2
@@ -37,6 +47,19 @@ jobs:
3747
run: |
3848
pip install -r scripts/gha/requirements.txt
3949
50+
- name: Name new branch
51+
if: github.event.inputs.package_version_number != 0
52+
run: |
53+
date_str=$(date "+%Y%m%d-%H%M%S")
54+
echo "NEW_BRANCH=${{env.branchPrefix}}${{github.event.inputs.package_version_number}}-${date_str}" >> $GITHUB_ENV
55+
56+
- name: Create new branch
57+
if: github.event.inputs.package_version_number != 0
58+
run: |
59+
git remote update
60+
git checkout -b "${NEW_BRANCH}"
61+
echo "UPDATE_LOGFILE=update_log.txt" >> $GITHUB_ENV
62+
4063
# Fetch all the zip files from previous run
4164
- name: Fetch Desktop Artifacts
4265
uses: dawidd6/action-download-artifact@v2
@@ -59,6 +82,47 @@ jobs:
5982
run_id: ${{ github.event.inputs.downloadPreviousRun }}
6083
path: built_artifect
6184

85+
# - name: Update Guids Json
86+
# if: github.event.inputs.package_version_number != 0
87+
# run: |
88+
89+
- name: Push branch if there are changes
90+
id: push-branch
91+
run: |
92+
cd firebase-unity-sdk
93+
if ! git update-index --refresh; then
94+
date_str=$(date "+%a %b %d %Y")
95+
commit_title="Update Unity SDK dependencies - ${date_str}"
96+
commit_body=
97+
if [[ -n '${{ github.event.inputs.comment }}' ]]; then
98+
# If a comment was provided, start with that instead of blank.
99+
commit_body='${{ github.event.inputs.comment }}
100+
101+
'
102+
fi
103+
104+
commit_body="${commit_body}
105+
106+
> Created by [${{github.workflow}} workflow]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)."
107+
git config user.email "[email protected]"
108+
git config user.name "firebase-workflow-trigger-bot"
109+
git config core.commentChar "%" # so we can use # in git commit messages
110+
git commit -a -m "${commit_title}
111+
112+
${commit_body}"
113+
echo "::set-output name=branch_pushed::1"
114+
# Show changes in git log
115+
git diff
116+
# Push branch
117+
git push --set-upstream origin "${NEW_BRANCH}"
118+
# Create pull request
119+
pr_number=$(python scripts/gha/create_pull_request.py --token ${{ steps.generate-token.outputs.token }} --head "${NEW_BRANCH}" --base "${{ github.event.inputs.baseBranch }}" --title "${commit_title}" --body "${commit_body}")
120+
echo "::set-output name=created_pr_number::${pr_number}"
121+
else
122+
echo "::warning ::No changes detected, won't create pull request."
123+
echo "::set-output name=branch_pushed::0"
124+
fi
125+
62126
- name: move zip files
63127
run: |
64128
cd built_artifect

.github/workflows/sdk_build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ on:
1414
description: 'Additional flags to pass into CMake'
1515
default: ''
1616
required: false
17+
unity_branch:
18+
description: 'Unity branch to build against, empty means current branch'
19+
default: ''
1720

1821
jobs:
1922
build_desktop:
@@ -45,6 +48,7 @@ jobs:
4548
- uses: actions/checkout@v2
4649
with:
4750
submodules: true
51+
ref: ${{ github.event.inputs.unity_branch }}
4852

4953
- uses: actions/checkout@v2
5054
with:

.github/workflows/update_versions.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ on:
88
description: 'CSV of VMs to run on'
99
default: 'ubuntu-latest'
1010
required: true
11+
baseBranch:
12+
description: 'create the new branch from this base'
13+
default: 'main'
1114
package_version_number:
1215
description: "The Unity SDK version to upgrade to"
1316
default: 8.6.0
1417

1518
jobs:
1619
update_versions:
17-
name: package-${{matrix.os}}
20+
name: update-version-${{matrix.os}}
21+
outputs:
22+
new_branch: ${{ steps.name-branch.outputs.new_branch }}
1823
runs-on: ${{matrix.os}}
1924
strategy:
2025
fail-fast: false
@@ -39,9 +44,9 @@ jobs:
3944
ref: ${{ github.event.inputs.firebase_cpp_sdk_version }}
4045
submodules: true
4146

42-
- name: Get token for firebase-workflow-trigger
47+
- name: Get token for creating PR
4348
uses: tibdex/github-app-token@v1
44-
id: generate-token
49+
id: generate-pr-token
4550
with:
4651
app_id: ${{ secrets.WORKFLOW_TRIGGER_APP_ID }}
4752
private_key: ${{ secrets.WORKFLOW_TRIGGER_APP_PRIVATE_KEY }}
@@ -58,16 +63,20 @@ jobs:
5863
pip install -r scripts/gha/requirements.txt
5964
6065
- name: Name new branch
66+
id: name-branch
6167
run: |
6268
date_str=$(date "+%Y%m%d-%H%M%S")
63-
echo "NEW_BRANCH=${{env.branchPrefix}}${{github.event.inputs.package_version_number}}-${date_str}" >> $GITHUB_ENV
69+
new_branch=version-${{github.event.inputs.package_version_number}}-${date_str}
70+
echo "NEW_BRANCH=${new_branch}" >> $GITHUB_ENV
71+
echo "::set-output name=new_branch::${new_branch}"
6472
6573
- name: Create new branch
6674
run: |
6775
cd firebase-unity-sdk
6876
git remote update
6977
git checkout -b "${NEW_BRANCH}"
7078
echo "UPDATE_LOGFILE=update_log.txt" >> $GITHUB_ENV
79+
7180
7281
- name: Update Unity SDK version and dependencies
7382
run: |
@@ -104,15 +113,15 @@ jobs:
104113
# Push branch
105114
git push --set-upstream origin "${NEW_BRANCH}"
106115
# Create pull request
107-
pr_number=$(python scripts/gha/create_pull_request.py --token ${{ steps.generate-token.outputs.token }} --head "${NEW_BRANCH}" --base "${{ github.event.inputs.baseBranch }}" --title "${commit_title}" --body "${commit_body}")
116+
pr_number=$(python scripts/gha/create_pull_request.py --token ${{ steps.generate-pr-token.outputs.token }} --head "${NEW_BRANCH}" --base "${{ github.event.inputs.baseBranch }}" --title "${commit_title}" --body "${commit_body}")
108117
echo "::set-output name=created_pr_number::${pr_number}"
109118
else
110119
echo "::warning ::No changes detected, won't create pull request."
111120
echo "::set-output name=branch_pushed::0"
112121
fi
113122
114123
trigger_build_sdks:
115-
needs: [update_versions]
124+
needs: update_versions
116125
name: trigger-build-${{matrix.platform}}
117126
runs-on: ubuntu-latest
118127
strategy:
@@ -130,6 +139,9 @@ jobs:
130139
steps:
131140
- name: Checkout repo
132141
uses: actions/[email protected]
142+
with:
143+
fetch-depth: 0
144+
ref: ${{ github.event.inputs.baseBranch }}
133145

134146
- name: Setup python
135147
uses: actions/setup-python@v2
@@ -144,7 +156,7 @@ jobs:
144156
# This method is preferred over the "personal access token" solution, as the GitHub App's scope is limited to just
145157
# the firebase-cpp-sdk repository.
146158
uses: tibdex/github-app-token@v1
147-
id: generate-token
159+
id: generate-build-token
148160
with:
149161
app_id: ${{ secrets.WORKFLOW_TRIGGER_APP_ID }}
150162
private_key: ${{ secrets.WORKFLOW_TRIGGER_APP_PRIVATE_KEY }}
@@ -158,4 +170,6 @@ jobs:
158170
generate_report=(-p test_pull_request nightly-packaging)
159171
fi
160172
set -e
161-
python scripts/gha/trigger_workflow.py -t ${{ steps.generate-token.outputs.token }} -w ${{ matrix.trigger_file }} -p test_packaged_sdk ${{ github.run_id }} -s 10 -A -v
173+
compose_new_branch=firebase-unity-sdk/${{ needs.update_versions.outputs.new_branch }}
174+
echo "New branch is: ${compose_new_branch}"
175+
python scripts/gha/trigger_workflow.py -t ${{ steps.generate-build-token.outputs.token }} -w ${{ matrix.trigger_file }} -p unity_branch ${{ needs.update_versions.outputs.new_branch }}

build_package.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import zipfile
3939
import shutil
4040

41+
from github import Github
4142
from absl import app
4243
from absl import flags
4344
from absl import logging
@@ -78,27 +79,19 @@ def get_zip_files():
7879

7980
return zip_file_paths
8081

81-
def get_last_version(guids_file):
82+
def get_last_version():
8283
"""Get the last version number in guids file if exists.
83-
84-
Args:
85-
guids_file: the file to look the version in.
86-
8784
Returns:
8885
version number.
8986
"""
90-
json_dict = None
91-
with open(guids_file, "rt") as json_file:
92-
try:
93-
json_dict = json.load(json_file,
94-
object_pairs_hook=collections.OrderedDict)
95-
except ValueError as error:
96-
raise ValueError("Failed to load JSON file %s (%s)" % (guids_file,
97-
str(error)))
98-
if json_dict:
99-
key_list = list(json_dict.keys())
100-
key_list.sort(key=lambda s: list(map(int, s.split('.'))))
101-
return key_list[-1]
87+
version_cmake_path = os.path.join(os.getcwd(), "cmake", "firebase_unity_version.cmake")
88+
with open(version_cmake_path, "r") as f:
89+
datafile = f.readlines()
90+
for line in datafile:
91+
if "FIREBASE_UNITY_SDK_VERSION" in line:
92+
result = line.split()
93+
return result[-1].strip("\"")
94+
return None
10295

10396
def find_pack_script():
10497
"""Get the pack script either from intermediate build folder or download from unity-jar-resolver.
@@ -135,12 +128,15 @@ def main(argv):
135128
packer_script_path = find_pack_script()
136129
if packer_script_path == None:
137130
raise app.UsageError('Cannot find pack script. Please build the project first.')
138-
131+
139132
packer_script_path = os.path.join(os.getcwd(), packer_script_path)
140133
config_file_path = os.path.join(os.getcwd(), FLAGS.script_folder,
141134
FLAGS.config_file)
142135
guids_file_path = os.path.join(os.getcwd(), FLAGS.script_folder,
143136
FLAGS.guids_file)
137+
138+
last_version = get_last_version()
139+
144140
zip_file_list = get_zip_files()
145141

146142
if not zip_file_list:
@@ -160,7 +156,7 @@ def main(argv):
160156
"--output_upm=" + str(FLAGS.output_upm),
161157
]
162158
cmd_args.extend(["--assets_zip=" + zip_file for zip_file in zip_file_list])
163-
last_version = get_last_version(guids_file_path)
159+
164160
if last_version:
165161
cmd_args.append("--plugins_version=" + last_version)
166162

@@ -172,6 +168,5 @@ def main(argv):
172168

173169
return subprocess.call(cmd_args)
174170

175-
176171
if __name__ == '__main__':
177172
app.run(main)

cmake/firebase_unity_version.cmake

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,17 @@
1717
set(FIREBASE_UNITY_SDK_VERSION "8.5.0"
1818
CACHE STRING "The version of the Unity SDK, used in the names of files.")
1919

20-
set(FIREBASE_IOS_POD_VERSION "8.3.0"
20+
set(FIREBASE_IOS_POD_VERSION "8.9.0"
2121
CACHE STRING "The version of the top-level Firebase Cocoapod to use.")
2222

2323
# https://github.com/googlesamples/unity-jar-resolver
24-
set(FIREBASE_UNITY_JAR_RESOLVER_VERSION
25-
"1.2.167"
24+
set(FIREBASE_UNITY_JAR_RESOLVER_VERSION "1.2.167"
2625
CACHE STRING
2726
"Version tag of Play Services Resolver to download and use (no trailing .0)"
2827
)
2928

3029
# https://github.com/firebase/firebase-cpp-sdk
31-
set(FIREBASE_CPP_SDK_PRESET_VERSION
32-
"v8.6.0"
30+
set(FIREBASE_CPP_SDK_PRESET_VERSION "v8.8.0"
3331
CACHE STRING
3432
"Version tag of Firebase CPP SDK to download (if no local or not passed in) and use (no trailing .0)"
3533
)

0 commit comments

Comments
 (0)