-
Notifications
You must be signed in to change notification settings - Fork 3
132 lines (114 loc) · 3.75 KB
/
main.yml
File metadata and controls
132 lines (114 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# 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 }}