Skip to content

Publish to npm

Publish to npm #18

Workflow file for this run

name: Publish to npm
on:
workflow_dispatch:
inputs:
next:
description: Is it a dev / next release ?
required: true
type: boolean
version:
description: The version of the release, if needed (x.y.z-p)
required: false
type: string
jobs:
build:
env:
branch: ${{ inputs.next == true && 'Development' || 'main' }}
stage: ${{ inputs.next == true && 'next' || 'latest' }}
build: ${{ inputs.next == true && 'next' || 'production' }}
version: ${{ inputs.next == true && 'patch' || 'minor' }}
ELECTRON_EXTRA_LAUNCH_ARGS: '--disable-gpu'
runs-on: ubuntu-latest
strategy:
matrix:
browser: [chromium]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ env.branch }}
token: ${{secrets.DONTCODE_ACTIONS_TOKEN}}
- name: Git config user
uses: snow-actions/git-config-user@v1.0.0
with:
name: Dont-code
email: developer@dont-code.net
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- name: Set libs & plugins versions
if: ${{ ( matrix.browser == 'chromium' ) && ( inputs.version != '') }}
run: |
PACKAGE_VERSION=${{inputs.version}}
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
cd libs/xt-type
npm version $PACKAGE_VERSION --allow-same-version
cd ../xt-store
npm version $PACKAGE_VERSION --allow-same-version
cd projects/store
npm version $PACKAGE_VERSION --allow-same-version
cd ../../../xt-components
npm version $PACKAGE_VERSION --allow-same-version
cd projects/xt-components
npm version $PACKAGE_VERSION --allow-same-version
cd ../../../xt-plugin-sample
npm version $PACKAGE_VERSION --allow-same-version
cd projects/sample
npm version $PACKAGE_VERSION --allow-same-version
cd ../../../../plugins/xt-web
npm version $PACKAGE_VERSION --allow-same-version
cd projects/web
npm version $PACKAGE_VERSION --allow-same-version
cd ../../../../plugins/xt-idb-store
npm version $PACKAGE_VERSION --allow-same-version
cd projects/idb-store
npm version $PACKAGE_VERSION --allow-same-version
cd ../../../xt-default
npm version $PACKAGE_VERSION --allow-same-version
cd projects/default
npm version $PACKAGE_VERSION --allow-same-version
- name: Increase xt-type version
if: ${{ ( matrix.browser == 'chromium' ) && ( inputs.version == '') }}
run: |
PACKAGE_VERSION=$(npm view xt-type versions --json | jq -r '.[-1]')
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
npm version $PACKAGE_VERSION --allow-same-version
npm version ${{env.version}}
working-directory: 'libs/xt-type'
- name: Increase xt-store version
if: ${{ ( matrix.browser == 'chromium' ) && ( inputs.version == '') }}
run: |
PACKAGE_VERSION=$(npm view xt-store versions --json | jq -r '.[-1]')
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
npm version $PACKAGE_VERSION --allow-same-version
npm version ${{env.version}}
working-directory: 'libs/xt-store'
- name: Increase xt-components version
if: ${{ ( matrix.browser == 'chromium' ) && ( inputs.version == '') }}
run: |
PACKAGE_VERSION=$(npm view xt-components versions --json | jq -r '.[-1]')
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
npm version $PACKAGE_VERSION --allow-same-version
npm version ${{env.version}}
working-directory: 'libs/xt-components'
- name: Increase xt-idb-store version
if: ${{ ( matrix.browser == 'chromium' ) && ( inputs.version == '') }}
run: |
PACKAGE_VERSION=$(npm view xt-idb-store versions --json | jq -r '.[-1]')
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
npm version $PACKAGE_VERSION --allow-same-version
npm version ${{env.version}}
working-directory: 'plugins/xt-idb-store'
- name: Increase xt-plugin-sample version
if: ${{ ( matrix.browser == 'chromium' ) && ( inputs.version == '') }}
run: |
PACKAGE_VERSION=$(npm view xt-plugin-sample versions --json | jq -r '.[-1]')
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
npm version $PACKAGE_VERSION --allow-same-version
npm version ${{env.version}}
cd projects/sample
npm version $PACKAGE_VERSION --allow-same-version
npm version ${{env.version}}
working-directory: 'libs/xt-plugin-sample'
- name: Increase xt-plugin-default version
if: ${{ ( matrix.browser == 'chromium' ) && ( inputs.version == '') }}
run: |
PACKAGE_VERSION=$(npm view xt-plugin-default versions --json | jq -r '.[-1]')
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
npm version $PACKAGE_VERSION --allow-same-version
npm version ${{env.version}}
cd projects/default
npm version $PACKAGE_VERSION --allow-same-version
npm version ${{env.version}}
working-directory: 'plugins/xt-default'
- name: Increase xt-plugin-web version
if: ${{ ( matrix.browser == 'chromium' ) && ( inputs.version == '') }}
run: |
PACKAGE_VERSION=$(npm view xt-plugin-web versions --json | jq -r '.[-1]')
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
npm version $PACKAGE_VERSION --allow-same-version
npm version ${{env.version}}
cd projects/web
npm version $PACKAGE_VERSION --allow-same-version
npm version ${{env.version}}
working-directory: 'plugins/xt-web'
- name: Install
run: |
node common/scripts/install-run-rush.js install
- name: Build
run: |
node common/scripts/install-run-rush.js build-deploy-${{env.stage}}
- name: Publish libraries to ${{env.stage}}
if: ${{ success() && ( matrix.browser == 'chromium' ) }}
run: |
npm publish libs/xt-store/dist/store --access public --tag ${{env.stage}}
npm publish libs/xt-components/dist/xt-components --access public --tag ${{env.stage}}
npm publish libs/xt-plugin-sample/dist/xt-plugin-sample --access public --tag ${{env.stage}}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish plugins to ${{env.stage}}
if: ${{ success() && ( matrix.browser == 'chromium' ) }}
run: |
npm publish plugins/xt-idb-store/dist/store --access public --tag ${{env.stage}}
npm publish plugins/xt-default/dist/xt-plugin-default --access public --tag ${{env.stage}}
npm publish plugins/xt-web/dist/xt-plugin-web --access public --tag ${{env.stage}}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}