Skip to content

Commit

Permalink
fix(docs): v2 install command
Browse files Browse the repository at this point in the history
  • Loading branch information
snorrees committed Nov 22, 2022
1 parent 4291125 commit d3f650d
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 22 deletions.
123 changes: 103 additions & 20 deletions .github/workflows/main.yml
@@ -1,37 +1,111 @@
---
name: CI & Release

# Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
run-name: >-
${{
inputs.release && inputs.test && format('Build {0} ➤ Test ➤ Publish to NPM', github.ref_name) ||
inputs.release && !inputs.test && format('Build {0} ➤ Skip Tests ➤ Publish to NPM', github.ref_name) ||
github.event_name == 'workflow_dispatch' && inputs.test && format('Build {0} ➤ Test', github.ref_name) ||
github.event_name == 'workflow_dispatch' && !inputs.test && format('Build {0} ➤ Skip Tests', github.ref_name) ||
''
}}
on:
# Build on pushes branches that have a PR (including drafts)
pull_request:
# Build on commits pushed to branches without a PR if it's in the allowlist
push:
branches: [main,studio-v2]
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
workflow_dispatch:
inputs:
test:
description: Run tests
required: true
default: true
type: boolean
release:
description: 'Release new version'
description: Release new version
required: true
default: false
type: boolean

concurrency:
# On PRs builds will cancel if new pushes happen before the CI completes, as it defines `github.head_ref` and gives it the name of the branch the PR wants to merge into
# Otherwise `github.run_id` ensures that you can quickly merge a queue of PRs without causing tests to auto cancel on any of the commits pushed to main.
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
test:
runs-on: ${{ matrix.platform }}
name: Node.js ${{ matrix.node-version }} / ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest]
node-version: [lts/*, current]
log-the-inputs:
name: Log inputs
runs-on: ubuntu-latest
steps:
- run: |
echo "Inputs: $INPUTS"
env:
INPUTS: ${{ toJSON(inputs) }}
build:
runs-on: ubuntu-latest
name: Lint & Build
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run lint
- run: npm run build
- run: npm test
cache: npm
node-version: lts/*
- run: npm ci
# Linting can be skipped
- run: npm run lint --if-present
if: github.event.inputs.test != 'false'
# But not the build script, as semantic-release will crash if this command fails so it makes sense to test it early
- run: npm run prepublishOnly --if-present

# test:
# needs: build
# # The test matrix can be skipped, in case a new release needs to be fast-tracked and tests are already passing on main
# if: github.event.inputs.test != 'false'
# runs-on: ${{ matrix.os }}
# name: Node.js ${{ matrix.node }} / ${{ matrix.os }}
# strategy:
# # A test failing on windows doesn't mean it'll fail on macos. It's useful to let all tests run to its completion to get the full picture
# fail-fast: false
# matrix:
# # Run the testing suite on each major OS with the latest LTS release of Node.js
# os: [macos-latest, ubuntu-latest, windows-latest]
# node: [lts/*]
# # It makes sense to also test the oldest, and latest, versions of Node.js, on ubuntu-only since it's the fastest CI runner
# include:
# - os: ubuntu-latest
# # Test the oldest LTS release of Node that's still receiving bugfixes and security patches, versions older than that have reached End-of-Life
# node: lts/-2
# - os: ubuntu-latest
# # Test the actively developed version that will become the latest LTS release next October
# node: current
# steps:
# # It's only necessary to do this for windows, as mac and ubuntu are sane OS's that already use LF
# - name: Set git to use LF
# if: matrix.os == 'windows-latest'
# run: |
# git config --global core.autocrlf false
# git config --global core.eol lf
# - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
# - uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
# with:
# cache: npm
# node-version: ${{ matrix.node }}
# - run: npm i
# - run: npm test --if-present

release:
name: 'Semantic release'
needs: test
# needs: [build, test]
needs: [build]
# only run if opt-in during workflow_dispatch
if: always() && github.event.inputs.release == 'true' && needs.build.result != 'failure' && needs.test.result != 'failure' && needs.test.result != 'cancelled'
runs-on: ubuntu-latest
if: inputs.release == true
name: Semantic release
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
with:
Expand All @@ -40,11 +114,20 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
with:
cache: npm
node-version: lts/*
cache: 'npm'
- run: npm install
# Branches that will release new versions are defined in .releaserc.json
- run: npm ci
# Branches that will release new versions are defined in .releaserc.json
- run: npx semantic-release
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
# e.g. git tags were pushed but it exited before `npm publish`
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
# Re-run semantic release with rich logs if it failed to publish for easier debugging
- run: npx semantic-release --dry-run --debug
if: failure()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
2 changes: 1 addition & 1 deletion .npmrc
@@ -1 +1 @@
legacy-peer-deps=true
legacy-peer-deps=true
2 changes: 1 addition & 1 deletion .releaserc.json
@@ -1,4 +1,4 @@
{
"extends": "@sanity/semantic-release-preset",
"branches": ["main", { "name": "studio-v2", "channel": "studio-v2", "range": "0.x.x" }]
"branches": ["main", { "name": "studio-v2", "channel": "studio-v2", "range": "0.2.x" }]
}
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -8,6 +8,17 @@ Search for photos on Unsplash and add them to your project right inside Sanity S

`sanity install asset-source-unsplash@studio-v2`

```sh
yarn add sanity-plugin-asset-source-unsplash@studio-v2
```

Next, add `"asset-source-unsplash"` to `sanity.json` plugins array:
```json
"plugins": [
"asset-source-unsplash"
]
```

## Part name

If you need to do customize available asset sources, the plugin part name for this asset source is:
Expand Down

0 comments on commit d3f650d

Please sign in to comment.