ci: add changeset version model

This commit is contained in:
janniks
2022-06-14 13:59:05 +02:00
committed by janniks
parent a99f0f70c5
commit 31dcaae0d3
9 changed files with 226 additions and 215 deletions

View File

@@ -1,37 +0,0 @@
name: circular dependency checks
on:
push:
branches:
- '**'
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
env:
NODE_OPTIONS: --max-old-space-size=4096
steps:
- uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v2
with:
node-version: 16
- name: Restore lerna cache
uses: actions/cache@v2
with:
path: |
node_modules
packages/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm i
- name: Bootstrap
run: npm run bootstrap
- name: List circular dependencies
run: npm run madge

View File

@@ -1,37 +0,0 @@
name: lint
on:
push:
branches:
- '**'
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
env:
NODE_OPTIONS: --max-old-space-size=4096
steps:
- uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v2
with:
node-version: 16
- name: Restore lerna cache
uses: actions/cache@v2
with:
path: |
node_modules
packages/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm i
- name: Bootstrap
run: npm run bootstrap
- name: Lint
run: npm run lint

46
.github/workflows/publish.yml vendored Normal file
View File

@@ -0,0 +1,46 @@
name: publish
on:
push:
branches:
- master
tags-ignore:
- "**"
workflow_dispatch:
jobs:
pre_run:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@ad6cb1b847ffb509a69b745b6ee2f1d14dfe14b8
with:
access_token: ${{ github.token }}
publish_beta:
runs-on: ubuntu-latest
needs: pre_run
if: "contains(github.event.head_commit.message, 'chore: version packages')"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- run: npm ci
- run: npm run bootstrap
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish
run: |
NODE_ENV=production npx lerna publish from-package --no-verify-access --yes
export RELEASE=$(cat lerna.json | jq -r '.version')
git tag -a v$RELEASE -m v$RELEASE
git push origin v$RELEASE

58
.github/workflows/publish_beta.yml vendored Normal file
View File

@@ -0,0 +1,58 @@
name: publish-beta
on:
push:
branches:
- master
tags-ignore:
- "**"
workflow_dispatch:
jobs:
pre_run:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@ad6cb1b847ffb509a69b745b6ee2f1d14dfe14b8
with:
access_token: ${{ github.token }}
publish_beta:
runs-on: ubuntu-latest
needs: pre_run
if: "!contains(github.event.head_commit.message, 'chore: version packages')"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# pulls all tags (needed for lerna to correctly version)
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- run: npm ci
- run: npm run bootstrap
- run: git config --local user.email 'action@github.com'
- run: git config --local user.name 'GitHub Action'
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Version & Publish
run: |
npx lerna-from-npm
git tag -d `git tag | grep -E 'beta'`
npx lerna version --conventional-commits --conventional-prerelease --preid beta --no-push --no-git-tag-version --yes
git commit -a -m 'DONT PUSH'
npx lerna publish from-package --no-verify-access --pre-dist-tag beta --yes
export RELEASE=$(cat lerna.json | jq -r '.version')
git reset HEAD~ --hard
git tag v$RELEASE
git push origin v$RELEASE

77
.github/workflows/pull_request.yml vendored Normal file
View File

