Skip to content

Commit afebfa0

Browse files
SK-1820 refactor release pipeline
1 parent 35ba49f commit afebfa0

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

.github/workflows/shared-build-and-deploy.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ jobs:
6161
server-password: SERVER_PASSWORD
6262
gpg-private-key: ${{ secrets.gpg-key }} # Value of the GPG private key to import
6363
gpg-passphrase: GPG_PASSPHRASE # env variable for GPG private key passphrase
64+
65+
- name: Resolve Branch for the Tagged Commit
66+
id: resolve-branch
67+
if: ${{ inputs.tag == 'beta' || inputs.tag == 'public' }}
68+
run: |
69+
TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref_name }})
70+
BRANCH_NAME=$(git branch -r --contains $TAG_COMMIT | grep -o 'origin/.*' | sed 's|origin/||' | head -n 1)
71+
if [ -z "$BRANCH_NAME" ]; then
72+
echo "Error: Could not resolve branch for the tag."
73+
exit 1
74+
fi
75+
echo "Resolved Branch Name: $BRANCH_NAME"
76+
echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV
6477
6578
- name: Get Previous tag
6679
id: previoustag
@@ -78,22 +91,25 @@ jobs:
7891
fi
7992
8093
- name: Commit changes
81-
if: ${{ inputs.tag == 'internal' || inputs.tag == 'public' }}
8294
run: |
8395
git config user.name ${{ github.actor }}
8496
git config user.email ${{ github.actor }}@users.noreply.github.com
97+
98+
if [[ "${{ inputs.tag }}" == "beta" || "${{ inputs.tag }}" == "public" ]]; then
99+
git checkout ${{ env.branch_name }}
100+
fi
101+
85102
git add pom.xml
86-
if ${{ inputs.tag == 'internal' }}; then
103+
if [[ "${{ inputs.tag }}" == "internal" ]]; then
87104
git commit -m "[AUTOMATED] Private Release ${{ steps.previoustag.outputs.tag }}-dev-$(git rev-parse --short $GITHUB_SHA)"
88105
git push origin ${{ github.ref_name }} -f
89106
fi
90-
if ${{ inputs.tag == 'public' }}; then
107+
if [[ "${{ inputs.tag }}" == "beta" || "${{ inputs.tag }}" == "public" ]]; then
91108
git commit -m "[AUTOMATED] Public Release - ${{ steps.previoustag.outputs.tag }}"
92-
git push origin
109+
git push origin ${{ env.branch_name }}
93110
fi
94111
95112
- name: Create env
96-
if: ${{ inputs.tag == 'internal' }}
97113
id: create-env
98114
run: |
99115
touch .env
@@ -109,7 +125,7 @@ jobs:
109125
json: ${{ secrets.TEST_CREDENTIALS_FILE_STRING }}
110126

111127
- name: Publish package
112-
run: mvn clean deploy -P ${{ inputs.profile }}
128+
run: mvn --batch-mode deploy -P ${{ inputs.profile }}
113129
env:
114130
SERVER_USERNAME: ${{ secrets.server-username }}
115131
SERVER_PASSWORD: ${{ secrets.server-password }}

0 commit comments

Comments
 (0)