1+ name : Build and Release
2+
3+ on :
4+ push :
5+ branches : [ main, develop ]
6+ tags : [ 'v*' ]
7+ pull_request :
8+ branches : [ main ]
9+
10+ env :
11+ DOTNET_VERSION : ' 9.0.x'
12+ PROJECT_PATH : ' DazContentInstaller/DazContentInstaller.csproj'
13+ ARTIFACT_NAME : ' DazContentInstaller'
14+
15+ jobs :
16+ build :
17+ runs-on : ubuntu-latest
18+
19+ steps :
20+ - name : Checkout code
21+ uses : actions/checkout@v4
22+
23+ - name : Setup .NET
24+ uses : actions/setup-dotnet@v4
25+ with :
26+ dotnet-version : ${{ env.DOTNET_VERSION }}
27+
28+ - name : Build
29+ run : dotnet build ${{ env.PROJECT_PATH }} --configuration Release
30+
31+ # - name: Test
32+ # run: dotnet test ${{ env.PROJECT_PATH }} --no-build --verbosity normal
33+ # continue-on-error: true
34+
35+ - name : Publish for Windows x64
36+ run : |
37+ dotnet publish ${{ env.PROJECT_PATH }} \
38+ --configuration Release \
39+ --runtime win-x64 \
40+ --output "./publish/win-x64" \
41+ --verbosity normal
42+
43+ - name : Publish for Windows x86
44+ run : |
45+ dotnet publish ${{ env.PROJECT_PATH }} \
46+ --configuration Release \
47+ --runtime win-x86 \
48+ --output "./publish/win-x86" \
49+ --verbosity normal
50+
51+ - name : Create zip archives
52+ run : |
53+ # Create directories for zip files
54+ mkdir -p ./artifacts
55+
56+ # Zip x64 version
57+ cd ./publish/win-x64 && zip -r "../../artifacts/${{ env.ARTIFACT_NAME }}-win-x64.zip" . && cd ../..
58+
59+ # Zip x86 version
60+ cd ./publish/win-x86 && zip -r "../../artifacts/${{ env.ARTIFACT_NAME }}-win-x86.zip" . && cd ../..
61+
62+ - name : Upload build artifacts
63+ uses : actions/upload-artifact@v4
64+ with :
65+ name : ${{ env.ARTIFACT_NAME }}-builds
66+ path : ./artifacts/*.zip
67+ retention-days : 30
68+
69+ release :
70+ needs : build
71+ runs-on : ubuntu-latest
72+ if : startsWith(github.ref, 'refs/tags/v')
73+
74+ steps :
75+ - name : Checkout code
76+ uses : actions/checkout@v4
77+
78+ - name : Setup .NET
79+ uses : actions/setup-dotnet@v4
80+ with :
81+ dotnet-version : ${{ env.DOTNET_VERSION }}
82+
83+ - name : Publish for Windows x64
84+ run : |
85+ dotnet publish ${{ env.PROJECT_PATH }} \
86+ --configuration Release \
87+ --runtime win-x64 \
88+ --output "./publish/win-x64" \
89+ --verbosity normal
90+
91+ - name : Publish for Windows x86
92+ run : |
93+ dotnet publish ${{ env.PROJECT_PATH }} \
94+ --configuration Release \
95+ --runtime win-x86 \
96+ --output "./publish/win-x86" \
97+ --verbosity normal
98+
99+ - name : Create zip archives
100+ run : |
101+ # Create directories for zip files
102+ mkdir -p ./artifacts
103+
104+ # Zip x64 version
105+ cd ./publish/win-x64 && zip -r "../../artifacts/${{ env.ARTIFACT_NAME }}-${{ github.ref_name }}-win-x64.zip" . && cd ../..
106+
107+ # Zip x86 version
108+ cd ./publish/win-x86 && zip -r "../../artifacts/${{ env.ARTIFACT_NAME }}-${{ github.ref_name }}-win-x86.zip" . && cd ../..
109+
110+ - name : Generate release notes
111+ id : release_notes
112+ run : |
113+ tag="${{ github.ref_name }}"
114+ cat << EOF > ./release_notes.md
115+ ## Release $tag
116+
117+ ### Downloads
118+ - **Windows x64**: ${{ env.ARTIFACT_NAME }}-$tag-win-x64.zip
119+ - **Windows x86**: ${{ env.ARTIFACT_NAME }}-$tag-win-x86.zip
120+
121+ **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.event.before }}...$tag
122+ EOF
123+
124+ echo "notes_file=./release_notes.md" >> $GITHUB_OUTPUT
125+
126+ - name : Create Release
127+ uses : softprops/action-gh-release@v2
128+ with :
129+ files : ./artifacts/*.zip
130+ body_path : ${{ steps.release_notes.outputs.notes_file }}
131+ draft : false
132+ prerelease : ${{ contains(github.ref_name, '-') }}
133+ generate_release_notes : true
0 commit comments