Skip to content

Commit 5bf17cd

Browse files
authored
Merge branch 'main' into mjeremia-patch-1
2 parents bc87921 + f493fb0 commit 5bf17cd

13 files changed

Lines changed: 651 additions & 58 deletions
-6 Bytes
Binary file not shown.

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111
python: ['3.9', '3.10', '3.11', '3.12', '3.13', 'pypy3.9']
1212

1313
steps:
14-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # 4.3.1
1515

1616
- name: Set up Python 3.13 for emulator
17-
uses: actions/setup-python@v5
17+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # 5.6.0
1818
with:
1919
python-version: '3.13'
2020
- name: Setup functions emulator environment
@@ -24,7 +24,7 @@ jobs:
2424
pip install -r integration/emulators/functions/requirements.txt
2525
deactivate
2626
- name: Set up Python ${{ matrix.python }}
27-
uses: actions/setup-python@v5
27+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # 5.6.0
2828
with:
2929
python-version: ${{ matrix.python }}
3030
- name: Install dependencies
@@ -34,11 +34,11 @@ jobs:
3434
- name: Test with pytest
3535
run: pytest
3636
- name: Set up Node.js 20
37-
uses: actions/setup-node@v4
37+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # 4.4.0
3838
with:
3939
node-version: 20
4040
- name: Set up Java 21
41-
uses: actions/setup-java@v5
41+
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # 5.1.0
4242
with:
4343
distribution: 'temurin'
4444
java-version: '21'
@@ -52,9 +52,9 @@ jobs:
5252
lint:
5353
runs-on: ubuntu-latest
5454
steps:
55-
- uses: actions/checkout@v4
55+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # 4.3.1
5656
- name: Set up Python 3.9
57-
uses: actions/setup-python@v5
57+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # 5.6.0
5858
with:
5959
python-version: 3.9
6060
- name: Install dependencies

.github/workflows/nightly.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ jobs:
2929

3030
steps:
3131
- name: Checkout source for staging
32-
uses: actions/checkout@v4
32+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # 4.3.1
3333
with:
3434
ref: ${{ github.event.client_payload.ref || github.ref }}
3535

3636
- name: Set up Python
37-
uses: actions/setup-python@v5
37+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # 5.6.0
3838
with:
3939
python-version: 3.9
4040

@@ -63,14 +63,14 @@ jobs:
6363
# Attach the packaged artifacts to the workflow output. These can be manually
6464
# downloaded for later inspection if necessary.
6565
- name: Archive artifacts
66-
uses: actions/upload-artifact@v4
66+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
6767
with:
6868
name: dist
6969
path: dist
7070

7171
- name: Send email on failure
7272
if: failure()
73-
uses: firebase/firebase-admin-node/.github/actions/send-email@main
73+
uses: firebase/firebase-admin-node/.github/actions/send-email@2e2b36a84ba28679bcb7aecdacabfec0bded2d48 # Admin Node SDK v13.6.0
7474
with:
7575
api-key: ${{ secrets.OSS_BOT_MAILGUN_KEY }}
7676
domain: ${{ secrets.OSS_BOT_MAILGUN_DOMAIN }}
@@ -85,7 +85,7 @@ jobs:
8585

8686
- name: Send email on cancelled
8787
if: cancelled()
88-
uses: firebase/firebase-admin-node/.github/actions/send-email@main
88+
uses: firebase/firebase-admin-node/.github/actions/send-email@2e2b36a84ba28679bcb7aecdacabfec0bded2d48 # Admin Node SDK v13.6.0
8989
with:
9090
api-key: ${{ secrets.OSS_BOT_MAILGUN_KEY }}
9191
domain: ${{ secrets.OSS_BOT_MAILGUN_DOMAIN }}

.github/workflows/release.yml

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,41 @@
1515
name: Release Candidate
1616

1717
on:
18-
# Only run the workflow when a PR is updated or when a developer explicitly requests
19-
# a build by sending a 'firebase_build' event.
18+
# Run the workflow when:
19+
# 1. A PR is created or updated (staging checks).
20+
# 2. A commit is pushed to main (release publication).
21+
# 3. A developer explicitly requests a build via 'firebase_build' event.
2022
pull_request:
21-
types: [opened, synchronize, closed]
23+
types: [opened, synchronize]
24+
25+
push:
26+
branches:
27+
- main
28+
paths:
29+
- 'firebase_admin/__about__.py'
2230

