Build and release Zenon CLI for .NET #59
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and release Zenon CLI for .NET | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
env: | |
PROJECT_PATH: src/ZenonCli/ZenonCli.csproj | |
jobs: | |
build-macos: | |
runs-on: macos-12 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 6.0.x | |
- name: Install Nerdbank Git versioning | |
run: dotnet tool install -g nbgv | |
- name: Setup Nerdbank Git versioning | |
run: nbgv install | |
- name: Restore | |
run: dotnet restore $PROJECT_PATH --runtime osx-x64 | |
- name: Build | |
run: dotnet build $PROJECT_PATH --configuration Release --runtime osx-x64 --no-self-contained --no-restore | |
- name: Test | |
run: dotnet test $PROJECT_PATH --no-restore --no-build --verbosity normal | |
- name: Publish | |
run: dotnet publish $PROJECT_PATH --configuration Release --runtime osx-x64 --no-self-contained --no-restore --no-build | |
- name: Package into zip | |
run: | | |
cd bin/ZenonCli/release/net6.0/osx-x64/publish | |
zip -r ../../../../../../znn-cli-dotnet-macos-universal.zip * | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: macos-artifacts | |
path: znn-cli-dotnet-macos-universal.zip | |
build-windows: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 6.0.x | |
- name: Setup Nerdbank Git versioning | |
run: nbgv install | |
- name: Restore | |
run: dotnet restore $env:PROJECT_PATH --runtime win-x64 | |
- name: Build | |
run: dotnet build $env:PROJECT_PATH --configuration Release --runtime win-x64 --no-self-contained --no-restore | |
- name: Test | |
run: dotnet test $env:PROJECT_PATH --no-restore --no-build --verbosity normal | |
- name: Publish | |
run: dotnet publish $env:PROJECT_PATH --configuration Release --runtime win-x64 --no-self-contained --no-restore --no-build | |
- name: Copy Native Libraries | |
run: Copy lib\hidapi-win\x64\hidapi.dll bin\ZenonCli\release\net6.0\win-x64\publish\ | |
- name: Package into zip | |
run: | | |
Compress-Archive -Path bin\ZenonCli\release\net6.0\win-x64\publish\* -DestinationPath .\znn-cli-dotnet-windows-amd64.zip | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: windows-artifacts | |
path: znn-cli-dotnet-windows-amd64.zip | |
build-linux: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 6.0.x | |
- name: Setup Nerdbank Git versioning | |
run: nbgv install | |
- name: Restore | |
run: dotnet restore $PROJECT_PATH --runtime linux-x64 | |
- name: Build | |
run: dotnet build $PROJECT_PATH --configuration Release --runtime linux-x64 --no-self-contained --no-restore | |
- name: Test | |
run: dotnet test $PROJECT_PATH --no-restore --no-build --verbosity normal | |
- name: Publish | |
run: dotnet publish $PROJECT_PATH --configuration Release --runtime linux-x64 --no-self-contained --no-restore --no-build | |
- name: Package into zip | |
run: | | |
cd bin/ZenonCli/release/net6.0/linux-x64/publish | |
zip -r ../../../../../../znn-cli-dotnet-linux-amd64.zip * | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: linux-artifacts | |
path: znn-cli-dotnet-linux-amd64.zip | |
make-release: | |
needs: [build-windows, build-linux, build-macos] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 6.0.x | |
- name: Setup Nerdbank Git versioning | |
run: nbgv install | |
- name: Set variables | |
run: | | |
VERSION=v$(nbgv get-version | grep NuGetPackageVersion | sed 's/NuGetPackageVersion://' | xargs) | |
echo "CLI Version: $VERSION" | |
echo "CLI_VERSION=$VERSION" >> $GITHUB_ENV | |
BODY=$(cat <<EOF | |
Zenon CLI for .NET $VERSION | |
Zenon CLI for .NET requires .NET 6.0 or higher to be installed. | |
[Download Microsoft .NET 6.0](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) | |
Github Action Context information | |
Git reference: ${{ github.ref }} | |
Repository URL: ${{ github.repositoryUrl }} | |
Run ID: ${{ github.run_id }} | |
Commit hash: ${{ github.sha }} | |
Workflow hash: ${{ github.workflow_sha }} | |
EOF | |
) | |
echo "$BODY" | |
echo "BODY<<EOFMARKER" >> ${GITHUB_ENV} | |
echo "${BODY}" >> ${GITHUB_ENV} | |
echo "EOFMARKER" >> ${GITHUB_ENV} | |
- name: Prepare releases directory | |
run: mkdir releases | |
- name: Download macOS artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: macos-artifacts | |
- name: Download Windows artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: windows-artifacts | |
- name: Download Linux artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: linux-artifacts | |
- name: Prepare releases | |
run: | | |
cp znn-cli-dotnet-macos-universal.zip releases/ | |
cp znn-cli-dotnet-windows-amd64.zip releases/ | |
cp znn-cli-dotnet-linux-amd64.zip releases/ | |
- name: Generate checksums | |
run: | | |
cd releases/ | |
echo $(sha256sum *) | |
echo $(sha256sum *) >> SHA256CHECKSUMS.txt | |
- name: Upload files to a GitHub release | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: releases/* | |
release_name: ${{ env.CLI_VERSION }} | |
tag: ${{ env.CLI_VERSION }} | |
file_glob: true | |
overwrite: true | |
body: ${{ env.BODY }} |