applying package updates #983
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: | |
workflow_dispatch: | |
push: | |
branches: [master, v1] | |
paths-ignore: | |
- "docs/**" | |
permissions: | |
contents: write | |
# Only run one release at a time to avoid duplicate attempts to publish particular versions. | |
# To avoid backups after multiple pushes in rapid succession, the prerelease job below emulates | |
# batching (which github actions don't support) by skipping the release job if a newer run is pending. | |
# | |
# (There's an option "cancel-in-progress" to cancel in-progress workflows upon a new request, but | |
# that's not safe because it could potentially cause a job to be cancelled in the middle of the | |
# actual npm publish step, leaving things in an inconsistent state.) | |
concurrency: | |
group: release-${{ github.ref }} | |
jobs: | |
# Only run the actual release if change files are present. | |
# Also skip this run if there are any newer pending runs. | |
prerelease: | |
runs-on: ubuntu-latest | |
outputs: | |
shouldRelease: ${{ steps.shouldRelease.outputs.shouldRelease }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
# Cancel the release if a newer run is pending or no change files are present | |
- uses: ecraig12345/beachball-actions/should-release@v1 | |
id: shouldRelease | |
with: | |
token: ${{ github.token }} | |
batch: true | |
mode: output | |
release: | |
needs: prerelease | |
if: ${{ needs.prerelease.outputs.shouldRelease == 'yes' }} | |
runs-on: ubuntu-latest | |
# This environment contains secrets needed for publishing | |
environment: release | |
strategy: | |
matrix: | |
node-version: [18.x] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
# Don't save creds in the git config (so it's easier to override later) | |
persist-credentials: false | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- run: yarn | |
- run: yarn ci --concurrency 2 --verbose | |
- name: Set git user | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "Ken Chau" | |
- name: Publish | |
run: | | |
# 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 }} |