11name : Publish to NPM
22
33on :
4- release :
5- types : [published]
6- push :
7- branches :
8- - graph_workspace
9- tags :
10- -
' @gravity-ui/[email protected] *' 11- -
' @gravity-ui/[email protected] *' 4+ workflow_dispatch :
5+ inputs :
6+ release_tag :
7+ description :
' Release tag to publish (e.g., @gravity-ui/[email protected] )' 8+ required : true
9+ type : string
10+ target_branch :
11+ description : ' Target branch for the release'
12+ required : false
13+ default : ' graph_workspace'
14+ type : string
1215
1316jobs :
1417 publish :
@@ -25,33 +28,37 @@ jobs:
2528
2629 - run : npm run build
2730
28- - name : Determine which package to publish
31+ - name : Check release branch and determine package
2932 id : package
3033 run : |
31- if [ "${{ github.event_name }}" = "release" ]; then
34+ # Определяем источник данных (автоматический релиз или ручной запуск)
35+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
36+ TAG_NAME="${{ github.event.inputs.release_tag }}"
37+ TARGET_COMMITISH="${{ github.event.inputs.target_branch }}"
38+ echo "Manual run - Release tag: $TAG_NAME"
39+ echo "Manual run - Target branch: $TARGET_COMMITISH"
40+ else
3241 TAG_NAME="${{ github.event.release.tag_name }}"
33- echo "Release tag: $TAG_NAME"
34-
35- if [[ "$TAG_NAME" == *"@gravity-ui/graph-react"* ]]; then
36- echo "package=react" >> $GITHUB_OUTPUT
37- elif [[ "$TAG_NAME" == *"@gravity-ui/graph"* ]]; then
38- echo "package=graph" >> $GITHUB_OUTPUT
39- else
40- echo "Unknown package tag format"
41- exit 1
42- fi
43- elif [ "${{ github.event_name }}" = "push" ]; then
44- TAG_NAME="${{ github.ref_name }}"
45- echo "Push tag: $TAG_NAME"
46-
47- if [[ "$TAG_NAME" == *"@gravity-ui/[email protected] "* ]]; then 48- echo "package=react" >> $GITHUB_OUTPUT
49- elif [[ "$TAG_NAME" == *"@gravity-ui/[email protected] "* ]]; then 50- echo "package=graph" >> $GITHUB_OUTPUT
51- else
52- echo "Unknown package tag format"
53- exit 1
54- fi
42+ TARGET_COMMITISH="${{ github.event.release.target_commitish }}"
43+ echo "Automatic release - Release tag: $TAG_NAME"
44+ echo "Automatic release - Target commitish: $TARGET_COMMITISH"
45+ fi
46+
47+ # Проверяем, что релиз создан из ветки graph_workspace
48+ if [[ "$TARGET_COMMITISH" != "graph_workspace" ]]; then
49+ echo "Release is not from graph_workspace branch (target: $TARGET_COMMITISH), skipping publish"
50+ echo "package=skip" >> $GITHUB_OUTPUT
51+ exit 0
52+ fi
53+
54+ # Определяем пакет по тегу
55+ if [[ "$TAG_NAME" == *"@gravity-ui/graph-react"* ]]; then
56+ echo "package=react" >> $GITHUB_OUTPUT
57+ elif [[ "$TAG_NAME" == *"@gravity-ui/graph"* ]]; then
58+ echo "package=graph" >> $GITHUB_OUTPUT
59+ else
60+ echo "Unknown package tag format: $TAG_NAME"
61+ exit 1
5562 fi
5663
5764 - name : Publish @gravity-ui/graph
0 commit comments