Lock file maintenance (#300) #1009
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: CI | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
concurrency: ${{ github.ref }}-ci | |
jobs: | |
ci: | |
outputs: | |
shouldCancel: ${{ steps.batchRuns.outputs.shouldCancel }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
cache: yarn | |
- run: yarn --frozen-lockfile --ignore-scripts | |
- run: yarn syncpack:check | |
- run: yarn format:check | |
- run: yarn beachball check | |
- run: yarn build | |
- run: yarn lint | |
- run: yarn test | |
- run: yarn package | |
- name: e2e - install-beachball | |
uses: ./install-beachball | |
- name: e2e - check-for-modified-files | |
uses: ./check-for-modified-files | |
- name: e2e - batch-runs | |
uses: ./batch-runs | |
id: batchRuns | |
with: | |
mode: output | |
token: ${{ github.token }} | |
- name: e2e - batch-runs result | |
uses: actions/github-script@v7 | |
if: ${{ steps.batchRuns.outputs.shouldCancel != 'no' }} | |
with: | |
script: | | |
const shouldCancel = '${{ steps.batchRuns.outputs.shouldCancel }}'; | |
if (shouldCancel === 'yes' && process.env.GITHUB_REF_NAME === 'main') { | |
core.info('Newer run is pending for main'); | |
} else { | |
core.setFailed(`batch-runs unexpectedly returned "${shouldCancel}"`); | |
} | |
# Note: this is not actually used here to determine if a release is needed | |
- name: e2e - should-release | |
uses: ./should-release | |
id: shouldRelease | |
with: | |
mode: output | |
token: ${{ github.token }} | |
batch: true | |
- name: e2e - should-release result | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const shouldRelease = '${{ steps.shouldRelease.outputs.shouldRelease }}'; | |
if (shouldRelease !== 'yes' && shouldRelease !== 'no') { | |
core.setFailed(`should-release returned "${shouldRelease}" instead of "yes" or "no"`); | |
} else { | |
core.info(`should-release returned shouldRelease: "${shouldRelease}"`); | |
} | |
# Run the release in a separate job with release environment access. | |
# This approach requires re-running the build but skips the tests. | |
release: | |
needs: ci | |
if: ${{ github.ref == 'refs/heads/main' && needs.ci.outputs.shouldCancel == 'no' }} | |
runs-on: ubuntu-latest | |
# This environment contains secrets needed for releasing | |
environment: release | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
cache: yarn | |
- run: yarn --frozen-lockfile --ignore-scripts | |
- run: yarn build | |
- run: yarn package | |
# Verify that no newer runs were queued since the check in the previous job | |
- uses: ./batch-runs | |
id: batchRuns | |
with: | |
mode: output | |
token: ${{ github.token }} | |
- name: Set git config | |
run: | | |
git config user.name "Elizabeth Craig" | |
git config user.email "[email protected]" | |
git remote set-url origin "https://[email protected]/$GITHUB_REPOSITORY" | |
env: | |
REPO_PAT: ${{ secrets.REPO_PAT }} | |
- name: Publish common package to npm | |
if: ${{ steps.batchRuns.outputs.shouldCancel == 'no' }} | |
run: | | |
yarn beachball publish -b origin/main -y -n "$NPM_TOKEN" | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Release actions | |
if: ${{ steps.batchRuns.outputs.shouldCancel == 'no' }} | |
uses: int128/release-typescript-action@v1 | |
with: | |
major-version: 2 | |
token: ${{ github.token }} |