Skip to content

Commit 2c1283b

Browse files
Update release.yml
1 parent fd9f504 commit 2c1283b

File tree

1 file changed

+62
-7
lines changed

1 file changed

+62
-7
lines changed

.github/workflows/release.yml

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
branches:
77
- master
88

9+
# Prevent concurrent builds that might interfere with each other
10+
concurrency:
11+
group: release-${{ github.ref }}
12+
cancel-in-progress: true
13+
914
permissions:
1015
contents: write
1116
pull-requests: write
@@ -43,6 +48,7 @@ jobs:
4348
echo "FILES_CHANGED=true" >> $GITHUB_ENV
4449
else
4550
echo "FILES_CHANGED=false" >> $GITHUB_ENV
51+
fi
4652
4753
# Stop workflow if no changes detected
4854
- name: Stop workflow if no changes detected
@@ -62,8 +68,15 @@ jobs:
6268
echo "Failed to parse current version from AssemblyInfo.cs"
6369
exit 1
6470
fi
65-
git tag -a "v$current_version" -m "Release version $current_version"
66-
git push origin "v$current_version"
71+
72+
# Check if tag already exists
73+
if git rev-parse "v$current_version" >/dev/null 2>&1; then
74+
echo "Tag v$current_version already exists. Skipping tag creation."
75+
else
76+
git tag -a "v$current_version" -m "Release version $current_version"
77+
git push origin "v$current_version"
78+
fi
79+
6780
echo "NEW_VERSION=$current_version" >> $GITHUB_ENV
6881
6982
# Extract Assembly Name from .csproj
@@ -83,23 +96,63 @@ jobs:
8396
- name: Get commit message
8497
id: get_commit_message
8598
run: |
86-
COMMIT_MESSAGE=$(git log -1 --pretty=%B HEAD)
99+
# Escape special characters in commit message
100+
COMMIT_MESSAGE=$(git log -1 --pretty=%B HEAD | sed 's/"/\\"/g')
87101
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV
88102
103+
# Debug information
104+
- name: Debug info
105+
if: env.FILES_CHANGED == 'true'
106+
run: |
107+
echo "Environment variables:"
108+
echo "ASSEMBLY_NAME: ${{ env.ASSEMBLY_NAME }}"
109+
echo "NEW_VERSION: ${{ env.NEW_VERSION }}"
110+
echo "Files in build path:"
111+
ls -la $BUILD_PATH
112+
89113
# Create the zip file for the release
90114
- name: Create the zip file for the release
91115
if: env.FILES_CHANGED == 'true'
92116
run: |
93117
mkdir -p release
94-
cp $BUILD_PATH/*.dll $BUILD_PATH/CalibreImport.config $BUILD_PATH/Setup.ps1 release/
95-
zip -r ${{ env.ASSEMBLY_NAME }}-v${{ env.NEW_VERSION }}.zip release/
118+
119+
# Check if required files exist
120+
if [ ! -d "$BUILD_PATH" ]; then
121+
echo "Error: Build path does not exist: $BUILD_PATH"
122+
exit 1
123+
fi
124+
125+
if [ ! -f "$BUILD_PATH/CalibreImport.config" ] || [ ! -f "$BUILD_PATH/Setup.ps1" ]; then
126+
echo "Warning: Some config files are missing. Continuing anyway."
127+
fi
128+
129+
# Copy files with error handling
130+
cp $BUILD_PATH/*.dll $BUILD_PATH/CalibreImport.config $BUILD_PATH/Setup.ps1 release/ || {
131+
echo "Warning: Some files could not be copied. Continuing with available files."
132+
}
133+
134+
zip -r ${{ env.ASSEMBLY_NAME }}-v${{ env.NEW_VERSION }}.zip release/ || {
135+
echo "Error: Failed to create zip file"
136+
exit 1
137+
}
138+
96139
echo "ZIP_FILE=${{ env.ASSEMBLY_NAME }}-v${{ env.NEW_VERSION }}.zip" >> $GITHUB_ENV
97140
98141
# Copy and rename CalibreImportSetup.exe
99142
- name: Copy and rename CalibreImportSetup.exe
100143
if: env.FILES_CHANGED == 'true'
101144
run: |
102-
cp $BUILD_PATH/${{ env.ASSEMBLY_NAME }}Setup.exe release/${{ env.ASSEMBLY_NAME }}Setup-${{ env.NEW_VERSION }}.exe
145+
# Check if setup exe exists
146+
if [ ! -f "$BUILD_PATH/${{ env.ASSEMBLY_NAME }}Setup.exe" ]; then
147+
echo "Error: Setup executable not found: $BUILD_PATH/${{ env.ASSEMBLY_NAME }}Setup.exe"
148+
exit 1
149+
fi
150+
151+
cp "$BUILD_PATH/${{ env.ASSEMBLY_NAME }}Setup.exe" "release/${{ env.ASSEMBLY_NAME }}Setup-${{ env.NEW_VERSION }}.exe" || {
152+
echo "Error: Failed to copy setup executable"
153+
exit 1
154+
}
155+
103156
echo "SETUP_FILE=release/${{ env.ASSEMBLY_NAME }}Setup-${{ env.NEW_VERSION }}.exe" >> $GITHUB_ENV
104157
105158
# Create Release
@@ -115,5 +168,7 @@ jobs:
115168
body: ${{ env.COMMIT_MESSAGE }}
116169
draft: false
117170
prerelease: false
118-
files: ${{ env.ZIP_FILE }},${{ env.SETUP_FILE }}
171+
files: |
172+
${{ env.ZIP_FILE }}
173+
${{ env.SETUP_FILE }}
119174
token: ${{ secrets.PAT_GITHUB }}

0 commit comments

Comments
 (0)