fix: update dependencies #58
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] }} | |
# Build the TypeScript outputs | |
- name: Build distribution packages | |
run: lerna run build | |
# 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 | |
documentation: | |
name: Docs on GitHub Pages | |
runs-on: ubuntu-latest | |
needs: [ packages ] | |
# Allow GitHub Actions to deploy documentation | |
permissions: | |
contents: read | |
actions: read | |
id-token: write | |
pages: write | |
# Deploy to the github-pages environment | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
# Build documentation site | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version-file: 'package.json' | |
- name: Install Dependencies | |
run: npm ci | |
- name: Build Pages | |
run: | | |
npm run build | |
npm run docs | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
# Upload docs directory | |
path: 'docs' | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 |