Skip to content

Commit

Permalink
Update publish-release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost1372 authored Dec 12, 2024
1 parent 39f11ed commit ebe51f4
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,32 @@ jobs:
if: contains(env.IS_CUSTOM_NUGET_SOURCE_ENABLED, 'true')
# Reading version tag from the csproj file.
- uses: kzrnm/get-net-sdk-project-versions-action@v2
- name: Run MSBuild to Get Version
id: get-version
with:
proj-path: ${{ env.PROJECT_PATH }}
run: |
# Run MSBuild and capture raw version output
$output = & msbuild ${{ env.PROJECT_PATH }} /t:GetVersion /v:m 2>&1
Write-Output "MSBuild Output: $output"
# Extract the version string (assumes the last line contains the version)
$lines = $output -split "`n"
$version = $lines[-1].Trim()
Write-Output "Extracted Version: $version"
# Parse the version into prefix and suffix
if ($version -match '^([^-]+)-(.+)$') {
$prefix = $Matches[1]
$suffix = $Matches[2]
} else {
$prefix = $version
$suffix = ""
}
# Export variables
echo "VERSION=$version" >> $env:GITHUB_ENV
echo "VERSION_PREFIX=$prefix" >> $env:GITHUB_ENV
echo "VERSION_SUFFIX=$suffix" >> $env:GITHUB_ENV
# Building with configured commands
- run: |
Expand All @@ -93,21 +115,21 @@ jobs:
with:
files: ${{ env.PUBLISH_OUTPUT_FOLDER }}/${{ matrix.platform }}
recursive: true
dest: ${{ env.APP_NAME }}-v${{ steps.get-version.outputs.version }}-${{ matrix.platform }}.zip
dest: ${{ env.APP_NAME }}-v${{ env.VERSION }}-${{ matrix.platform }}.zip

# Uploading all zip files to access them in the 'release' job
- uses: actions/upload-artifact@v4
with:
name: artifacts-${{ matrix.platform }}
path: ${{ env.APP_NAME }}-v${{ steps.get-version.outputs.version }}-${{ matrix.platform }}.zip
path: ${{ env.APP_NAME }}-v${{ env.VERSION }}-${{ matrix.platform }}.zip

# Checking version suffix for words like [alpha, beta, preview, and experiment]. Marking the release as a pre-release if any exists.
- run: |
# Define the list of strings
$list = @("beta", "alpha", "preview", "experiment")
# Define the suffix variable
$suffix = "${{ steps.get-version.outputs.version-suffix }}"
$suffix = "${{ env.VERSION_SUFFIX }}"
foreach ($item in $list) {
# Convert both strings to lower case for case-insensitive comparison
Expand All @@ -124,7 +146,7 @@ jobs:
runs-on: ubuntu-latest
env:
# Read some variables from the 'build' job
APP_VERSION: ${{ needs.build.outputs.app-version }}
APP_VERSION: ${{ env.VERSION }}
IS_PRE_RELEASE: ${{ needs.build.outputs.IS_PRE_RELEASE }}
steps:
- uses: actions/checkout@v4
Expand Down

0 comments on commit ebe51f4

Please sign in to comment.