As part of our transition from Azure DevOps (ADO) to GitHub, we’re focusing on automating the remaining parts of our workflow. One key area is the automatic creation of GitHub releases using GitHub Actions and the Semantic Release package.
Semantic Release is a highly flexible tool that follow semantic versioning, but it’s primarily geared towards frontend projects, often requiring a package.json file. Additionally, it lacks preconfigured GitHub tasks from official sources, though third-party options are available and describes in various online guides. To minimize dependencies on third-party tools, I’ve developed a few techniques to avoid committing frontend-specific files directly to the repository.
In this article, I’ll walk you through an example pipeline for building and publishing GitHub release for a .NET project using these techniques.
        # This workflow will build a .NET project
        # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
        name: .NET
        on:
          push:
            branches: [ "main" ]
          pull_request:
            branches: [ "main" ]
            
        env:
          BUILD_CONFIGURATION: 'Release'    # set this to the appropriate build configuration
          DOTNET_VERSION: '8.0.x' 
          
        jobs:
          build-windows:
            runs-on: windows-latest
            steps:
            - uses: actions/checkout@v4
            - name: Setup .NET
              uses: actions/setup-dotnet@v4
              with:
                dotnet-version: ${{ env.DOTNET_VERSION }}
                persist-credentials: false
                
            - name: dotnet build
              run: |
                dotnet restore
                dotnet publish 'D:/a/project/project.csproj' --configuration '${{ env.BUILD_CONFIGURATION }}' -p:PublishSingleFile=True --self-contained true --output package
              
            - name: Upload a Build Artifact
              uses: actions/upload-artifact@v4.3.4
              with:
                name: project-windows
                path: package
              
            # Semantic Release start
            - name: Setup Node.js
              uses: actions/setup-node@v3
              with:
                node-version: "lts/*"
            - name: Create and Upload Release
              env:
                GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
                GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
              run: |
                npm install --save-dev semantic-release
                npm audit signatures
                Compress-Archive -Path package/* -Destination package/package.zip
                echo '{"branches":["main"],"plugins":["@semantic-release/commit-analyzer","@semantic-release/release-notes-generator",["@semantic-release/github", {"assets": [{"path": "package/package.zip", "label": "package"}]}]]}' > .releaserc.json
                ls
                npx semantic-release
              # Semantic Release end
Here’s a refactored version of the provided steps:
- Build and Publish (.NET Project):- Use the dotnet buildanddotnet publishcommands.
- Set the output directory for the build artifact using the --output packageoption.
 
- Use the 
- Optional: Upload Build Artifact:- This step involves uploading the generated build artifact to the current workflow action or build.
 
- Setup Node.js:- Since Semantic-Release is a Node.js package, ensure that the latest Node.js version is installed in this step.
 
- Configure Authentication Tokens:- For private repositories, use a PAT (Personal Access Token) set as the GH_TOKEN.
- For public repositories, use the GITHUB_TOKEN.
- Refer to the official Semantic-Release CI Configuration for details.
- These tokens are sensitive and should be added as secrets in your repository.
- Ensure the PAT token has read/write access to the repository to avoid pipeline errors.
 
- For private repositories, use a PAT (Personal Access Token) set as the 
- **Install semantic release on workflow run **:- First, install the semantic-releasepackage withnpm install --save-dev semantic-release.
- Compress the additional build artifact (from the .NET project) that you want to upload to the release.
 
- First, install the 
- Create .releaserc.jsonConfiguration:- Use an echocommand to generate the.releaserc.jsonfile with all necessary plugins and configurations.
- In particular, check the assets section in the @semantic-release/githubplugin, where the build artifact pathpackage/package.zipis specified for release upload.
 
- Use an 
- Run Semantic-Release:- Finally, use npx semantic-releaseto create the actual release, which includes both the source code and the additional build artifact package.
 
- Finally, use