2331
repository_dispatch:
2432
types:
2533
- firebase_build
2634

2735
jobs:
2836
stage_release:
29-
# To publish a release, merge the release PR with the label 'release:publish'.
37+
# To publish a release, merge a PR with the title prefix '[chore] Release ' to main
38+
# and ensure the squashed commit message also has the prefix.
3039
# To stage a release without publishing it, send a 'firebase_build' event or apply
3140
# the 'release:stage' label to a PR.
3241
if: github.event.action == 'firebase_build' ||
3342
contains(github.event.pull_request.labels.*.name, 'release:stage') ||
34-
(github.event.pull_request.merged &&
35-
contains(github.event.pull_request.labels.*.name, 'release:publish'))
43+
(github.event_name == 'push' && startsWith(github.event.head_commit.message, '[chore] Release '))
3644

3745
runs-on: ubuntu-latest
3846

39-
# When manually triggering the build, the requester can specify a target branch or a tag
40-
# via the 'ref' client parameter.
4147
steps:
4248
- name: Checkout source for staging
43-
uses: actions/checkout@v4
44-
with:
45-
ref: ${{ github.event.client_payload.ref || github.ref }}
49+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # 4.3.1
4650

4751
- name: Set up Python
48-
uses: actions/setup-python@v5
52+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # 5.6.0
4953
with:
5054
python-version: 3.9
5155

@@ -74,25 +78,24 @@ jobs:
7478
# Attach the packaged artifacts to the workflow output. These can be manually
7579
# downloaded for later inspection if necessary.
7680
- name: Archive artifacts
77-
uses: actions/upload-artifact@v4
81+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
7882
with:
7983
name: dist
8084
path: dist
8185

8286
publish_release:
8387
needs: stage_release
8488

85-
# Check whether the release should be published. We publish only when the trigger PR is
86-
# 1. merged
89+
# Check whether the release should be published. We publish only when the trigger is
90+
# 1. a push (merge)
8791
# 2. to the main branch
88-
# 3. with the label 'release:publish', and
89-
# 4. the title prefix '[chore] Release '.
90-
if: github.event.pull_request.merged &&
92+
# 3. and the commit message has the title prefix '[chore] Release '.
93+
if: github.event_name == 'push' &&
9194
github.ref == 'refs/heads/main' &&
92-
contains(github.event.pull_request.labels.*.name, 'release:publish') &&
93-
startsWith(github.event.pull_request.title, '[chore] Release ')
95+
startsWith(github.event.head_commit.message, '[chore] Release ')
9496

9597
runs-on: ubuntu-latest
98+
environment: Release
9699
permissions:
97100
# Used to create a short-lived OIDC token which is given to PyPi to identify this workflow job
98101
# See: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings
@@ -102,11 +105,11 @@ jobs:
102105

103106
steps:
104107
- name: Checkout source for publish
105-
uses: actions/checkout@v4
108+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # 4.3.1
106109

107110
# Download the artifacts created by the stage_release job.
108111
- name: Download release candidates
109-
uses: actions/download-artifact@v4.1.7
112+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
110113
with:
111114
name: dist
112115
path: dist
@@ -119,24 +122,12 @@ jobs:
119122
- name: Create release tag
120123
env:
121124
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122-
run: gh release create ${{ steps.preflight.outputs.version }}
123-
--title "Firebase Admin Python SDK ${{ steps.preflight.outputs.version }}"
124-
--notes '${{ steps.preflight.outputs.changelog }}'
125+
RELEASE_VER: ${{ steps.preflight.outputs.version }}
126+
RELEASE_BODY: ${{ steps.preflight.outputs.changelog }}
127+
run: |
128+
gh release create "$RELEASE_VER" \
129+
--title "Firebase Admin Python SDK $RELEASE_VER" \
130+
--notes "$RELEASE_BODY"
125131
126132
- name: Publish to Pypi
127-
uses: pypa/gh-action-pypi-publish@release/v1
128-
129-
# Post to Twitter if explicitly opted-in by adding the label 'release:tweet'.
130-
- name: Post to Twitter
131-
if: success() &&
132-
contains(github.event.pull_request.labels.*.name, 'release:tweet')
133-
uses: firebase/firebase-admin-node/.github/actions/send-tweet@main
134-
with:
135-
status: >
136-
${{ steps.preflight.outputs.version }} of @Firebase Admin Python SDK is available.
137-
https://github.com/firebase/firebase-admin-python/releases/tag/${{ steps.preflight.outputs.version }}
138-
consumer-key: ${{ secrets.TWITTER_CONSUMER_KEY }}
139-
consumer-secret: ${{ secrets.TWITTER_CONSUMER_SECRET }}
140-
access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
141-
access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
142-
continue-on-error: true
133+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0

