Skip to content

Commit beb6548

Browse files
committed
refactor: use a GitHub actions and a more permissive regex
1 parent 6a2ad8b commit beb6548

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

.github/workflows/merge-release-tag.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Merge Release Tag
33
on:
44
push:
55
tags:
6-
- 'mongosh@[0-9]+.[0-9]+.[0-9]+'
6+
- 'mongosh@[0-9]+.[0-9]+.*'
77
workflow_dispatch:
88

99
jobs:
@@ -24,31 +24,31 @@ jobs:
2424
token: ${{ steps.app-token.outputs.token }}
2525

2626
- name: Extract version from tag
27-
id: version
28-
run: echo "RELEASE_VERSION=$(echo ${GITHUB_REF} | sed -n 's/refs\/tags\/mongosh@\([0-9]\+\.[0-9]\+\.[0-9]\+\)/\1/p')" >> $GITHUB_ENV
27+
uses: actions-ecosystem/action-regex-match@d50fd2e7a37d0e617aea3d7ada663bd56862b9cc
28+
id: version-match
29+
with:
30+
text: ${{ github.ref }}
31+
regex: 'refs/tags/mongosh@([0-9]+\.[0-9]+\.*)'
2932

3033
- name: Validate release version
3134
shell: bash
35+
id: validate
3236
run: |
33-
if [ -z "${RELEASE_VERSION}" ]; then
34-
echo "RELEASE_TAG is not set or is empty"
37+
if [[ -z "${{ steps.version-match.outputs.group1 }}" ]]; then
38+
echo "Error: Could not extract version from tag"
3539
exit 1
3640
fi
3741
38-
if git rev-parse "release/v$RELEASE_VERSION" >/dev/null 2>&1; then
42+
if git rev-parse "release/v${{ steps.version-match.outputs.group1 }}" >/dev/null 2>&1; then
3943
echo "Error: Branch release/v$RELEASE_TAG already exists"
4044
echo "If this version has already been released consider using a different one."
4145
exit 1
4246
fi
47+
echo "::set-output name=version::${{ steps.version-match.outputs.group1 }}"
4348
44-
- name: Create and push branch from tag
45-
run: |
46-
git checkout -b release/v$RELEASE_VERSION ${{ github.ref }}
47-
git push origin release/v$RELEASE_VERSION
48-
49-
- name: Merge branch into main
49+
- name: Merge release tag into main
5050
run: |
51+
git checkout -b release/v${{ steps.validate.outputs.version }} ${{ github.ref }}
5152
git checkout main
52-
git merge release/v$RELEASE_VERSION
53+
git merge release/v${{ steps.validate.outputs.version }}
5354
git push origin main
54-
git push -d origin release/v$RELEASE_VERSION

0 commit comments

Comments
 (0)