88 type : string
99 default : 1.0.0 # for non-released builds
1010 release_url :
11- description : The url to upload a publsihed release
11+ description : The url to upload a published release
1212 required : false # leave empty for non-release build
1313 type : string
1414 release_dir :
1515 description : The relative directory inside the repo where the build artifacts to publish for release will be located
16+ required : true
17+ type : string
18+ release_project :
19+ description : The relative file location for csproj
1620 required : false
1721 type : string
1822 integration_type :
5559
5660 echo "release_dir: ${{ inputs.release_dir }}"
5761
58- $creatingRelease = ( "${{ inputs.release_url }}".Trim().Length -gt 0) -and ("${{ inputs.release_dir }}".Trim().Length -gt 0)
62+ $creatingRelease = "${{ inputs.release_url }}".Trim().Length -gt 0
5963 echo "Flagged to create release: ${creatingRelease}"
6064 echo "CREATE_RELEASE=${creatingRelease}" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
6165
7478 if ($assemblyInfoFiles -ne $null)
7579 {
7680 $newVer = "${{ inputs.release_version || '1.0.0' }}".TrimStart('v').Split('-')[0]
81+ echo "newver=${newVer}" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
7782 echo "Prepared to overwrite Assembly version to: ${newVer}"
7883 foreach ($assemblyInfoFile in $assemblyInfoFiles)
7984 {
@@ -88,37 +93,64 @@ jobs:
8893 $newVer = "${{ inputs.release_version || '1.0.0' }}".TrimStart('v').Split('-')[0]
8994 MSBuild.exe $Env:SOLUTION_PATH -p:RestorePackagesConfig=false -p:Configuration=Release -p:Version=$newVer
9095
91- - name : Check for manifest
92- if : success() && env.CREATE_RELEASE == 'True' && inputs.integration_type == 'orchestrator'
96+ - name : Read Target Frameworks
97+ id : read_target_frameworks
98+ shell : pwsh
9399 run : |
94- $fileExists = Get-ChildItem -Path ${{ github.workspace }}\${{ inputs.release_dir }} -Recurse -Filter 'manifest.json' | Select-Object -First 1
95- if (-not $fileExists) { exit 1 }
100+ [xml]$csproj = Get-Content "${{ inputs.release_project }}"
101+ $targetFrameworks = $csproj.Project.PropertyGroup.TargetFrameworks
102+ if ($null -eq $targetFrameworks) {
103+ $targetFrameworks = $csproj.Project.PropertyGroup.TargetFramework
104+ }
105+ echo "release_platforms: $targetFrameworks"
106+ echo "release_platforms=$targetFrameworks" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
96107
97108 - name : Archive Files
98109 if : success() && env.CREATE_RELEASE == 'True'
110+ shell : pwsh
99111 run : |
100- md ${{ github.workspace }}\zip\Keyfactor
101- Compress-Archive -Path `
102- ${{ github.workspace }}\${{ inputs.release_dir }}\ `
103- -DestinationPath ${{ github.workspace }}\zip\Keyfactor\$Env:REPO_NAME.zip -Force
104-
105- - name : Upload Release Asset (x64)
112+ $platforms = "${{ env.release_platforms }}".Split(';')
113+ $outputDir = "${{ github.workspace }}\zip\Keyfactor"
114+ echo "outputDir=$outputDir" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
115+ if (Test-Path $outputDir) {
116+ Remove-Item -Recurse -Force $outputDir
117+ }
118+ md $outputDir
119+ foreach ($platform in $platforms) {
120+ $platform = $platform.Trim()
121+ $sourcePath = "${{ github.workspace }}\${{ inputs.release_dir }}\$platform\"
122+ $zipPath = "$outputDir\${{ env.REPO_NAME }}_${{ inputs.release_version }}_$platform.zip"
123+ Get-ChildItem -File -Path $sourcePath
124+ Compress-Archive -Path $sourcePath -DestinationPath $zipPath -Force -Verbose
125+ }
126+ Get-ChildItem -File -Path $outputDir
127+ $buildFiles = Get-ChildItem -File -Path $outputDir -Name
128+ $releaseArtifacts
129+ foreach ($zipFile in $buildFiles) {
130+ $releaseArtifacts = $releaseArtifacts + $outputDir + "\" + $zipFile + [Environment]::NewLine
131+ }
132+ echo "release_artifacts: $releaseArtifacts"
133+ echo "Writing in as multiline github env variable"
134+ echo "release_artifacts<<EOF" >> $env:GITHUB_ENV
135+ echo "$releaseArtifacts" >> $env:GITHUB_ENV
136+ echo "EOF" >> $env:GITHUB_ENV
137+
138+ - name : Release Asset(s)
139+ uses : softprops/action-gh-release@v2
106140 if : success() && env.CREATE_RELEASE == 'True'
107- id : upload-release-asset-x64
108- uses : keyfactor/upload-release-assets@v1
109- env :
110- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
111141 with :
112- upload_url : ${{ inputs.release_url }}
113- asset_path : ${{ github.workspace }}\zip\Keyfactor\${{ env.REPO_NAME}}.zip
114- asset_name : ${{ env.REPO_NAME}}_${{ inputs.release_version }}.zip
115- asset_content_type : application/zip
116-
117- - name : Delete Failed Release
118- if : failure() && env.CREATE_RELEASE == 'True'
119- id : delete-failed-release
120- env :
121- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
122- run : |
123- gh release delete ${{ inputs.release_version }} --yes --cleanup-tag
142+ repository : ${{ github.repository }}
143+ files : |
144+ ${{ env.release_artifacts }}
145+ append_body : true
146+ tag_name : ${{ inputs.release_version }}
147+ token : ${{ secrets.token }}
148+
149+ # - name: Delete Failed Release
150+ # if: failure() && env.CREATE_RELEASE == 'True'
151+ # id: delete-failed-release
152+ # env:
153+ # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
154+ # run: |
155+ # gh release delete ${{ inputs.release_version }} --yes --cleanup-tag
124156
0 commit comments