@@ -0,0 +1,77 @@
name: pull-request
on: [pull_request, workflow_dispatch]
jobs:
pre_run:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@ad6cb1b847ffb509a69b745b6ee2f1d14dfe14b8
with:
access_token: ${{ github.token }}
code_checks:
runs-on: ubuntu-latest
needs: pre_run
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- run: npm ci
- name: Bootstrap lerna
run: npm run bootstrap
- name: Check bootstrap
run: |
if [[ -n $(git status -s) ]]; then
git status
echo "Error: file tree is not clean; Likely needs bootstraping"
echo "Run `npm run bootstrap` and commit to resolve"
exit 1
fi
- run: npm run lint
- run: npm run typecheck
- name: Check for circular dependencies
run: npm run madge
- run: npm run lerna run test --stream --parallel -- -- --coverage
- uses: codecov/codecov-action@v1
check_fork:
runs-on: ubuntu-latest
outputs:
is_not_fork: ${{ steps.check.outputs.is_not_fork }}
steps:
- id: check
run: echo "::set-output name=is_not_fork::${{ env.NPM_TOKEN != '' }}"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
publish_npm_pr:
runs-on: ubuntu-latest
needs: [pre_run, check_fork]
if: needs.check_fork.outputs.is_not_fork == 'true'
steps:
- uses: actions/checkout@v3
if: github.event_name == 'pull_request'
with:
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/checkout@v3
if: github.event_name == 'workflow_dispatch'
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- run: npm ci
- run: npm run bootstrap
- id: git-commit
run: echo "::set-output name=sha::$(git rev-parse --short HEAD)"
- run: echo $SHA
env:
SHA: ${{ steps.git-commit.outputs.sha }}
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: npx lerna publish prepatch --preid pr.$SHA --dist-tag pr --no-verify-access --no-push --no-git-tag-version --yes
env:
SHA: ${{ steps.git-commit.outputs.sha }}

View File

@@ -1,61 +0,0 @@
name: release beta
on:
push:
branches:
- master
tags-ignore:
- "**"
paths-ignore:
- "**/CHANGELOG.md"
jobs:
release:
name: Release Beta
runs-on: macos-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
with:
# pulls all commits (needed for lerna / semantic release to correctly version)
fetch-depth: "0"
# pulls all tags (needed for lerna / semantic release to correctly version)
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set Node Version
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install dependencies
run: npm ci
- name: Bootstrap
run: |
npx lerna bootstrap
if [[ -n $(git status -s) ]]; then
echo "Error: file tree is not clean"
git status
exit 1
fi
- name: Test
run: npm run test
- name: Build
run: NODE_ENV=production npm run build
- name: "Release"
run: |
npx lerna-from-npm
npx lerna version --conventional-commits --conventional-prerelease --preid beta --no-push --no-git-tag-version --yes
git commit -a -m 'DONT PUSH'
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
npx lerna publish from-package --no-verify-access --pre-dist-tag beta --yes
export RELEASE=$(cat lerna.json | jq -r '.version')
git reset HEAD~ --hard
git tag v$RELEASE
git push origin v$RELEASE
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@@ -1,43 +0,0 @@
name: tests
on:
push:
branches:
- '**'
pull_request:
jobs:
tests:
runs-on: ubuntu-latest
env:
NODE_OPTIONS: --max-old-space-size=4096
steps:
- uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v2
with:
node-version: 16
- name: Restore lerna cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm i
- name: Bootstrap
run: npm run bootstrap
- name: Build
run: npm run build
- name: Tests
run: npm run lerna run test --stream --parallel -- -- --coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1

View File

@@ -1,37 +0,0 @@
name: typecheck
on:
push:
branches:
- '**'
pull_request:
jobs:
typecheck:
runs-on: ubuntu-latest
env:
NODE_OPTIONS: --max-old-space-size=4096
steps:
- uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v2
with:
node-version: 16
- name: Restore lerna cache
uses: actions/cache@v2
with:
path: |
node_modules
packages/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm i
- name: Bootstrap
run: npm run bootstrap
- name: Typecheck
run: npm run typecheck

45
.github/workflows/version.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
name: version
on:
push:
branches:
- master
tags-ignore:
- "**"
workflow_dispatch:
jobs:
pre_run:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@ad6cb1b847ffb509a69b745b6ee2f1d14dfe14b8
with:
access_token: ${{ github.token }}
publish_beta:
runs-on: ubuntu-latest
needs: pre_run
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# pulls all tags (needed for lerna to correctly version)
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- run: npm ci
- run: npm run bootstrap
- name: Create Release Pull Request
uses: changesets/action@v1
with:
version: git tag -d `git tag | grep -E 'beta'` && npx lerna version --conventional-commits --no-push --no-git-tag-version --yes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}