Skip to content

Commit b5cb1ae

Browse files
authored
Merge pull request #130 from firebase/fix-firestore
Make package script to update guids and create packages together
2 parents ac8e9de + 4a076c3 commit b5cb1ae

File tree

3 files changed

+68
-22
lines changed

3 files changed

+68
-22
lines changed

.github/workflows/package.yml

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
skipIntegrationTests:
1212
description: 'skip integration tests?'
1313
default: 0
14+
working_branch:
15+
description: 'If already a working in progress release branch'
16+
default: None
1417

1518
jobs:
1619
package_sdks:
@@ -28,7 +31,7 @@ jobs:
2831
uses: actions/[email protected]
2932
with:
3033
fetch-depth: 0
31-
ref: ${{ github.event.inputs.baseBranch }}
34+
ref: ${{ github.event.inputs.working_branch }}
3235

3336
- name: Get token for firebase-workflow-trigger
3437
uses: tibdex/github-app-token@v1
@@ -48,18 +51,26 @@ jobs:
4851
pip install -r scripts/gha/requirements.txt
4952
5053
- name: Name new branch
51-
if: github.event.inputs.package_version_number != 0
54+
if: github.event.inputs.working_branch == 'None'
5255
run: |
5356
date_str=$(date "+%Y%m%d-%H%M%S")
5457
echo "NEW_BRANCH=${{env.branchPrefix}}${{github.event.inputs.package_version_number}}-${date_str}" >> $GITHUB_ENV
5558
5659
- name: Create new branch
57-
if: github.event.inputs.package_version_number != 0
60+
if: github.event.inputs.working_branch == 'None'
5861
run: |
5962
git remote update
6063
git checkout -b "${NEW_BRANCH}"
6164
echo "UPDATE_LOGFILE=update_log.txt" >> $GITHUB_ENV
6265
66+
- name: Checkout working branch
67+
if: github.event.inputs.working_branch != 'None'
68+
run: |
69+
git remote update
70+
git checkout ${{ github.event.inputs.working_branch }}
71+
echo "UPDATE_LOGFILE=update_log.txt" >> $GITHUB_ENV
72+
echo "NEW_BRANCH=${{ github.event.inputs.working_branch }}" >> $GITHUB_ENV
73+
6374
# Fetch all the zip files from previous run
6475
- name: Fetch Desktop Artifacts
6576
uses: dawidd6/action-download-artifact@v2
@@ -81,15 +92,36 @@ jobs:
8192
workflow: 'android.yml'
8293
run_id: ${{ github.event.inputs.downloadPreviousRun }}
8394
path: built_artifect
95+
96+
- name: move zip files
97+
run: |
98+
cd built_artifect
99+
find . -type f -name "*.zip" -exec mv {} . \;
100+
ls -l
101+
cd ..
84102
85-
# - name: Update Guids Json
86-
# if: github.event.inputs.package_version_number != 0
87-
# run: |
103+
- name: Package unitypackage
104+
run: |
105+
python build_package.py --zip_dir=built_artifect
88106
89-
- name: Push branch if there are changes
107+
- name: Commit Changes if there is any
108+
run: |
109+
if ! git update-index --refresh; then
110+
git config user.email "[email protected]"
111+
git config user.name "firebase-workflow-trigger-bot"
112+
git config core.commentChar "%" # so we can use # in git commit messages
113+
git commit -a -m "Update Guids ID"
114+
115+
# Show changes in git log
116+
git diff
117+
# Push branch
118+
git push --set-upstream origin "${NEW_BRANCH}"
119+
fi
120+
121+
- name: Create PR if there is None
122+
if: github.event.inputs.working_branch == 'None'
90123
id: push-branch
91124
run: |
92-
cd firebase-unity-sdk
93125
if ! git update-index --refresh; then
94126
date_str=$(date "+%a %b %d %Y")
95127
commit_title="Update Unity SDK dependencies - ${date_str}"
@@ -123,17 +155,6 @@ jobs:
123155
echo "::set-output name=branch_pushed::0"
124156
fi
125157
126-
- name: move zip files
127-
run: |
128-
cd built_artifect
129-
find . -type f -name "*.zip" -exec mv {} . \;
130-
ls -l
131-
cd ..
132-
133-
- name: Package unitypackage
134-
run: |
135-
python build_package.py --zip_dir=built_artifect
136-
137158
- name: Listing output
138159
run: |
139160
ls -Rl

.github/workflows/update_versions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
id: name-branch
6767
run: |
6868
date_str=$(date "+%Y%m%d-%H%M%S")
69-
new_branch=version-${{github.event.inputs.package_version_number}}-${date_str}
69+
new_branch=release-${{github.event.inputs.package_version_number}}-${date_str}
7070
echo "NEW_BRANCH=${new_branch}" >> $GITHUB_ENV
7171
echo "::set-output name=new_branch::${new_branch}"
7272

build_package.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,33 @@ def main(argv):
165165
cmd_args.append("--output_unitypackage=False")
166166
else:
167167
cmd_args.append("--enabled_sections=build_dotnet3 build_dotnet4")
168-
169-
return subprocess.call(cmd_args)
168+
169+
# Check if need to gen new guids
170+
p = subprocess.Popen(cmd_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
171+
output, error = p.communicate()
172+
if p.returncode != 0:
173+
error_str = str(error)
174+
split_string = error_str.split("assets:")[-1]
175+
split_string = split_string.rstrip("\\n\'")
176+
print(split_string)
177+
split_string = split_string.split(" ")
178+
split_string = split_string[3:] # exclude first 3 lines
179+
gen_guids_script_path = os.path.join(os.getcwd(), "gen_guids.py")
180+
gen_cmd_args = [
181+
sys.executable,
182+
gen_guids_script_path,
183+
"--guids_file=" + guids_file_path,
184+
"--version=" + last_version,
185+
"--generate_new_guids=True",
186+
]
187+
for file in split_string:
188+
file=file.strip("\"")
189+
print(file)
190+
gen_cmd_args.append(file)
191+
subprocess.call(gen_cmd_args)
192+
193+
# Need to package again if has that error
194+
subprocess.call(cmd_args)
170195

171196
if __name__ == '__main__':
172197
app.run(main)

0 commit comments

Comments
 (0)