Skip to content

Commit a4b8eb7

Browse files
committed
Added a new step to automatically create a github release on tag.
1 parent 3bbc3c0 commit a4b8eb7

File tree

1 file changed

+89
-1
lines changed

1 file changed

+89
-1
lines changed

.github/workflows/dataminer-cicd-automation.yml

+89-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,95 @@ jobs:
2828
# The API-key: generated in the DCP Admin app (https://admin.dataminer.services/) as authentication for a certain DataMiner System.
2929
api-key: ${{ secrets.DATAMINER_DEPLOY_KEY }}
3030
sonarCloudToken: ${{ secrets.SONAR_TOKEN }}
31-
31+
32+
Release:
33+
if: github.ref_type == 'tag'
34+
runs-on: ubuntu-latest
35+
needs: CI
36+
permissions:
37+
contents: write
38+
steps:
39+
- name: Checkout Code
40+
uses: actions/checkout@v4
41+
42+
- name: Check Release
43+
id: release_check
44+
run: |
45+
REF_NAME="${{ github.ref_name }}"
46+
RELEASE_REGEX="^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$"
47+
PRE_RELEASE_REGEX="^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+-[0-9a-zA-Z]+$"
48+
if [[ $REF_NAME =~ $RELEASE_REGEX ]]
49+
then
50+
echo "prerelease=false" >> $GITHUB_OUTPUT
51+
echo "Release"
52+
exit 0
53+
elif [[ $REF_NAME =~ $PRE_RELEASE_REGEX ]]
54+
then
55+
echo "prerelease=true" >> $GITHUB_OUTPUT
56+
echo "Pre-Release"
57+
exit 0
58+
else
59+
echo "Tag is in the incorrect format. Should be 0.0.0.0 for a release or 0.0.0.0-someprereleasetag for a pre-release."
60+
exit 1
61+
fi
62+
63+
- name: Check Changelog
64+
id: changelog_check
65+
if: steps.release_check.outputs.prerelease == 'false'
66+
run: |
67+
FILE=./Documentation/CHANGELOG_${{ github.ref_name }}.md
68+
echo "$FILE"
69+
if [ -f "$FILE" ]
70+
then
71+
echo "changelog_exists=true" >> $GITHUB_OUTPUT
72+
echo "changelog_file=$FILE" >> $GITHUB_OUTPUT
73+
exit 0
74+
else
75+
echo "There is no changelog found for tag $FILE. Please add a CHANGELOG_$FILE.md file with the changes for this version in the Documentation folder."
76+
exit 1
77+
fi
78+
79+
- name: Retrieve Installation Package
80+
id: retrieveInstallationPackage
81+
uses: actions/download-artifact@v4
82+
with:
83+
name: DataMiner Installation Package
84+
path: _DataMinerInstallationPackage
85+
86+
- name: Find Installation Package
87+
id: findInstallationPackage
88+
run: |
89+
path=$(find _DataMinerInstallationPackage -type f -name '*.dmapp')
90+
echo $path
91+
92+
if [ ! -z "$path" ]
93+
then
94+
newpath="${path%.*}_${{ github.ref_name }}.dmapp"
95+
echo $newpath
96+
mv $path $newpath
97+
echo "dmappPackageName=$newpath" >> $GITHUB_OUTPUT
98+
else
99+
exit 1
100+
echo "dmappPackageName=""" >> $GITHUB_OUTPUT
101+
fi
102+
103+
- name: Logging
104+
run: |
105+
echo ${{ steps.changelog_check.outputs.changelog_exists }}
106+
echo ${{ steps.changelog_check.outputs.changelog_file }}
107+
echo ${{ steps.release_check.outputs.prerelease }}
108+
echo ${{ steps.findInstallationPackage.outputs.dmappPackageName }}
109+
110+
- name: Create Release
111+
uses: ncipollo/release-action@v1
112+
with:
113+
name: ${{ github.ref_name }}
114+
bodyFile: ${{ steps.changelog_check.outputs.changelog_file }}
115+
draft: false
116+
prerelease: ${{ steps.release_check.outputs.prerelease == 'true' }}
117+
allowUpdates: true
118+
artifacts: ${{ steps.findInstallationPackage.outputs.dmappPackageName }}
119+
32120
# # Optional 0 or More CD Jobs as needed
33121
# CD:
34122
# if: github.ref_type == 'tag'

0 commit comments

Comments
 (0)