diff --git a/.github/workflows/release-preview-publish.yml b/.github/workflows/release-preview-publish.yml new file mode 100644 index 000000000..552452e80 --- /dev/null +++ b/.github/workflows/release-preview-publish.yml @@ -0,0 +1,40 @@ +name: Publish release preview package + +on: + push: + branches: + - 'release/**' + +jobs: + publish: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [10.x] + steps: + - uses: actions/checkout@v1 + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Install Yarn + run: npm i yarn --global + + - name: Install Json + run: npm i json --global + + - name: Install Packages + run: yarn install + + - name: Publish + run: | + PREVIEW_VERSION=$(git rev-list --count --first-parent HEAD) + VERSION=$(echo ${{github.ref}} | tail -c +20)-preview.$PREVIEW_VERSION + echo $VERSION + npm version --no-git-tag-version --allow-same-version $VERSION + npm set //npm.pkg.github.com/:_authToken ${{ secrets.GITHUB_TOKEN }} + npm set registry https://npm.pkg.github.com/knsv + json -I -f package.json -e 'this.name="@knsv/mermaid"' # Package name needs to be set to a scoped one because GitHub registry requires this + json -I -f package.json -e 'this.repository="git://github.com/knsv/mermaid"' # Repo url needs to have a specific format too + npm publish + diff --git a/README.md b/README.md index b7372ce37..0d3e6c394 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,20 @@ Example: https://unpkg.com/mermaid@7.1.0/dist/ yarn add mermaid +### Preview builds +Preview builds are created automatically for each release. They can be found in the [GitHub registry](https://github.com/knsv/mermaid/packages). +Make sure to configure npm to use the GitHub package registry. Steps for that can be found [here](https://help.github.com/en/articles/configuring-npm-for-use-with-github-package-registry). + +If you want to get the latest preview for the next release +``` +yarn add @knsv/mermaid +``` + + +If you want to get the latest preview for a specific version +``` +yarn add @knsv/mermaid@ +``` ## Documentation