Nowadays, continous integration and delivery starts to make sense even for small personal projects, especially when features are added every now and then. You don’t want to remember how to build or where to put the newly built version. It makes more sense once you push your changes to a branch, to build automatically and to put the resulting exe file somewhere easily accessible on the web.

GitHub workflows are perfect for this.

First part is to build and publish the application when new commits are pushed to a repository.

name: Release MyWpfApp
on:
  push:
    branches:
      - master
jobs:
  build:
    runs-on: windows-latest
    steps:
    - run: echo $PWD
      shell: bash
    - name: Checkout repository
      uses: actions/checkout@v3
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v3
      with:
        dotnet-version: '6.0.x'
    - name: Publish
      run: dotnet publish /p:DebugType=None /p:DebugSymbols=false --configuration Release --self-contained:false

This will usually produce a MyWpfApp.exe (possible with some more DLLs and extra assets) and we just need a place to store it so that it’s accessible online, via https.

A good options could be to upload these files to an Azure Blob Storage that are accessible via https. But to upload to Azure, all of the GitHub actions I’ve found on the marketplace or the Azure CLI tools require linux to run, and our workflow needs Windows to compile WPF.

The solution is to create a second job, depending on the previous one, that runs on linux. To move the MyWpfApp.exe file from one job (running on Windows) to the second job (runnint on Linux), the GitHub classic actions/download-artifact@v3 / upload-artifact come handy.

Here’s the part to upload the artifact so that it can be downloaded later on the linux container:

    - name: Upload artifact
      uses: actions/upload-artifact@v3
      with:
        name: MyWpfApp
        path: MyWpfApp\bin\Release\net6.0-windows\win-x86\publish\

And here’s the job publishing the app on Azure Blob Storage:

  publish:
    needs: build
    runs-on: ubuntu-latest
    env:
      AZURE_STORAGE_CONNECTION_STRING: $
    steps:
    - name: Download artifact
      uses: actions/download-artifact@v3
      with:
        name: MyWpfApp
    - name: Upload to Azure Blob Storage
      uses: azure/CLI@v1
      with:
        azcliversion: 2.51.0
        inlineScript: |
          az storage blob upload-batch -d files -s . --destination-path MyWpfApp --overwrite true

This will upload it in the files container at the MyWpfApp\MyWpfApp.exe location. Note that you need an Azure Blob Storage connection string, set up in a GitHub workflow secret, that is passed to the az command as an environment variable.

Now your new version of the MyWpfApp.exe can be downloaded from the following address: https://<yourstoragename>.blob.core.windows.net/files/MyWpfApp/MyWpfApp.exe.