-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (126 loc) · 5.36 KB
/
vxmusic-publish-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: VXMusic Desktop Build/Release
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch: # Add this to manually trigger the workflow
permissions:
contents: write
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.x'
- name: Get Project Version
uses: kzrnm/get-net-sdk-project-versions-action@v2
id: get-project-version
with:
proj-path: VXMusicDesktop/VXMusicDesktop.csproj
# - name: Get Last Tag Version
# id: previoustag
# uses: 'WyriHaximus/github-action-get-previous-tag@v1'
# with:
# fallback: ${{ steps.get-project-version.outputs.version }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Determine next version
# id: nextversion
# run: |
# $current_version = '${{ steps.previoustag.outputs.tag }}'
# $base_version = '${{ steps.get-project-version.outputs.version }}'
# if ($current_version -match '(\d+)\.(\d+)\.(\d+)') {
# $major = [int]$matches[1]
# $minor = [int]$matches[2]
# $patch = [int]$matches[3] + 1
# $new_version = "$major.$minor.$patch"
# } else {
# $new_version = "$base_version.0"
# }
# echo "VERSION=$new_version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8
# shell: pwsh
# - name: Set New Version
# id: set_project_version
# run: |
# $new_version = ${{ steps.get-project-version.outputs.version }}
# echo "Dynamic Version: $new_version"
# echo "new_version=$new_version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8
# shell: pwsh
# - name: Update CSPROJ with dynamic version
# run: |
# $csproj_path = "VXMusicDesktop/VXMusicDesktop.csproj"
# $new_version = $env:new_version
# (Get-Content $csproj_path) -replace '<Version>.*</Version>', "<Version>$new_version</Version>" | Set-Content $csproj_path
# shell: pwsh
- name: Replace version in NSIS script
run: |
(Get-Content -path "${{ github.workspace }}/Installer/VXMusic.nsi") -replace '(!define PRODUCT_VERSION ").*(")', '!define PRODUCT_VERSION "${{ steps.get-project-version.outputs.version }}"' | Set-Content -path "${{ github.workspace }}/Installer/VXMusic.nsi"
Get-Content -path "${{ github.workspace }}/Installer/VXMusic.nsi"
shell: pwsh
- name: Install dependencies
run: dotnet restore
- name: Build solution
run: dotnet build --configuration Release --no-restore
- name: Publish VXMusic
run: dotnet publish ${{ github.workspace }}/VXMusicDesktop/VXMusicDesktop.csproj -r win-x64 -c Release -o ${{ github.workspace }}/Publish/x64
- name: Make NSIS Installer
id: make_nsis_installer
uses: joncloud/makensis-action@v4.1
with:
script-file: "${{ github.workspace }}/Installer/VXMusic.nsi"
- name: Run VXMusicInstaller
id: run_vxmusicinstaller
if: steps.make_nsis_installer.conclusion == 'success'
run: |
${{ github.workspace }}\Installer\VXMusicInstaller.exe /S /D=${{ github.workspace }}\InstallerOutput
- name: List Installer Output Directory (Debug)
if: steps.run_vxmusicinstaller.conclusion == 'success'
run: |
dir ${{ github.workspace }}\InstallerOutput
- name: Copy Uninstaller to Package Location
if: steps.run_vxmusicinstaller.conclusion == 'success'
id: copy_uninstaller_to_package_location
run: |
Copy-Item -Path ${{ github.workspace }}\InstallerOutput\UninstallVXMusic.exe -Destination ${{ github.workspace }}\Publish\x64
- name: Package VXMusic
run: |
cd ${{ github.workspace }}/Publish/x64
Compress-Archive -Path * -DestinationPath ../../VXMusic_x64_${{ steps.get-project-version.outputs.version }}.zip
shell: pwsh
- name: List Package Output Directory (Debug)
if: steps.copy_uninstaller_to_package_location.conclusion == 'success'
run: |
dir ${{ github.workspace }}\Publish\x64
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get-project-version.outputs.version }}
release_name: VXMusic ${{ steps.get-project-version.outputs.version }}
draft: true
prerelease: false
- name: Upload Installer Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/Installer/VXMusicInstaller.exe
asset_name: VXMusicInstaller_${{ steps.get-project-version.outputs.version }}.exe
asset_content_type: application/octet-stream
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/VXMusic_x64_${{ steps.get-project-version.outputs.version }}.zip
asset_name: VXMusic_${{ steps.get-project-version.outputs.version }}.zip
asset_content_type: application/zip