Release #1104
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
# release daily | |
# https://crontab-generator.org/ | |
schedule: | |
- cron: '0 8 * * *' | |
# or on manual trigger | |
workflow_dispatch: | |
env: | |
npmVersion: 8 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
# This environment contains secrets needed for publishing | |
environment: release | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
# Fetch all history (required for publishing which looks at history) | |
fetch-depth: 0 | |
# Don't save creds in the git config (so it's easier to override later) | |
persist-credentials: false | |
- name: Install Node.js from .nvmrc | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
# Guarantee a predictable version of npm (the PR build tests against both 6 and 8) | |
- name: Install package managers | |
run: npm install --global npm@${{ env.npmVersion }} yarn@1 | |
- run: yarn --frozen-lockfile | |
- run: yarn build | |
- run: yarn test:unit | |
- run: yarn test:func | |
- name: yarn test:e2e (npm ${{ env.npmVersion }}) | |
run: yarn test:e2e | |
- name: Publish package | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "Ken Chau" | |
# Get the existing remote URL without creds, and use a trap (like try/finally) | |
# to restore it after this step finishes | |
trap "git remote set-url origin '$(git remote get-url origin)'" EXIT | |
# Add a token to the remote URL for auth during release | |
git remote set-url origin "https://[email protected]/$GITHUB_REPOSITORY" | |
yarn release -y -n "$NPM_AUTHTOKEN" | |
env: | |
NPM_AUTHTOKEN: ${{ secrets.NPM_AUTHTOKEN }} | |
REPO_PAT: ${{ secrets.REPO_PAT }} | |
- name: Update docs | |
run: | | |
# See previous step for explanation | |
trap "git remote set-url origin '$(git remote get-url origin)'" EXIT | |
git remote set-url origin "https://[email protected]/$GITHUB_REPOSITORY" | |
yarn release:docs | |
env: | |
REPO_PAT: ${{ secrets.REPO_PAT }} |