Skip to content

Virto-shell CI

Virto-shell CI #923

Workflow file for this run

# v2.2.0
name: Virto-shell CI
on:
workflow_dispatch:
push:
branches: [ main, feat/virto-oz ]
# Only on commits with package changes or release commits
paths:
- 'framework/**'
- 'cli/**'
- 'configs/**'
- '**/package.json'
- '**/CHANGELOG.md'
release:
types: [published]
jobs:
CI:
runs-on: ubuntu-latest
# Only runs on release commits, releases, or manual dispatch
if: |
github.event_name == 'release' ||
github.event_name == 'workflow_dispatch' ||
contains(github.event.head_commit.message, 'release:') ||
contains(github.event.head_commit.message, 'chore: release')
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
GITHUB_USER: '${{ github.repository_owner }}'
VERSION_SUFFIX: ''
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TAG: 'latest'
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to GitHub Packages
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
cache-dependency-path: 'yarn.lock'
always-auth: true
- name: Set GITHUB_USER to lowercase
run: |
echo "GITHUB_USER=${GITHUB_USER,,}" >> $GITHUB_ENV
- name: Install dependencies
run: |
yarn install
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
- name: Get Image Version
uses: VirtoCommerce/vc-github-actions/get-image-version@master
id: image
with:
projectType: theme
- name: Set release variables
if: ${{ github.ref == 'refs/heads/main' }}
run: |
echo "VERSION_SUFFIX=${{ steps.image.outputs.prefix }}" >> $GITHUB_ENV
- name: Set release-alpha variables
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "VERSION_SUFFIX=${{ steps.image.outputs.fullVersion }}" >> $GITHUB_ENV
- name: Set PR variables
if: ${{ github.event_name == 'pull_request' }}
run: |
echo "VERSION_SUFFIX=${{ steps.image.outputs.taggedVersion }}" >> $GITHUB_ENV
- name: Build virto-shell
run: |
yarn build
- name: Configure npm
if: success()
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Determine npm tag
if: success()
run: |
VERSION=$(node -p "require('./framework/package.json').version")
NPM_TAG=$(node -e "const m='$VERSION'.match(/-(alpha|beta|rc|next)/); console.log(m?m[1]:'latest')")
echo "Version: $VERSION → npm tag: $NPM_TAG"
echo "NPM_TAG=$NPM_TAG" >> $GITHUB_ENV
- name: Publish packages to npm
if: success()
run: |
yarn publish:packages --tag "$NPM_TAG"
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Verify npm dist tags
if: success()
run: |
echo "Verifying npm dist tags..."
echo "Published packages with tag: $NPM_TAG"
# Show current tags for verification
PACKAGES=(
"@vc-shell/framework"
"@vc-shell/ts-config"
"@vc-shell/create-vc-app"
"@vc-shell/config-generator"
"@vc-shell/api-client-generator"
)
for PACKAGE in "${PACKAGES[@]}"; do
echo "Tags for $PACKAGE:"
npm dist-tag ls "$PACKAGE" 2>/dev/null || echo "Package not found in npm"
echo "---"
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Storybook:
needs: 'CI'
uses: VirtoCommerce/vc-shell/.github/workflows/storybook-ci.yml@main
with:
event_name: ${{ github.event_name }}
secrets:
VCMP_PLATFORM_TOKEN: ${{ secrets.VCMP_PLATFORM_TOKEN }}