Skip to content

Commit

Permalink
chore: setup changesets and release workflow (#91)
Browse files Browse the repository at this point in the history
* chore: setup changesets and release workflow

* docs: update readmes

* chore(ci): use yarn cache
  • Loading branch information
emmenko authored Aug 11, 2021
1 parent 09d4ea0 commit 2bc967a
Show file tree
Hide file tree
Showing 14 changed files with 11,226 additions and 26 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
13 changes: 13 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": [
"@changesets/changelog-github",
{
"repo": "commercetools/commercetools-sdk-typescript"
}
],
"commit": false,
"linked": [["@commercetools/*"]],
"access": "restricted",
"baseBranch": "master"
}
8 changes: 8 additions & 0 deletions .changeset/grumpy-coins-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@commercetools/history-sdk': patch
'@commercetools/importapi-sdk': patch
'@commercetools/ml-sdk': patch
'@commercetools/platform-sdk': patch
---

Update readme structure.
32 changes: 25 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
aliases:
- &ml_ts_sdk ~/commercetools-typescript-sdk
- &ml_ts_sdk ~/commercetools-typescript-sdk

version: 2.1
- &restore_yarn_cache
name: 'Restoring yarn cache'
keys:
- v1-yarn-cache-{{ checksum "yarn.lock" }}

- &save_yarn_cache
name: 'Saving yarn cache'
key: v1-yarn-cache-{{ checksum "yarn.lock" }}
# Persisting to the workspace is always relative to the root which is our working directory.
# https://circleci.com/docs/2.0/configuration-reference/#persist_to_workspace
paths:
- .cache
- node_modules

version: 2.1
jobs:
build_and_test:
working_directory: *ml_ts_sdk
docker:
- image: node:12.22.1
steps:
- checkout
- restore_cache: *restore_yarn_cache
- run:
name: install dependencies
command: yarn install
command: yarn install --frozen-lockfile
- save_cache: *save_yarn_cache
- run:
name: test
command: yarn test
Expand All @@ -21,9 +37,9 @@ jobs:
- store_artifacts:
path: packages/platform-sdk/test-results
prefix: tests
- store_test_results:
- store_test_results:
path: packages/ml-sdk/test-results
- store_test_results:
- store_test_results:
path: packages/platform-sdk/test-results
update_ml_sdk_from_spec:
working_directory: ~/commercetools-typescript-spec
Expand All @@ -43,9 +59,11 @@ jobs:
- run:
name: install rmf cli
command: export VRAP_VERSION=1.0.0-20200304142749 && curl -o- -s https://raw.githubusercontent.com/vrapio/rmf-codegen/master/scripts/install.sh | bash
- restore_cache: *restore_yarn_cache
- run:
name: install yarn
command: yarn install && yarn bootstrap
name: install dependencies
command: yarn install --frozen-lockfile
- save_cache: *save_yarn_cache
workflows:
version: 2
validate_spec:
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Release

on:
push:
branches:
- master

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Pass a personal access token (using our `ct-release-bot` account) to be able to trigger
# other workflows
# https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token
# https://github.community/t/action-does-not-trigger-another-on-push-tag-action/17148/8
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}

- name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm

- name: Setup Node (uses version in .nvmrc)
uses: actions/setup-node@v2
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'

- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Creating .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
[email protected]
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Building packages
run: yarn build

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@master
with:
publish: yarn changeset publish
version: yarn changeset:version-and-format
commit: 'ci(changesets): version packages'
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn.lock*

# Env files
*.env
# Dependencies
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
8 changes: 1 addition & 7 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,5 @@
"packages": ["packages/**"],
"useWorkspaces": true,
"npmclient": "yarn",
"version": "independent",
"command": {
"publish": {
"npmClient": "yarn",
"message": "chore(release): releasing component"
}
}
"version": "independent"
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"name": "root",
"private": true,
"devDependencies": {
"@changesets/changelog-github": "0.4.0",
"@changesets/cli": "2.16.0",
"@commitlint/config-conventional": "8.3.4",
"@lerna/bootstrap": "3.20.0",
"@rollup/plugin-typescript": "3.0.0",
"husky": "4.3.8",
"lerna": "3.20.2",
Expand All @@ -13,12 +14,12 @@
"workspaces": ["packages/*"],
"scripts": {
"generate": "lerna run generate && yarn format",
"bootstrap": "lerna exec yarn install",
"format": "prettier --write '**/*.{js,ts,json,md}'",
"build": "lerna run build",
"test": "lerna run test",
"pre-commit": "lerna run precommit",
"release": "yarn run build && lerna publish --registry=https://registry.npmjs.org/"
"changeset": "changeset",
"changeset:version-and-format": "changeset version && prettier --write --parser json '**/package.json'"
},
"lint-staged": {
"*.{js,ts,json,md}": "yarn format"
Expand Down
4 changes: 2 additions & 2 deletions packages/history-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
npm install --save @commercetools/history-sdk
```

#### Browser
### Browser

```html
<script src="https://unpkg.com/browse/@commercetools/history-sdk/dist/history-sdk.umd.js"></script>
Expand All @@ -15,7 +15,7 @@ npm install --save @commercetools/history-sdk
</script>
```

#### Usage example
### Usage example

```ts
import { createAuthMiddlewareForClientCredentialsFlow } from '@commercetools/sdk-middleware-auth'
Expand Down
4 changes: 2 additions & 2 deletions packages/importapi-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
npm install --save @commercetools/importapi-sdk
```

#### Browser
### Browser

```html
<script src="https://unpkg.com/browse/@commercetools/importapi-sdk/dist/importapi-sdk.umd.js"></script>
Expand All @@ -15,7 +15,7 @@ npm install --save @commercetools/importapi-sdk
</script>
```

#### Usage example
### Usage example

```ts
import { createAuthMiddlewareForClientCredentialsFlow } from '@commercetools/sdk-middleware-auth'
Expand Down
4 changes: 2 additions & 2 deletions packages/ml-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
npm install --save @commercetools/ml-sdk
```

#### Browser
### Browser

```html
<script src="https://unpkg.com/browse/@commercetools/ml-sdk/dist/ml-sdk.umd.js"></script>
Expand All @@ -15,7 +15,7 @@ npm install --save @commercetools/ml-sdk
</script>
```

#### Usage example
### Usage example

```ts
import { createAuthMiddlewareForClientCredentialsFlow } from '@commercetools/sdk-middleware-auth'
Expand Down
4 changes: 2 additions & 2 deletions packages/platform-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
npm install --save @commercetools/platform-sdk
```

#### Browser
### Browser

```html
<script src="https://unpkg.com/@commercetools/platform-sdk/dist/platform-sdk.umd.js"></script>
Expand All @@ -15,7 +15,7 @@ npm install --save @commercetools/platform-sdk
</script>
```

#### Usage example
### Usage example

```ts
import { createAuthMiddlewareForClientCredentialsFlow } from '@commercetools/sdk-middleware-auth'
Expand Down
Loading

0 comments on commit 2bc967a

Please sign in to comment.