Skip to content

Commit 1060146

Browse files
authored
Merge branch 'master' into mlkit
2 parents f90a021 + af1b456 commit 1060146

19 files changed

+504
-223
lines changed
1.69 KB
Binary file not shown.

.github/scripts/generate_changelog.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/bash
2+
3+
# Copyright 2020 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
set -u
19+
20+
function printChangelog() {
21+
local TITLE=$1
22+
shift
23+
# Skip the sentinel value.
24+
local ENTRIES=("${@:2}")
25+
if [ ${#ENTRIES[@]} -ne 0 ]; then
26+
echo "### ${TITLE}"
27+
echo ""
28+
for ((i = 0; i < ${#ENTRIES[@]}; i++))
29+
do
30+
echo "* ${ENTRIES[$i]}"
31+
done
32+
echo ""
33+
fi
34+
}
35+
36+
if [[ -z "${GITHUB_SHA}" ]]; then
37+
GITHUB_SHA="HEAD"
38+
fi
39+
40+
LAST_TAG=`git describe --tags $(git rev-list --tags --max-count=1) 2> /dev/null` || true
41+
if [[ -z "${LAST_TAG}" ]]; then
42+
echo "[INFO] No tags found. Including all commits up to ${GITHUB_SHA}."
43+
VERSION_RANGE="${GITHUB_SHA}"
44+
else
45+
echo "[INFO] Last release tag: ${LAST_TAG}."
46+
COMMIT_SHA=`git show-ref -s ${LAST_TAG}`
47+
echo "[INFO] Last release commit: ${COMMIT_SHA}."
48+
VERSION_RANGE="${COMMIT_SHA}..${GITHUB_SHA}"
49+
echo "[INFO] Including all commits in the range ${VERSION_RANGE}."
50+
fi
51+
52+
echo ""
53+
54+
# Older versions of Bash (< 4.4) treat empty arrays as unbound variables, which triggers
55+
# errors when referencing them. Therefore we initialize each of these arrays with an empty
56+
# sentinel value, and later skip them.
57+
CHANGES=("")
58+
FIXES=("")
59+
FEATS=("")
60+
MISC=("")
61+
62+
while read -r line
63+
do
64+
COMMIT_MSG=`echo ${line} | cut -d ' ' -f 2-`
65+
if [[ $COMMIT_MSG =~ ^change(\(.*\))?: ]]; then
66+
CHANGES+=("$COMMIT_MSG")
67+
elif [[ $COMMIT_MSG =~ ^fix(\(.*\))?: ]]; then
68+
FIXES+=("$COMMIT_MSG")
69+
elif [[ $COMMIT_MSG =~ ^feat(\(.*\))?: ]]; then
70+
FEATS+=("$COMMIT_MSG")
71+
else
72+
MISC+=("${COMMIT_MSG}")
73+
fi
74+
done < <(git log ${VERSION_RANGE} --oneline)
75+
76+
printChangelog "Breaking Changes" "${CHANGES[@]}"
77+
printChangelog "New Features" "${FEATS[@]}"
78+
printChangelog "Bug Fixes" "${FIXES[@]}"
79+
printChangelog "Miscellaneous" "${MISC[@]}"
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
#!/bin/bash
2+
3+
# Copyright 2020 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
###################################### Outputs #####################################
19+
20+
# 1. version: The version of this release including the 'v' prefix (e.g. v1.2.3).
21+
# 2. changelog: Formatted changelog text for this release.
22+
23+
####################################################################################
24+
25+
set -e
26+
set -u
27+
28+
function echo_info() {
29+
local MESSAGE=$1
30+
echo "[INFO] ${MESSAGE}"
31+
}
32+
33+
function echo_warn() {
34+
local MESSAGE=$1
35+
echo "[WARN] ${MESSAGE}"
36+
}
37+
38+
function terminate() {
39+
echo ""
40+
echo_warn "--------------------------------------------"
41+
echo_warn "PREFLIGHT FAILED"
42+
echo_warn "--------------------------------------------"
43+
exit 1
44+
}
45+
46+
47+
echo_info "Starting publish preflight check..."
48+
echo_info "Git revision : ${GITHUB_SHA}"
49+
echo_info "Workflow triggered by : ${GITHUB_ACTOR}"
50+
echo_info "GitHub event : ${GITHUB_EVENT_NAME}"
51+
52+
53+
echo_info ""
54+
echo_info "--------------------------------------------"
55+
echo_info "Extracting release version"
56+
echo_info "--------------------------------------------"
57+
echo_info ""
58+
59+
readonly ABOUT_FILE="firebase_admin/__about__.py"
60+
echo_info "Loading version from: ${ABOUT_FILE}"
61+
62+
readonly RELEASE_VERSION=`grep "__version__" ${ABOUT_FILE} | awk '{print $3}' | tr -d \'` || true
63+
if [[ -z "${RELEASE_VERSION}" ]]; then
64+
echo_warn "Failed to extract release version from: ${ABOUT_FILE}"
65+
terminate
66+
fi
67+
68+
if [[ ! "${RELEASE_VERSION}" =~ ^([0-9]*)\.([0-9]*)\.([0-9]*)$ ]]; then
69+
echo_warn "Malformed release version string: ${RELEASE_VERSION}. Exiting."
70+
terminate
71+
fi
72+
73+
echo_info "Extracted release version: ${RELEASE_VERSION}"
74+
echo "::set-output name=version::v${RELEASE_VERSION}"
75+
76+
77+
echo_info ""
78+
echo_info "--------------------------------------------"
79+
echo_info "Check release artifacts"
80+
echo_info "--------------------------------------------"
81+
echo_info ""
82+
83+
if [[ ! -d dist ]]; then
84+
echo_warn "dist directory does not exist."
85+
terminate
86+
fi
87+
88+
readonly BIN_DIST="dist/firebase_admin-${RELEASE_VERSION}-py3-none-any.whl"
89+
if [[ -f "${BIN_DIST}" ]]; then
90+
echo_info "Found binary distribution (bdist_wheel): ${BIN_DIST}"
91+
else
92+
echo_warn "Binary distribution ${BIN_DIST} not found."
93+
terminate
94+
fi
95+
96+
readonly SRC_DIST="dist/firebase_admin-${RELEASE_VERSION}.tar.gz"
97+
if [[ -f "${SRC_DIST}" ]]; then
98+
echo_info "Found source distribution (sdist): ${SRC_DIST}"
99+
else
100+
echo_warn "Source distribution ${SRC_DIST} not found."
101+
terminate
102+
fi
103+
104+
readonly ARTIFACT_COUNT=`ls dist/ | wc -l`
105+
if [[ $ARTIFACT_COUNT -ne 2 ]]; then
106+
echo_warn "Unexpected artifacts in the distribution directory."
107+
ls -l dist
108+
terminate
109+
fi
110+
111+
112+
echo_info ""
113+
echo_info "--------------------------------------------"
114+
echo_info "Checking previous releases"
115+
echo_info "--------------------------------------------"
116+
echo_info ""
117+
118+
readonly PYPI_URL="https://pypi.org/pypi/firebase-admin/${RELEASE_VERSION}/json"
119+
readonly PYPI_STATUS=`curl -s -o /dev/null -L -w "%{http_code}" ${PYPI_URL}`
120+
if [[ $PYPI_STATUS -eq 404 ]]; then
121+
echo_info "Release version ${RELEASE_VERSION} not found in Pypi."
122+
elif [[ $PYPI_STATUS -eq 200 ]]; then
123+
echo_warn "Release version ${RELEASE_VERSION} already present in Pypi."
124+
terminate
125+
else
126+
echo_warn "Unexpected ${PYPI_STATUS} response from Pypi. Exiting."
127+
terminate
128+
fi
129+
130+
131+
echo_info ""
132+
echo_info "--------------------------------------------"
133+
echo_info "Checking release tag"
134+
echo_info "--------------------------------------------"
135+
echo_info ""
136+
137+
echo_info "---< git fetch --depth=1 origin +refs/tags/*:refs/tags/* >---"
138+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
139+
echo ""
140+
141+
readonly EXISTING_TAG=`git rev-parse -q --verify "refs/tags/v${RELEASE_VERSION}"` || true
142+
if [[ -n "${EXISTING_TAG}" ]]; then
143+
echo_warn "Tag v${RELEASE_VERSION} already exists. Exiting."
144+
echo_warn "If the tag was created in a previous unsuccessful attempt, delete it and try again."
145+
echo_warn " $ git tag -d v${RELEASE_VERSION}"
146+
echo_warn " $ git push --delete origin v${RELEASE_VERSION}"
147+
148+
readonly RELEASE_URL="https://github.com/firebase/firebase-admin-python/releases/tag/v${RELEASE_VERSION}"
149+
echo_warn "Delete any corresponding releases at ${RELEASE_URL}."
150+
terminate
151+
fi
152+
153+
echo_info "Tag v${RELEASE_VERSION} does not exist."
154+
155+
156+
echo_info ""
157+
echo_info "--------------------------------------------"
158+
echo_info "Generating changelog"
159+
echo_info "--------------------------------------------"
160+
echo_info ""
161+
162+
echo_info "---< git fetch origin master --prune --unshallow >---"
163+
git fetch origin master --prune --unshallow
164+
echo ""
165+
166+
echo_info "Generating changelog from history..."
167+
readonly CURRENT_DIR=$(dirname "$0")
168+
readonly CHANGELOG=`${CURRENT_DIR}/generate_changelog.sh`
169+
echo "$CHANGELOG"
170+
171+
# Parse and preformat the text to handle multi-line output.
172+
# See https://github.community/t5/GitHub-Actions/set-output-Truncates-Multiline-Strings/td-p/37870
173+
FILTERED_CHANGELOG=`echo "$CHANGELOG" | grep -v "\\[INFO\\]"`
174+
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//'%'/'%25'}"
175+
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//$'\n'/'%0A'}"
176+
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//$'\r'/'%0D'}"
177+
echo "::set-output name=changelog::${FILTERED_CHANGELOG}"
178+
179+
180+
echo ""
181+
echo_info "--------------------------------------------"
182+
echo_info "PREFLIGHT SUCCESSFUL"
183+
echo_info "--------------------------------------------"
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Copyright 2017 Google Inc.
1+
#!/bin/bash
2+
3+
# Copyright 2020 Google Inc.
24
#
35
# Licensed under the Apache License, Version 2.0 (the "License");
46
# you may not use this file except in compliance with the License.
@@ -12,14 +14,12 @@
1214
# See the License for the specific language governing permissions and
1315
# limitations under the License.
1416

15-
#!/bin/bash
17+
set -e
18+
set -u
19+
20+
gpg --quiet --batch --yes --decrypt --passphrase="${FIREBASE_SERVICE_ACCT_KEY}" \
21+
--output integ-service-account.json .github/resources/integ-service-account.json.gpg
22+
23+
echo "${FIREBASE_API_KEY}" > integ-api-key.txt
1624

17-
function parseVersion {
18-
if [[ ! "$1" =~ ^([0-9]*)\.([0-9]*)\.([0-9]*)$ ]]; then
19-
return 1
20-
fi
21-
MAJOR_VERSION=$(echo "$1" | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\1/')
22-
MINOR_VERSION=$(echo "$1" | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\2/')
23-
PATCH_VERSION=$(echo "$1" | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\3/')
24-
return 0
25-
}
25+
pytest integration/ --cert integ-service-account.json --apikey integ-api-key.txt

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Continuous Integration
22

3-
on: [push, pull_request]
3+
on: pull_request
44

55
jobs:
66
build:

0 commit comments

Comments
 (0)