Skip to content

Create staging release workflow #6279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ name: E2E Smoke Tests

# Allows REST trigger. Currently triggered by release-cli script during a staging run.
on:
workflow_dispatch:
inputs:
versionOrTag:
description: 'release version or tag'
required: true
default: 'next'
repository_dispatch:
types: [staging-tests]

jobs:
test:
Expand Down Expand Up @@ -39,8 +35,8 @@ jobs:
echo "export const config = $PROJECT_CONFIG; export const testAccount = $TEST_ACCOUNT" > firebase-config.js
- name: Yarn install
run: |
echo "Installing firebase@${{ github.event.inputs.versionOrTag }}"
yarn add firebase@${{ github.event.inputs.versionOrTag }}
echo "Installing firebase@${{ github.event.client_payload.versionOrTag }}"
yarn add firebase@${{ github.event.client_payload.versionOrTag }}
yarn
- name: Deploy "callTest" cloud function
run: |
Expand Down
141 changes: 141 additions & 0 deletions .github/workflows/release-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Staging Release

on:
push:
branches:
- master
workflow_dispatch:

jobs:
deploy:
name: Staging Release
runs-on: ubuntu-latest

steps:
- name: Set up Node (14)
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Merge master into release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.repos.merge({
owner: context.repo.owner,
repo: context.repo.repo,
base: 'release',
head: 'master'
})
- name: Checkout release branch (with history)
uses: actions/checkout@master
with:
# Release script requires git history and tags.
fetch-depth: 0
ref: release
- name: Yarn install
run: yarn
# Ensures a new @firebase/app is published with every release.
# This keeps the SDK_VERSION variable up to date.
- name: Add a changeset for @firebase/app
# pull master so changeset can diff against it
run: |
git pull -f --no-rebase origin master:master
yarn ts-node-script scripts/ci/add_changeset.ts
- name: Create Release Pull Request
uses: changesets/action@v1
env:
GITHUB_TOKEN: ${{ secrets.OSS_BOT_GITHUB_TOKEN }}
- name: Get release version
id: get-version
# STAGING_VERSION = version with staging hash, e.g. 1.2.3-20430523
# BASE_VERSION = version without staging hash, e.g. 1.2.3
run: |
VERSION_SCRIPT="const pkg = require('./packages/firebase/package.json'); console.log(pkg.version);"
VERSION=`node -e "${VERSION_SCRIPT}"`
echo "::set-output name=STAGING_VERSION::$VERSION"
BASE_VERSION=$(echo ${{ steps.get-version.outputs.STAGING_VERSION }} | cut -d "-" -f 1)
echo "::set-output name=BASE_VERSION::$BASE_VERSION"
- name: Echo version in shell
run: |
echo "Staging release ${{ steps.get-version.outputs.STAGING_VERSION }}"
- 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 staging --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_MESSAGING_TYPES: ${{secrets.NPM_TOKEN_MESSAGING_TYPES}}
NPM_TOKEN_PERFORMANCE: ${{secrets.NPM_TOKEN_PERFORMANCE}}
NPM_TOKEN_PERFORMANCE_TYPES: ${{secrets.NPM_TOKEN_PERFORMANCE_TYPES}}
NPM_TOKEN_POLYFILL: ${{secrets.NPM_TOKEN_POLYFILL}}
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_TESTING: ${{secrets.NPM_TOKEN_TESTING}}
NPM_TOKEN_UTIL: ${{secrets.NPM_TOKEN_UTIL}}
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: Launch E2E tests workflow
# Trigger e2e-test.yml
run: |
OSS_BOT_GITHUB_TOKEN=${{ secrets.OSS_BOT_GITHUB_TOKEN }}
VERSION_OR_TAG=${{ steps.get-version.outputs.STAGING_VERSION }}
curl -X POST \
-H "Content-Type:application/json" \
-H "Accept:application/vnd.github.v3+json" \
-H "Authorization:Bearer $OSS_BOT_GITHUB_TOKEN" \
-d "{\"event_type\":\"staging-tests\", \"client_payload\":{\"versionOrTag\":\"$VERSION_OR_TAG\"}}" \
https://api.github.com/repos/firebase/firebase-js-sdk/dispatches
- 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 }}
STAGING_VERSION=${{ steps.get-version.outputs.STAGING_VERSION }}
OPERATOR=${{ github.actor }}
RELEASE_TRACKER_URL=${{ secrets.RELEASE_TRACKER_URL }}
curl -X POST -H "Content-Type:application/json" \
-d "{\"version\":\"$BASE_VERSION\",\"tag\":\"$STAGING_VERSION\",\"date\":\"$DATE\",\"operator\":\"$OPERATOR\"}" \
$RELEASE_TRACKER_URL/logStaging