Skip to content

Release

Release #68

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
prerelease:
type: choice
options:
- 'alpha'
- 'beta'
- 'rc'
- 'none'
description: Prerelease type
default: 'none'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Yarn configuration
run: make .yarnrc.yml
- name: Configure Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "RetailCRM.CI"
- name: Install dependencies
run: yarn install
- name: Build worktree
run: yarn workspaces foreach -A --topological-dev run build
- name: Run eslint
run: yarn eslint
- name: Run tests
run: yarn test
- name: Run release [${{ inputs.prerelease }}]
if: ${{ inputs.prerelease != 'none' }}
run: yes | npx tsx scripts/release.ts -p ${{ inputs.prerelease }}
- name: Run release
if: ${{ inputs.prerelease == 'none' }}
run: |
echo "YARN_ENABLE_IMMUTABLE_INSTALLS=false" >> $GITHUB_ENV
yes | npx tsx scripts/release.ts
- name: Push tags to repository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: git push --follow-tags origin master
- name: Create .npmrc
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Publish to npm
run: yes | npx tsx scripts/publish.ts
- name: Extract version from package.json
id: version
run: |
VERSION=$(grep -oP '"version":\s*"\K[^"]+' package.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "${VERSION}"
outputs:
version: ${{ steps.version.outputs.version }}
storybook:
runs-on: ubuntu-latest
needs: release
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Yarn configuration
run: make .yarnrc.yml
- name: Install dependencies
run: yarn install
- name: Build Storybook
run: yarn workspace @retailcrm/embed-ui-v1-components run storybook:build
- name: Upload Storybook artifact
uses: actions/upload-artifact@v4
with:
name: v1-components-storybook
path: packages/v1-components/storybook/dist
- name: Push version forward
id: version
run: echo "version=${{ needs.release.outputs.version }}" >> $GITHUB_OUTPUT
outputs:
version: ${{ steps.version.outputs.version }}
deploy:
runs-on: ubuntu-latest
needs: storybook
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Storybook artifact
uses: actions/download-artifact@v4
with:
name: v1-components-storybook
path: packages/v1-components/storybook/dist
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: packages/v1-components/storybook/dist
publish_branch: gh-pages
destination_dir: v1-components/${{ needs.storybook.outputs.version }}
- name: Clone gh-pages branch
run: |
git clone --branch=gh-pages https://github.com/${{ github.repository }} gh-pages
cd gh-pages
rm -rf v1-components/latest
cp -r v1-components/${{ needs.storybook.outputs.version }} v1-components/latest
git config --global user.email "[email protected]"
git config --global user.name "RetailCRM.CI"
git add .
git commit -m "Update latest symlink to ${{ needs.storybook.outputs.version }}"
- name: Push changes
run: |
cd gh-pages
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git push origin gh-pages