Skip to content

Production Release

Production Release #68

Workflow file for this run

# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Production Release
on:
workflow_dispatch:
inputs:
release-branch:
description: 'Release branch'
type: string
default: 'release'
required: true
jobs:
deploy:
name: Production Release
runs-on: ubuntu-latest
# Allow GITHUB_TOKEN to have write permissions
permissions:
contents: write
steps:
- name: Set up node (20)
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Checkout release branch (with history)
uses: actions/checkout@master
with:
# Release script requires git history and tags.
fetch-depth: 0
ref: ${{ github.event.inputs.release-branch }}
token: ${{ secrets.OSS_BOT_GITHUB_TOKEN }}
- name: Yarn install
run: yarn
- name: Publish to NPM
# --skipTests No need to run tests
# --skipReinstall Yarn install has already been run
# --ignoreUnstaged Adding the @firebase/app changeset file means
# there's unstaged changes. Ignore.
# TODO: Make these flags defaults in the release script.
run: yarn release --releaseType Production --ci --skipTests --skipReinstall --ignoreUnstaged
env:
NPM_TOKEN_ANALYTICS: ${{secrets.NPM_TOKEN_ANALYTICS}}
NPM_TOKEN_ANALYTICS_INTEROP_TYPES: ${{secrets.NPM_TOKEN_ANALYTICS_INTEROP_TYPES}}
NPM_TOKEN_ANALYTICS_TYPES: ${{secrets.NPM_TOKEN_ANALYTICS_TYPES}}
NPM_TOKEN_APP: ${{secrets.NPM_TOKEN_APP}}
NPM_TOKEN_APP_TYPES: ${{secrets.NPM_TOKEN_APP_TYPES}}
NPM_TOKEN_APP_CHECK: ${{secrets.NPM_TOKEN_APP_CHECK}}
NPM_TOKEN_APP_CHECK_INTEROP_TYPES: ${{secrets.NPM_TOKEN_APP_CHECK_INTEROP_TYPES}}
NPM_TOKEN_APP_CHECK_TYPES: ${{secrets.NPM_TOKEN_APP_CHECK_TYPES}}
NPM_TOKEN_AUTH: ${{secrets.NPM_TOKEN_AUTH}}
NPM_TOKEN_AUTH_INTEROP_TYPES: ${{secrets.NPM_TOKEN_AUTH_INTEROP_TYPES}}
NPM_TOKEN_AUTH_TYPES: ${{secrets.NPM_TOKEN_AUTH_TYPES}}
NPM_TOKEN_COMPONENT: ${{secrets.NPM_TOKEN_COMPONENT}}
NPM_TOKEN_DATABASE: ${{secrets.NPM_TOKEN_DATABASE}}
NPM_TOKEN_DATABASE_TYPES: ${{secrets.NPM_TOKEN_DATABASE_TYPES}}
NPM_TOKEN_FIRESTORE: ${{secrets.NPM_TOKEN_FIRESTORE}}
NPM_TOKEN_FIRESTORE_TYPES: ${{secrets.NPM_TOKEN_FIRESTORE_TYPES}}
NPM_TOKEN_FUNCTIONS: ${{secrets.NPM_TOKEN_FUNCTIONS}}
NPM_TOKEN_FUNCTIONS_TYPES: ${{secrets.NPM_TOKEN_FUNCTIONS_TYPES}}
NPM_TOKEN_INSTALLATIONS: ${{secrets.NPM_TOKEN_INSTALLATIONS}}
NPM_TOKEN_INSTALLATIONS_TYPES: ${{secrets.NPM_TOKEN_INSTALLATIONS_TYPES}}
NPM_TOKEN_LOGGER: ${{secrets.NPM_TOKEN_LOGGER}}
NPM_TOKEN_MESSAGING: ${{secrets.NPM_TOKEN_MESSAGING}}
NPM_TOKEN_PERFORMANCE: ${{secrets.NPM_TOKEN_PERFORMANCE}}
NPM_TOKEN_PERFORMANCE_TYPES: ${{secrets.NPM_TOKEN_PERFORMANCE_TYPES}}
NPM_TOKEN_REMOTE_CONFIG: ${{secrets.NPM_TOKEN_REMOTE_CONFIG}}
NPM_TOKEN_REMOTE_CONFIG_TYPES: ${{secrets.NPM_TOKEN_REMOTE_CONFIG_TYPES}}
NPM_TOKEN_RULES_UNIT_TESTING: ${{secrets.NPM_TOKEN_RULES_UNIT_TESTING}}
NPM_TOKEN_STORAGE: ${{secrets.NPM_TOKEN_STORAGE}}
NPM_TOKEN_STORAGE_TYPES: ${{secrets.NPM_TOKEN_STORAGE_TYPES}}
NPM_TOKEN_UTIL: ${{secrets.NPM_TOKEN_UTIL}}
NPM_TOKEN_VERTEXAI_PREVIEW: ${{secrets.NPM_TOKEN_VERTEXAI_PREVIEW}}
NPM_TOKEN_WEBCHANNEL_WRAPPER: ${{secrets.NPM_TOKEN_WEBCHANNEL_WRAPPER}}
NPM_TOKEN_FIREBASE: ${{secrets.NPM_TOKEN_FIREBASE}}
NPM_TOKEN_APP_COMPAT: ${{ secrets.NPM_TOKEN_APP_COMPAT }}
NPM_TOKEN_INSTALLATIONS_COMPAT: ${{ secrets.NPM_TOKEN_INSTALLATIONS_COMPAT }}
NPM_TOKEN_ANALYTICS_COMPAT: ${{ secrets.NPM_TOKEN_ANALYTICS_COMPAT }}
NPM_TOKEN_AUTH_COMPAT: ${{ secrets.NPM_TOKEN_AUTH_COMPAT }}
NPM_TOKEN_MESSAGING_INTEROP_TYPES: ${{ secrets.NPM_TOKEN_MESSAGING_INTEROP_TYPES }}
NPM_TOKEN_FUNCTIONS_COMPAT: ${{ secrets.NPM_TOKEN_FUNCTIONS_COMPAT }}
NPM_TOKEN_MESSAGING_COMPAT: ${{ secrets.NPM_TOKEN_MESSAGING_COMPAT }}
NPM_TOKEN_PERFORMANCE_COMPAT: ${{ secrets.NPM_TOKEN_PERFORMANCE_COMPAT }}
NPM_TOKEN_REMOTE_CONFIG_COMPAT: ${{ secrets.NPM_TOKEN_REMOTE_CONFIG_COMPAT }}
NPM_TOKEN_DATABASE_COMPAT: ${{ secrets.NPM_TOKEN_DATABASE_COMPAT }}
NPM_TOKEN_FIRESTORE_COMPAT: ${{ secrets.NPM_TOKEN_FIRESTORE_COMPAT }}
NPM_TOKEN_STORAGE_COMPAT: ${{ secrets.NPM_TOKEN_STORAGE_COMPAT }}
NPM_TOKEN_APP_CHECK_COMPAT: ${{ secrets.NPM_TOKEN_APP_CHECK_COMPAT }}
NPM_TOKEN_API_DOCUMENTER: ${{ secrets.NPM_TOKEN_API_DOCUMENTER }}
CI: true
- name: Get release version
id: get-version
# In production, there is only one version number
run: |
VERSION_SCRIPT="const pkg = require('./packages/firebase/package.json'); console.log(pkg.version);"
VERSION=`node -e "${VERSION_SCRIPT}"`
echo "BASE_VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Echo version in shell
run: |
echo "Base version: ${{ steps.get-version.outputs.BASE_VERSION }}"
- name: Log to release tracker
# Sends release information to cloud functions endpoint of release tracker.
run: |
DATE=$(date +'%m/%d/%Y')
BASE_VERSION=${{ steps.get-version.outputs.BASE_VERSION }}
RELEASE_TRACKER_URL=${{ secrets.RELEASE_TRACKER_URL }}
curl -X POST -H "Content-Type:application/json" \
-d "{\"version\":\"$BASE_VERSION\",\"date\":\"$DATE\"}" \
$RELEASE_TRACKER_URL/logProduction
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get the newest release tag for the firebase package (e.g. [email protected])
NEWEST_TAG=$(git describe --tags --match "firebase@[0-9]*.[0-9]*.[0-9]*" --abbrev=0)
# Get the release notes from the description of the most recent merged PR into the "release" branch
# See: https://github.com/firebase/firebase-js-sdk/pull/8236 for an example description
JSON_RELEASE_NOTES=$(gh pr list \
--repo "$GITHUB_REPOSITORY" \
--state "merged" \
--base "release" \
--limit 1 \
--json "body" \
| jq '.[].body | split("\n# Releases\n")[-1]' # Remove the generated changesets header
)
# Prepend the new release header
# We have to be careful to insert the new release header after a " character, since we're
# modifying the JSON string
JSON_RELEASE_NOTES="\"For more detailed release notes, see [Firebase JavaScript SDK Release Notes](https://firebase.google.com/support/release-notes/js).\n\n# What's Changed\n\n${JSON_RELEASE_NOTES:1}"
# Format the JSON string into a readable markdown string
RELEASE_NOTES=$(echo -E $JSON_RELEASE_NOTES | jq -r .)
# Create the GitHub release
gh release create "$NEWEST_TAG" \
--repo "$GITHUB_REPOSITORY" \
--title "$NEWEST_TAG" \
--notes "$RELEASE_NOTES" \
--verify-tag