Skip to content

Commit 8f83032

Browse files
committed
Update tag name extraction
1 parent b7edbee commit 8f83032

File tree

1 file changed

+7
-28
lines changed

1 file changed

+7
-28
lines changed

.github/workflows/publish.yml

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,65 +14,44 @@ jobs:
1414
- name: Checkout code
1515
uses: actions/checkout@v3
1616

17-
- name: Extract and validate name
18-
id: check_name
19-
run: |
20-
TAG="${GITHUB_REF#refs/tags/}"
21-
NAME="${TAG%%/*}"
22-
echo $NAME
23-
LIBRARY_NAMES=("js-service-client" "js-edge-driver")
24-
found=false
25-
for item in "${LIBRARY_NAMES[@]}"; do
26-
if [[ "$item" == "$NAME" ]]; then
27-
found=true
28-
break
29-
fi
30-
done
31-
if [[ "$found" == true ]]; then
32-
echo "String '$NAME' exists in the array."
33-
echo "name=$NAME" >> $GITHUB_OUTPUT
34-
echo "is_valid=true" >> $GITHUB_OUTPUT
35-
else
36-
echo "String '$NAME' does NOT exist in the array."
37-
echo "is_valid=false" >> $GITHUB_OUTPUT
38-
fi
39-
4017
- name: Extract and validate version
4118
if: steps.check_name.outputs.is_valid == 'true'
4219
id: check_version
4320
run: |
4421
TAG="${GITHUB_REF#refs/tags/}"
45-
PATTERN='^${{ steps.check_name.outputs.name }}\/v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'
22+
NAME="${TAG%%/*}"
23+
PATTERN='^js-[-a-z]*\/v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'
4624
echo "Release tag: $TAG"
4725
if [[ "$TAG" =~ $PATTERN ]]; then
4826
echo "Valid tag format."
4927
echo "is_valid=true" >> $GITHUB_OUTPUT
5028
echo "version=${TAG#${{ steps.check_name.outputs.name }}/v}" >> $GITHUB_OUTPUT
29+
echo "name=${NAME}" >> $GITHUB_OUTPUT
5130
else
5231
echo "Invalid tag format."
5332
echo "is_valid=false" >> $GITHUB_OUTPUT
5433
fi
5534
5635
- name: Set up Node.js
57-
if: steps.check_version.outputs.is_valid == 'true' && steps.check_name.outputs.is_valid == 'true'
36+
if: steps.check_version.outputs.is_valid == 'true' && steps.check_version.outputs.name != null
5837
uses: actions/setup-node@v3
5938
with:
6039
node-version: '16.x'
6140

6241
- name: Install Dependencies
63-
if: steps.check_version.outputs.is_valid == 'true' && steps.check_name.outputs.is_valid == 'true'
42+
if: steps.check_version.outputs.is_valid == 'true' && steps.check_version.outputs.name != null
6443
run: npm install --verbose
6544

6645
- name: Update version in package.json
67-
if: steps.check_version.outputs.is_valid == 'true' && steps.check_name.outputs.is_valid == 'true'
46+
if: steps.check_version.outputs.is_valid == 'true' && steps.check_version.outputs.name != null
6847
run: |
6948
VERSION=${{ steps.check_version.outputs.version }}
7049
echo "Updating version to: $VERSION"
7150
jq ".version = \"$VERSION\"" package.json > package.json.tmp
7251
mv package.json.tmp package.json
7352
7453
- name: Publish to npm
75-
if: steps.check_version.outputs.is_valid == 'true' && steps.check_name.outputs.is_valid == 'true'
54+
if: steps.check_version.outputs.is_valid == 'true' && steps.check_version.outputs.name != null
7655
run: |
7756
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
7857
npm publish --dry-run

0 commit comments

Comments
 (0)