Release #140
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: Setup dependencies | |
| uses: ./.github/actions/setup-dependencies | |
| with: | |
| node-version: '24.x' | |
| - name: Configure Git | |
| run: | | |
| git config --global user.email "integration@retailcrm.ru" | |
| git config --global user.name "RetailCRM.CI" | |
| - 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 coverage | |
| run: yarn test:coverage | |
| - name: Run typecheck tests | |
| run: yarn vitest run -c packages/v1-contexts/vitest.config.ts --typecheck.only --typecheck.checker tsc --typecheck.tsconfig packages/v1-contexts/tsconfig.json | |
| - name: Run release [${{ inputs.prerelease }}] | |
| if: ${{ inputs.prerelease != 'none' }} | |
| run: npx tsx scripts/release.ts -p ${{ inputs.prerelease }} | |
| - name: Ensure stable release is running from master | |
| if: ${{ inputs.prerelease == 'none' }} | |
| run: | | |
| if [ "${{ github.ref_name }}" != "master" ]; then | |
| echo "Stable release is allowed only from master. Current ref: ${{ github.ref_name }}" | |
| exit 1 | |
| fi | |
| - name: Run release | |
| if: ${{ inputs.prerelease == 'none' }} | |
| run: | | |
| echo "YARN_ENABLE_IMMUTABLE_INSTALLS=false" >> "$GITHUB_ENV" | |
| npx tsx scripts/release.ts | |
| - name: Push current branch with tags | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: git push --follow-tags origin HEAD:${{ github.ref_name }} | |
| - 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: Setup dependencies | |
| uses: ./.github/actions/setup-dependencies | |
| with: | |
| node-version: '24.x' | |
| - 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@v4 | |
| 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 "integration@retailcrm.ru" | |
| 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 |