firebase_admin/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
"""About information (version, etc) for Firebase Admin SDK."""
1616

17-
__version__ = '7.1.0'
17+
__version__ = '7.4.0'
1818
__title__ = 'firebase_admin'
1919
__author__ = 'Firebase'
2020
__license__ = 'Apache License 2.0'

firebase_admin/_messaging_encoder.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ def encode_android(cls, android):
207207
'fcm_options': cls.encode_android_fcm_options(android.fcm_options),
208208
'direct_boot_ok': _Validators.check_boolean(
209209
'AndroidConfig.direct_boot_ok', android.direct_boot_ok),
210+
'bandwidth_constrained_ok': _Validators.check_boolean(
211+
'AndroidConfig.bandwidth_constrained_ok', android.bandwidth_constrained_ok),
212+
'restricted_satellite_ok': _Validators.check_boolean(
213+
'AndroidConfig.restricted_satellite_ok', android.restricted_satellite_ok),
210214
}
211215
result = cls.remove_null_values(result)
212216
priority = result.get('priority')

firebase_admin/_messaging_utils.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
# limitations under the License.
1414

1515
"""Types and utilities used by the messaging (FCM) module."""
16+
from __future__ import annotations
17+
import datetime
18+
from typing import Dict, Optional, Union
1619

1720
from firebase_admin import exceptions
1821

@@ -51,10 +54,25 @@ class AndroidConfig:
5154
fcm_options: A ``messaging.AndroidFCMOptions`` to be included in the message (optional).
5255
direct_boot_ok: A boolean indicating whether messages will be allowed to be delivered to
5356
the app while the device is in direct boot mode (optional).
57+
bandwidth_constrained_ok: A boolean indicating whether messages will be allowed to be
58+
delivered to the app while the device is on a bandwidth constrained network (optional).
59+
restricted_satellite_ok: A boolean indicating whether messages will be allowed to be
60+
delivered to the app while the device is on a restricted satellite network (optional).
5461
"""
5562

56-
def __init__(self, collapse_key=None, priority=None, ttl=None, restricted_package_name=None,
57-
data=None, notification=None, fcm_options=None, direct_boot_ok=None):
63+
def __init__(
64+
self,
65+
collapse_key: Optional[str] = None,
66+
priority: Optional[str] = None,
67+
ttl: Optional[Union[int, float, datetime.timedelta]] = None,
68+
restricted_package_name: Optional[str] = None,
69+
data: Optional[Dict[str, str]] = None,
70+
notification: Optional[AndroidNotification] = None,
71+
fcm_options: Optional[AndroidFCMOptions] = None,
72+
direct_boot_ok: Optional[bool] = None,
73+
bandwidth_constrained_ok: Optional[bool] = None,
74+
restricted_satellite_ok: Optional[bool] = None
75+
):
5876
self.collapse_key = collapse_key
5977
self.priority = priority
6078
self.ttl = ttl
@@ -63,6 +81,8 @@ def __init__(self, collapse_key=None, priority=None, ttl=None, restricted_packag
6381
self.notification = notification
6482
self.fcm_options = fcm_options
6583
self.direct_boot_ok = direct_boot_ok
84+
self.bandwidth_constrained_ok = bandwidth_constrained_ok
85+
self.restricted_satellite_ok = restricted_satellite_ok
6686

6787

6888
class AndroidNotification:

firebase_admin/_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ def handle_httpx_error(error: httpx.HTTPError, message=None, code=None) -> excep
279279
message=f'Failed to establish a connection: {error}',
280280
cause=error)
281281
if isinstance(error, httpx.HTTPStatusError):
282-
print("printing status error", error)
283282
if not code:
284283
code = _http_status_to_error_code(error.response.status_code)
285284
if not message:

0 commit comments

Comments
 (0)