Skip to content

Commit 4343fa8

Browse files
hiranya911rueian178inaba
authored
[chore] Release 3.12.1 (#364)
* chore: Removed Travis CI integration (#326) * chore: Added Actions-based release workflow (#331) * chore: Added Actions-based release workflow * Set GOPATH * Fixed working directory for tests * Decrypting credentials into the testdata directory * Added preflight and post check scripts * chore: Running CI workflow on pull_request (#338) * fix(fcm): correct the iidEndpoint endpoints used for topic management (#335) According to the document https://developers.google.com/instance-id/reference/server, the endpoints should be: https://iid.googleapis.com/iid/v1:batchAdd https://iid.googleapis.com/iid/v1:batchRemove NOT: https://iid.googleapis.com/iid/v1/:batchAdd https://iid.googleapis.com/iid/v1/:batchRemove * fix(fcm): Fix documents of FCM batch request limit (#347) Co-authored-by: Hiranya Jayathilaka <hiranya911@gmail.com> * fix: Deferring credential loading until required (#361) * Bumped version to 3.12.1 (#363) * chore: Specifying correct working directory for staging command (#365) Co-authored-by: Rueian <rueiancsie@gmail.com> Co-authored-by: 178inaba <178inaba.git@gmail.com>
1 parent e088f55 commit 4343fa8

19 files changed

+558
-111
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[@]}"

.github/scripts/publish_post_check.sh

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
2+
#!/bin/bash
3+
4+
# Copyright 2020 Google Inc.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
19+
###################################### Outputs #####################################
20+
21+
# 1. version: The version of this release including the 'v' prefix (e.g. v1.2.3).
22+
# 2. changelog: Formatted changelog text for this release.
23+
24+
####################################################################################
25+
26+
set -e
27+
set -u
28+
29+
function echo_info() {
30+
local MESSAGE=$1
31+
echo "[INFO] ${MESSAGE}"
32+
}
33+
34+
function echo_warn() {
35+
local MESSAGE=$1
36+
echo "[WARN] ${MESSAGE}"
37+
}
38+
39+
function terminate() {
40+
echo ""
41+
echo_warn "--------------------------------------------"
42+
echo_warn "POST CHECK FAILED"
43+
echo_warn "--------------------------------------------"
44+
exit 1
45+
}
46+
47+
48+
echo_info "Starting publish post check..."
49+
echo_info "Git revision : ${GITHUB_SHA}"
50+
echo_info "Git ref : ${GITHUB_REF}"
51+
echo_info "Workflow triggered by : ${GITHUB_ACTOR}"
52+
echo_info "GitHub event : ${GITHUB_EVENT_NAME}"
53+
54+
55+
echo_info ""
56+
echo_info "--------------------------------------------"
57+
echo_info "Extracting release version"
58+
echo_info "--------------------------------------------"
59+
echo_info ""
60+
61+
echo_info "Loading version from: firebase.go"
62+
63+
readonly RELEASE_VERSION=`grep "const Version" firebase.go | awk '{print $4}' | tr -d \"` || true
64+
if [[ -z "${RELEASE_VERSION}" ]]; then
65+
echo_warn "Failed to extract release version from: firebase.go"
66+
terminate
67+
fi
68+
69+
if [[ ! "${RELEASE_VERSION}" =~ ^([0-9]*)\.([0-9]*)\.([0-9]*)$ ]]; then
70+
echo_warn "Malformed release version string: ${RELEASE_VERSION}. Exiting."
71+
terminate
72+
fi
73+
74+
echo_info "Extracted release version: ${RELEASE_VERSION}"
75+
echo "::set-output name=version::v${RELEASE_VERSION}"
76+
77+
78+
echo_info ""
79+
echo_info "--------------------------------------------"
80+
echo_info "Generating changelog"
81+
echo_info "--------------------------------------------"
82+
echo_info ""
83+
84+
echo_info "---< git fetch origin master --prune --unshallow >---"
85+
git fetch origin master --prune --unshallow
86+
echo ""
87+
88+
echo_info "Generating changelog from history..."
89+
readonly CURRENT_DIR=$(dirname "$0")
90+
readonly CHANGELOG=`${CURRENT_DIR}/generate_changelog.sh`
91+
echo "$CHANGELOG"
92+
93+
# Parse and preformat the text to handle multi-line output.
94+
# See https://github.community/t5/GitHub-Actions/set-output-Truncates-Multiline-Strings/td-p/37870
95+
FILTERED_CHANGELOG=`echo "$CHANGELOG" | grep -v "\\[INFO\\]"`
96+
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//'%'/'%25'}"
97+
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//$'\n'/'%0A'}"
98+
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//$'\r'/'%0D'}"
99+
echo "::set-output name=changelog::${FILTERED_CHANGELOG}"
100+
101+
102+
echo ""
103+
echo_info "--------------------------------------------"
104+
echo_info "POST CHECK SUCCESSFUL"
105+
echo_info "--------------------------------------------"
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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+
set -e
19+
set -u
20+
21+
function echo_info() {
22+
local MESSAGE=$1
23+
echo "[INFO] ${MESSAGE}"
24+
}
25+
26+
function echo_warn() {
27+
local MESSAGE=$1
28+
echo "[WARN] ${MESSAGE}"
29+
}
30+
31+
function terminate() {
32+
echo ""
33+
echo_warn "--------------------------------------------"
34+
echo_warn "PREFLIGHT FAILED"
35+
echo_warn "--------------------------------------------"
36+
exit 1
37+
}
38+
39+
40+
echo_info "Starting publish preflight check..."
41+
echo_info "Git revision : ${GITHUB_SHA}"
42+
echo_info "Git ref : ${GITHUB_REF}"
43+
echo_info "Workflow triggered by : ${GITHUB_ACTOR}"
44+
echo_info "GitHub event : ${GITHUB_EVENT_NAME}"
45+
46+
47+
echo_info ""
48+
echo_info "--------------------------------------------"
49+
echo_info "Extracting release version"
50+
echo_info "--------------------------------------------"
51+
echo_info ""
52+
53+
echo_info "Loading version from: firebase.go"
54+
55+
readonly RELEASE_VERSION=`grep "const Version" firebase.go | awk '{print $4}' | tr -d \"` || true
56+
if [[ -z "${RELEASE_VERSION}" ]]; then
57+
echo_warn "Failed to extract release version from: firebase.go"
58+
terminate
59+
fi
60+
61+
if [[ ! "${RELEASE_VERSION}" =~ ^([0-9]*)\.([0-9]*)\.([0-9]*)$ ]]; then
62+
echo_warn "Malformed release version string: ${RELEASE_VERSION}. Exiting."
63+
terminate
64+
fi
65+
66+
echo_info "Extracted release version: ${RELEASE_VERSION}"
67+
68+
69+
echo_info ""
70+
echo_info "--------------------------------------------"
71+
echo_info "Checking release tag"
72+
echo_info "--------------------------------------------"
73+
echo_info ""
74+
75+
echo_info "---< git fetch --depth=1 origin +refs/tags/*:refs/tags/* >---"
76+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
77+
echo ""
78+
79+
readonly EXISTING_TAG=`git rev-parse -q --verify "refs/tags/v${RELEASE_VERSION}"` || true
80+
if [[ -n "${EXISTING_TAG}" ]]; then
81+
echo_warn "Tag v${RELEASE_VERSION} already exists. Exiting."
82+
echo_warn "If the tag was created in a previous unsuccessful attempt, delete it and try again."
83+
echo_warn " $ git tag -d v${RELEASE_VERSION}"
84+
echo_warn " $ git push --delete origin v${RELEASE_VERSION}"
85+
86+
readonly RELEASE_URL="https://github.com/firebase/firebase-admin-go/releases/tag/v${RELEASE_VERSION}"
87+
echo_warn "Delete any corresponding releases at ${RELEASE_URL}."
88+
terminate
89+
fi
90+
91+
echo_info "Tag v${RELEASE_VERSION} does not exist."
92+
93+
94+
echo ""
95+
echo_info "--------------------------------------------"
96+
echo_info "PREFLIGHT SUCCESSFUL"
97+
echo_info "--------------------------------------------"

.github/scripts/run_all_tests.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
gpg --quiet --batch --yes --decrypt --passphrase="${FIREBASE_SERVICE_ACCT_KEY}" \
21+
--output testdata/integration_cert.json .github/resources/integ-service-account.json.gpg
22+
23+
echo "${FIREBASE_API_KEY}" > testdata/integration_apikey.txt
24+
25+
go test -v -race firebase.google.com/go/...

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: Go Continuous Integration
2-
on: [push, pull_request]
1+
name: Continuous Integration
2+
on: pull_request
33
jobs:
44

55
build:
@@ -22,7 +22,7 @@ jobs:
2222
uses: actions/checkout@v2
2323
with:
2424
path: go/src/firebase.google.com/go
25-
25+
2626
- name: Get dependencies
2727
run: go get -t -v $(go list ./... | grep -v integration)
2828

@@ -43,7 +43,7 @@ jobs:
4343
echo "Go code is not formatted:"
4444
gofmt -d -s .
4545
exit 1
46-
fi
46+
fi
4747
4848
- name: Run Static Analyzer
4949
run: go vet -v firebase.google.com/go/...

0 commit comments

Comments
 (0)