Skip to content

📦 Create release using github actions #13

📦 Create release using github actions

📦 Create release using github actions #13

Workflow file for this run

name: .NET Core Desktop
on:
push:
tags:
- '*'
jobs:
build:
strategy:
matrix:
configuration: [Release]
targetplatform: [x64]
defaults:
run:
working-directory: ./src
runs-on: windows-latest
env:
Solution_Path: Watermarker.sln
TargetApplicationProjectFile: Watermarker.csproj
InstallerApplicationProjectFile: Watermarker.Installer.csproj
TargetApplicationDirectory: Watermarker
InstallerApplicationDirectory: Watermarker.Installer
ZipPrefix: watermarker
ZipInstaller: watermarker-installer
ArtifactName: WatermarkerInstaller
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
# Install the .NET Core workload
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/[email protected]
# Restore the application to populate the obj folder with RuntimeIdentifiers
- name: Restore the application
run: msbuild $env:Solution_Path /t:Restore /p:Configuration=$env:Configuration /p:RuntimeIdentifier=$env:RuntimeIdentifier
env:
Configuration: ${{ matrix.configuration }}
RuntimeIdentifier: win-${{ matrix.targetplatform }}
# Build main application
- name: Build the main application
run: msbuild $env:TargetApplicationDirectory/$env:TargetApplicationProjectFile /p:Platform=$env:TargetPlatform /p:Configuration=$env:Configuration
env:
Configuration: Release
TargetPlatform: ${{ matrix.targetplatform }}
# Build installer
- name: Build installer
run: msbuild $env:InstallerApplicationDirectory/$env:InstallerApplicationProjectFile /p:Platform=$env:TargetPlatform /p:Configuration=$env:Configuration
env:
Configuration: Release
TargetPlatform: ${{ matrix.targetplatform }}
- name: Pack application into zip
uses: vimtor/[email protected]
with:
files: src/${{ env.TargetApplicationDirectory }}/bin/${{ matrix.targetplatform }}/${{ matrix.configuration }}/net6.0-windows/
dest: src/${{ env.InstallerApplicationDirectory }}/bin/${{ matrix.targetplatform }}/${{ matrix.configuration }}/net6.0-windows/${{ env.ZipPrefix }}-${{ github.ref_name }}.zip
- name: Pack release with installer
uses: vimtor/[email protected]
with:
files: src/${{ env.InstallerApplicationDirectory }}/bin/${{ matrix.targetplatform }}/${{ matrix.configuration }}/net6.0-windows/
dest: ${{ env.ZipInstaller }}-${{ github.ref_name }}.zip
# Upload artifacts: https://github.com/marketplace/actions/upload-a-build-artifact
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.ZipInstaller }}-${{ github.ref_name }}
path: src/${{ env.InstallerApplicationDirectory }}/bin/${{ matrix.targetplatform }}/${{ matrix.configuration }}/net6.0-windows/
# Create the release: https://github.com/actions/create-release
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref}}.${{matrix.ChannelName}}.${{ matrix.targetplatform }}
release_name: ${{ github.ref }}.${{ matrix.ChannelName }}.${{ matrix.targetplatform }}
draft: false
prerelease: false
# Upload release asset: https://github.com/actions/upload-release-asset
- name: Update release asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ${{ env.ZipInstaller }}-${{ github.ref_name }}.zip
asset_name: ${{ env.ZipInstaller }}-${{ github.ref_name }}.zip
asset_content_type: application/zip