Skip to content

chore: make lerna able to push to develop #91

chore: make lerna able to push to develop

chore: make lerna able to push to develop #91

Workflow file for this run

# Inspired from https://github.com/backstage/backstage/blob/master/.github/workflows/ci.yml. Thanks!
# See ci.yml for info on `quality` and `tests` stages
name: Build
on:
workflow_dispatch:
push:
branches:
- develop
paths:
- "packages/**"
- ".github/workflows/build.yml"
defaults:
run:
shell: bash
jobs:
quality:
strategy:
# We use a matrix even if it's not needed here to be able to re-use the same Yarn setup snippet everywhere
matrix:
os: [ubuntu-latest]
node-version: [20.x] # Active LTS (https://github.com/nodejs/release)
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
# Beginning of yarn setup [KEEP IN SYNC BETWEEN ALL WORKFLOWS] (copy/paste of ci.yml's snippet)
- name: use node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/
- name: cache all node_modules
id: cache-modules
uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-v${{ matrix.node-version }}-node_modules-${{ hashFiles('yarn.lock', '**/package.json') }}
- name: find location of global yarn cache
id: yarn-cache
if: steps.cache-modules.outputs.cache-hit != 'true'
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: cache global yarn cache
uses: actions/cache@v2
if: steps.cache-modules.outputs.cache-hit != 'true'
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: yarn install
if: steps.cache-modules.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
# End of yarn setup
# TODO: make dev & test work without having to build everything (inspiration: https://github.com/Izhaki/mono.ts)
- name: build
run: yarn build
- name: format
run: yarn format
- name: lint
run: yarn lint
tests:
needs: quality
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version:
- 20.x # Active LTS (https://github.com/nodejs/release)
- 18.x # Maintenance LTS
exclude: # these cases are tested after the release with E2E tests
- os: windows-latest
node-version: 18.x
- os: windows-latest
node-version: 18.x
- os: macos-latest
node-version: 18.x
- os: macos-latest
node-version: 18.x
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # fetch all history to make Jest snapshot tests work
# Beginning of yarn setup [KEEP IN SYNC BETWEEN ALL WORKFLOWS] (copy/paste of ci.yml's snippet)
- name: use node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/
- name: cache all node_modules
id: cache-modules
uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-v${{ matrix.node-version }}-node_modules-${{ hashFiles('yarn.lock', '**/package.json') }}
- name: find location of global yarn cache
id: yarn-cache
if: steps.cache-modules.outputs.cache-hit != 'true'
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: cache global yarn cache
uses: actions/cache@v2
if: steps.cache-modules.outputs.cache-hit != 'true'
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: yarn install
if: steps.cache-modules.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
# End of yarn setup
# We have to build all the packages before the tests
# Because init-log4brains's integration tests use @log4brains/cli, which uses @log4brains/core
# TODO: we should separate tests that require built packages of the others, to get a quicker feedback
# Once it's done, we should add "yarn test" in each package's preVersion script
- name: build
run: |
yarn build
yarn link-cli
echo "$(yarn global bin)" >> $GITHUB_PATH
- name: typescript checks
run: yarn typescript
- name: test
run: yarn test
- name: E2E tests
run: yarn e2e
publish-pages:
needs: tests
strategy:
# We use a matrix even if it's not needed here to be able to re-use the same Yarn setup snippet everywhere
matrix:
os: [ubuntu-latest]
node-version: [20.x] # Active LTS (https://github.com/nodejs/release)
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false # required by JamesIves/github-pages-deploy-action
fetch-depth: 0 # required by Log4brains to work correctly (needs the whole Git history)
# Beginning of yarn setup [KEEP IN SYNC BETWEEN ALL WORKFLOWS] (copy/paste of ci.yml's snippet)
- name: use node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/
- name: cache all node_modules
id: cache-modules
uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-v${{ matrix.node-version }}-node_modules-${{ hashFiles('yarn.lock', '**/package.json') }}
- name: find location of global yarn cache
id: yarn-cache
if: steps.cache-modules.outputs.cache-hit != 'true'
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: cache global yarn cache
uses: actions/cache@v2
if: steps.cache-modules.outputs.cache-hit != 'true'
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: yarn install
if: steps.cache-modules.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
# End of yarn setup
- name: build
run: |
yarn build
yarn link-cli
echo "$(yarn global bin)" >> $GITHUB_PATH
- name: build self knowledge base
env:
HIDE_LOG4BRAINS_VERSION: "1" # TODO: use lerna to bump the version temporarily here so we don't have to hide it
run: log4brains build --basePath /${GITHUB_REPOSITORY#*/}/adr
- name: publish self knowledge base
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: .log4brains/out
TARGET_FOLDER: adr
release:
needs: publish-pages # we could perform this step in parallel but this acts as a last end-to-end test before releasing
strategy:
# We use a matrix even if it's not needed here to be able to re-use the same Yarn setup snippet everywhere
matrix:
os: [ubuntu-latest]
node-version: [20.x] # Active LTS (https://github.com/nodejs/release)
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all history for Lerna (https://stackoverflow.com/a/60184319/9285308)
ssh-key: ${{ secrets.LERNA_GITHUB_DEPLOY_KEY }} # so that Lerna is able to push to the protected branch (https://github.com/orgs/community/discussions/25305#discussioncomment-10728028)
- name: fetch all git tags for Lerna # (https://stackoverflow.com/a/60184319/9285308)
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
# Beginning of yarn setup [KEEP IN SYNC BETWEEN ALL WORKFLOWS] (copy/paste of ci.yml's snippet)
- name: use node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/
- name: cache all node_modules
id: cache-modules
uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-v${{ matrix.node-version }}-node_modules-${{ hashFiles('yarn.lock', '**/package.json') }}
- name: find location of global yarn cache
id: yarn-cache
if: steps.cache-modules.outputs.cache-hit != 'true'
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: cache global yarn cache
uses: actions/cache@v2
if: steps.cache-modules.outputs.cache-hit != 'true'
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: yarn install
if: steps.cache-modules.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
# End of yarn setup
- name: build
run: yarn build
- name: git identity
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: release and publish to NPM
run: yarn lerna publish --yes --conventional-commits --conventional-prerelease --exact --create-release github
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}