Skip to content

Commit

Permalink
chore: update .NET version and enhance CI workflows
Browse files Browse the repository at this point in the history
Updated the .NET version in `build_app.yml` to '9.0.x' and modified artifact names to include "Velopack". Ensured upload steps are conditional on event type.

Added a new job in `releases.yml` for manual deployment to GitHub Releases, which includes steps for version retrieval, .NET installation, application publishing, and Velopack release creation.

Also, added a `<Version>` tag with '1.0.0' in `SketchNow.csproj` to specify the application version.
  • Loading branch information
realybin committed Jan 1, 2025
1 parent 3088033 commit 36befe4
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 17 deletions.
28 changes: 11 additions & 17 deletions .github/workflows/build_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ on:
defaults:
run:
shell: pwsh

env:
version: "1.0.${{ github.run_number }}"

jobs:
build:
runs-on: windows-latest
Expand All @@ -26,10 +22,15 @@ jobs:
- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'
dotnet-version: 9.0.x

- name: Get Version from Project File
id: get-version
shell: bash
run: echo "version=$(grep -oE '<Version>[^<]+' SketchNow/SketchNow.csproj | sed 's/<Version>//')" >> $GITHUB_OUTPUT

- name: dotnet build
run: dotnet build --configuration Release -p:Version="${{ env.version }}"
run: dotnet build --configuration Release -p:Version="${{ steps.get-version.outputs.version }}${{ github.run_number }}"

- name: dotnet test
run: dotnet test --configuration Release --no-build --collect:"XPlat Code Coverage" --results-directory ${{github.workspace}}/.build/coverage
Expand All @@ -56,27 +57,20 @@ jobs:

- name: dotnet publish
if: ${{ github.event_name != 'pull_request' }}
run: dotnet publish --configuration Release --no-build -p:Version="${{ env.version }}" -p:PublishDir=${{github.workspace}}/.build/publish
run: dotnet publish --configuration Release --no-build -p:Version="${{ steps.get-version.outputs.version }}${{ github.run_number }}" -p:PublishDir=${{github.workspace}}/.build/publish

- name: Build Velopack packages
if: ${{ github.event_name != 'pull_request' }}
run: dotnet tool update -g vpk && vpk pack -u SketchNow -v ${{ env.version }} -p ${{github.workspace}}/.build/publish -e SketchNow.exe -o ${{github.workspace}}/.build/release
run: dotnet tool update -g vpk && vpk pack -u SketchNow -v ${{ steps.get-version.outputs.version }}${{ github.run_number }} -p ${{github.workspace}}/.build/publish -e SketchNow.exe -o ${{github.workspace}}/.build/release

- name: Upload Publish artifact for deployment job
if: ${{ github.event_name != 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: Publish
path: ${{github.workspace}}/.build/publish

- name: Upload Portable artifact for deployment job
- name: Upload Velopack Portable artifact for deployment job
if: ${{ github.event_name != 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: Portable
path: ${{github.workspace}}/.build/release/SketchNow-win-Portable.zip

- name: Upload Installer artifact for deployment job
- name: Upload Velopack Installer artifact for deployment job
if: ${{ github.event_name != 'pull_request' }}
uses: actions/upload-artifact@v4
with:
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Deploy to GitHub Releases

on: workflow_dispatch
jobs:
deploy-to-github-releases:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

- name: Get Version from Project File
id: get-version
shell: bash
run: echo "version=$(grep -oE '<Version>[^<]+' SketchNow/SketchNow.csproj | sed 's/<Version>//')" >> $GITHUB_OUTPUT

- name: dotnet build
run: dotnet build --configuration Release -p:Version="${{ steps.get-version.outputs.version }}"

- name: dotnet test
run: dotnet test --configuration Release --no-build --collect:"XPlat Code Coverage" --results-directory ${{github.workspace}}/.build/coverage

- name: Upload Code Coverage Report
uses: actions/upload-artifact@v4
with:
name: CodeCoverage
path: ${{github.workspace}}/.build/coveragereport/
if-no-files-found: error

- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

- name: Publish Application
if: ${{ github.event_name != 'pull_request' }}
run: dotnet publish --no-build --configuration Release -p:PublishDir=${{ github.workspace }}/.build/publish -r win-x64 --self-contained true

- name: Create Velopack Release
run: |
dotnet tool install -g vpk
vpk download github --repoUrl https://github.com/SketchNow/SketchNow.WPF
vpk pack -u SketchNow -v ${{ steps.get-version.outputs.version }} -p ${{ github.workspace }}/.build/publish
vpk upload github --repoUrl https://github.com/SketchNow/SketchNow.WPF --releaseName "SketchNow ${{ steps.get-version.outputs.version }}" --tag v${{ steps.get-version.outputs.version }} --token ${{ secrets.RELEASE_TOKEN }}
1 change: 1 addition & 0 deletions SketchNow/SketchNow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<UseWPF>true</UseWPF>
<StartupObject>SketchNow.App</StartupObject>
<ApplicationIcon>Resources\AppIcon.ico</ApplicationIcon>
<Version>1.0.0</Version>
</PropertyGroup>

<!--
Expand Down

0 comments on commit 36befe4

Please sign in to comment.