Skip to content

Commit 4fe5d03

Browse files
Initial
0 parents  commit 4fe5d03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+5107
-0
lines changed

.gitattributes

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
6+
###############################################################################
7+
# Set default behavior for command prompt diff.
8+
#
9+
# This is need for earlier builds of msysgit that does not have it on by
10+
# default for csharp files.
11+
# Note: This is only used by command line
12+
###############################################################################
13+
#*.cs diff=csharp
14+
15+
###############################################################################
16+
# Set the merge driver for project and solution files
17+
#
18+
# Merging from the command prompt will add diff markers to the files if there
19+
# are conflicts (Merging from VS is not affected by the settings below, in VS
20+
# the diff markers are never inserted). Diff markers may cause the following
21+
# file extensions to fail to load in VS. An alternative would be to treat
22+
# these files as binary and thus will always conflict and require user
23+
# intervention with every merge. To do so, just uncomment the entries below
24+
###############################################################################
25+
#*.sln merge=binary
26+
#*.csproj merge=binary
27+
#*.vbproj merge=binary
28+
#*.vcxproj merge=binary
29+
#*.vcproj merge=binary
30+
#*.dbproj merge=binary
31+
#*.fsproj merge=binary
32+
#*.lsproj merge=binary
33+
#*.wixproj merge=binary
34+
#*.modelproj merge=binary
35+
#*.sqlproj merge=binary
36+
#*.wwaproj merge=binary
37+
38+
###############################################################################
39+
# behavior for image files
40+
#
41+
# image files are treated as binary by default.
42+
###############################################################################
43+
#*.jpg binary
44+
#*.png binary
45+
#*.gif binary
46+
47+
###############################################################################
48+
# diff behavior for common document formats
49+
#
50+
# Convert binary document formats to text before diffing them. This feature
51+
# is only available from the command line. Turn it on by uncommenting the
52+
# entries below.
53+
###############################################################################
54+
#*.doc diff=astextplain
55+
#*.DOC diff=astextplain
56+
#*.docx diff=astextplain
57+
#*.DOCX diff=astextplain
58+
#*.dot diff=astextplain
59+
#*.DOT diff=astextplain
60+
#*.pdf diff=astextplain
61+
#*.PDF diff=astextplain
62+
#*.rtf diff=astextplain
63+
#*.RTF diff=astextplain

.github/workflows/release.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Create Release
2+
# This workflow gathers the version number and the relevant files
3+
# and creates and pushes a Tag and a Release with them.
4+
on:
5+
push:
6+
branches:
7+
- master
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
17+
env:
18+
# path to the release files
19+
BUILD_PATH: ${{ github.workspace }}/CalibreImport/ReleaseFiles
20+
21+
steps:
22+
# Checkout repository
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
# Set up Git identity
29+
- name: Set up Git identity
30+
run: |
31+
git config --global user.name "${{ github.actor }}"
32+
git config --global user.email "${{ github.actor }}@tuscoss.com"
33+
34+
# Check if relevant files have changed
35+
- name: Check if relevant files have changed
36+
id: check_files_changed
37+
run: |
38+
git fetch origin master
39+
git checkout master
40+
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD -- CalibreImport/ReleaseFiles/CalibreImport.config CalibreImport/ReleaseFiles/*.dll CalibreImport/ReleaseFiles/Setup.ps1 CalibreImport/ReleaseFiles/CalibreImportSetup.exe)
41+
echo "Changed files: $CHANGED_FILES"
42+
if [ -n "$CHANGED_FILES" ]; then
43+
echo "FILES_CHANGED=true" >> $GITHUB_ENV
44+
else
45+
echo "FILES_CHANGED=false" >> $GITHUB_ENV
46+
47+
# Stop workflow if no changes detected
48+
- name: Stop workflow if no changes detected
49+
if: env.FILES_CHANGED == 'false'
50+
run: |
51+
echo "No relevant changes detected. Stopping workflow."
52+
exit 0
53+
54+
# Extract version from AssemblyInfo.cs and create a tag
55+
- name: Extract version from AssemblyInfo.cs and create a tag
56+
if: env.FILES_CHANGED == 'true'
57+
id: create_tag
58+
run: |
59+
current_version=$(grep -Po '(?<=\[assembly: AssemblyVersion\(")([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' CalibreImport/Properties/AssemblyInfo.cs)
60+
echo "Current version: $current_version"
61+
if [ -z "$current_version" ]; then
62+
echo "Failed to parse current version from AssemblyInfo.cs"
63+
exit 1
64+
fi
65+
git tag -a "v$current_version" -m "Release version $current_version"
66+
git push origin "v$current_version"
67+
echo "NEW_VERSION=$current_version" >> $GITHUB_ENV
68+
69+
# Extract Assembly Name from .csproj
70+
- name: Extract Assembly Name from .csproj
71+
if: env.FILES_CHANGED == 'true'
72+
id: extract_assembly_name
73+
run: |
74+
assembly_name=$(grep -Po '(?<=<AssemblyName>)([^<]+)' CalibreImport/CalibreImport.csproj)
75+
echo "Assembly name: $assembly_name"
76+
if [ -z "$assembly_name" ]; then
77+
echo "Failed to parse assembly name from .csproj"
78+
exit 1
79+
fi
80+
echo "ASSEMBLY_NAME=$assembly_name" >> $GITHUB_ENV
81+
82+
# Get commit message
83+
- name: Get commit message
84+
id: get_commit_message
85+
run: |
86+
COMMIT_MESSAGE=$(git log -1 --pretty=%B HEAD)
87+
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV
88+
89+
# Create the zip file for the release
90+
- name: Create the zip file for the release
91+
if: env.FILES_CHANGED == 'true'
92+
run: |
93+
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/
96+
echo "ZIP_FILE=${{ env.ASSEMBLY_NAME }}-v${{ env.NEW_VERSION }}.zip" >> $GITHUB_ENV
97+
98+
# Copy and rename CalibreImportSetup.exe
99+
- name: Copy and rename CalibreImportSetup.exe
100+
if: env.FILES_CHANGED == 'true'
101+
run: |
102+
cp $BUILD_PATH/CalibreImportSetup.exe release/CalibreImportSetup-${{ env.NEW_VERSION }}.exe
103+
echo "SETUP_FILE=release/CalibreImportSetup-${{ env.NEW_VERSION }}.exe" >> $GITHUB_ENV
104+
105+
# Create Release
106+
- name: Create Release
107+
if: env.FILES_CHANGED == 'true'
108+
id: create_release
109+
uses: softprops/action-gh-release@v2
110+
env:
111+
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }}
112+
with:
113+
tag_name: v${{ env.NEW_VERSION }}
114+
name: Release v${{ env.NEW_VERSION }}
115+
body: ${{ env.COMMIT_MESSAGE }}
116+
draft: false
117+
prerelease: false
118+
files: ${{ env.ZIP_FILE }},${{ env.SETUP_FILE }}
119+
token: ${{ secrets.PAT_GITHUB }}

0 commit comments

Comments
 (0)