30
30
TAG_VERSION=${GITHUB_REF#refs/tags/v}
31
31
echo "version=$TAG_VERSION" >> $GITHUB_OUTPUT
32
32
33
- - name : Determine source branch
34
- id : branch
35
- run : |
36
- TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref }})
37
- git fetch --all
38
- SOURCE_BRANCH=$(git branch -r --contains $TAG_COMMIT | sed -E 's|^.*origin/([^ ]+).*$|\1|' | head -1)
39
-
40
- if [ -z "$SOURCE_BRANCH" ]; then
41
- echo "Error: Could not determine source branch for tag ${{ github.ref }}"
42
- exit 1
43
- fi
44
- echo "Source branch: $SOURCE_BRANCH"
45
- echo "source_branch=$SOURCE_BRANCH" >> $GITHUB_OUTPUT
46
-
47
33
- name : Check if version needs to be updated
48
34
id : check_version
49
35
run : |
@@ -64,14 +50,14 @@ jobs:
64
50
npm version ${{ steps.version.outputs.version }} --no-git-tag-version
65
51
git config --global user.name "GitHub Actions"
66
52
git config --global user.email "[email protected] "
67
- git fetch origin ${{ steps.branch.outputs.source_branch }}
68
- git pull origin ${{ steps.branch.outputs.source_branch }} --rebase
53
+ git fetch origin ${{ github.ref_name }}
54
+ git pull origin ${{ github.ref_name }} --rebase
69
55
git add package.json package-lock.json
70
56
git commit -m "Bump version to ${{ steps.version.outputs.version }} [skip ci]"
71
- git push origin HEAD:${{ steps.branch.outputs.source_branch }}
57
+ git push origin HEAD:${{ github.ref_name }}
72
58
73
59
- name : Rename tag for develop branch
74
- if : steps.branch.outputs.source_branch == 'develop'
60
+ if : github.ref_name == 'develop'
75
61
run : |
76
62
TIMESTAMP=$(date -u +"%Y%m%d%H%M%S")
77
63
NEW_TAG="v${{ steps.version.outputs.version }}-dev$TIMESTAMP"
@@ -123,8 +109,8 @@ jobs:
123
109
runs-on : ubuntu-latest
124
110
needs : [build]
125
111
if : |
126
- needs.version.outputs.source_branch == 'master' ||
127
- needs.version.outputs.source_branch == 'develop'
112
+ github.ref_name == 'master' ||
113
+ github.ref_name == 'develop'
128
114
129
115
steps :
130
116
- name : Download package files
@@ -153,7 +139,7 @@ jobs:
153
139
154
140
- name : Publish to npm
155
141
run : |
156
- if [ "${{ needs.version.outputs.source_branch }}" == "develop" ]; then
142
+ if [ "${{ github.ref_name }}" == "develop" ]; then
157
143
npm publish --tag dev
158
144
else
159
145
npm publish
0 commit comments