chore: bump lerna to v7 #35
Workflow file for this run
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
# Inspired by: https://dev.to/xcanchal/automatic-versioning-in-a-lerna-monorepo-using-github-actions-4hij | |
name: Publish | |
on: | |
# Runs on pull requests merged into the main and beta branches | |
pull_request: | |
types: | |
- 'closed' | |
branches: | |
- 'main' | |
- 'beta' | |
# Allow one concurrent deployment | |
concurrency: | |
group: "publish" | |
cancel-in-progress: false | |
jobs: | |
packages: | |
# According to the "on" attribute that we configured, this workflow will trigger on every "Pull Request closed" event | |
# against beta or main, but what we actually want is to execute it ONLY when the Pull Request has been merged | |
# (not discarded). | |
if: github.event.pull_request.merged == true | |
name: ${{ matrix.registry.name }} package | |
runs-on: ubuntu-latest | |
# Allow GitHub Action to read repo and install/publish packages from GitHub Package Registry | |
permissions: | |
contents: read | |
packages: write | |
# Publish to both NPM and GitHub Package Registry | |
strategy: | |
matrix: | |
registry: | |
- name: npm | |
token: NPM_TOKEN | |
url: https://registry.npmjs.org | |
- name: GitHub | |
token: GITHUB_TOKEN | |
url: https://npm.pkg.github.com | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
# Lerna needs the git history to automatically bump package versions | |
fetch-depth: 0 | |
- name: Restore Lerna | |
uses: actions/cache@v3 | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version-file: 'package.json' | |
# Publish to the provided registry... | |
registry-url: ${{ matrix.registry.url }} | |
# ...and under the byu-oit scope | |
scope: '@byu-oit' | |
# Install and link package dependencies | |
- name: Install dependencies | |
run: npm ci | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets[matrix.registry.token] }} | |
# Allow Lerna to make commits and create tags for the new versions in the repository. For that, we'll take | |
# advantage of the "github.actor" variable available in the environment. | |
- name: Set Git User | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
# Lerna Version Command Docs: https://github.com/lerna/lerna/tree/main/libs/commands/version | |
- name: Beta Version | |
if: github.base_ref == 'beta' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets[matrix.registry.token] }} | |
run: lerna version --no-private --no-commit-hooks --no-push --conventional-commits --conventional-prerelease --preid beta --yes | |
- name: Version | |
if: github.base_ref == 'main' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets[matrix.registry.token] }} | |
run: lerna version --no-private --no-commit-hooks --no-push --conventional-commits --conventional-graduate --yes | |
# Lerna Publish Command Docs: https://github.com/lerna/lerna/tree/main/libs/commands/publish | |
- name: Publish Package | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets[matrix.registry.token] }} | |
run: lerna publish from-git --yes --no-private | |
release: | |
name: GitHub Release | |
# According to the "on" attribute that we configured, this workflow will trigger on every "Pull Request closed" event | |
# against beta or main, but what we actually want is to execute it ONLY when the Pull Request has been merged | |
# (not discarded). | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
needs: [ packages ] | |
# Allow GitHub Action to read repo and install/publish packages from GitHub Package Registry | |
permissions: | |
contents: write | |
packages: read | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
# Lerna needs the git history to automatically bump package versions | |
fetch-depth: 0 | |
- name: Restore Lerna | |
uses: actions/cache@v3 | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version-file: 'package.json' | |
# Allow Lerna to make commits and create tags for the new versions in the repository. For that, we'll take | |
# advantage of the "github.actor" variable available in the environment. | |
- name: Set Git User | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor}}@users.noreply.github.com" | |
# Lerna Version Command Docs: https://github.com/lerna/lerna/tree/main/libs/commands/version | |
# The difference between this job and the "publish" job is that we add `--create-release github` and removed | |
# `--no-push` to the lerna version command options. | |
- name: Publish Beta Releases to GitHub | |
if: github.base_ref == 'beta' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: lerna version --no-private --no-commit-hooks --conventional-commits --create-release github --conventional-prerelease --preid beta --yes | |
- name: Publish Releases to GitHub | |
if: github.base_ref == 'main' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: lerna version --no-private --no-commit-hooks --conventional-commits --create-release github --conventional-graduate --yes |