Skip to content

Commit

Permalink
Merge pull request #14 from nodew/nuget-release-action
Browse files Browse the repository at this point in the history
Add GitHub action to release dotnet tool to nuget.org.
  • Loading branch information
nodew authored Feb 7, 2024
2 parents 53caed8 + 657e204 commit 8d5e8bd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
35 changes: 35 additions & 0 deletions .github/workflows/cli-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release .NET Tool

on:
push:
tags:
"cli-v[0-9]+.[0-9]+.[0-9]+"

defaults:
run:
working-directory: src/PwSafeClient.CLI

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Extract Version
if: ${{ github.ref_type == 'tag' }}
run: |
version=$(./build/extract_version "${GITHUB_REF#refs/tags/}")
echo "VERSION=$version" >> $GITHUB_ENV
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore /p:Version=$VERSION
- name: Pack
run: dotnet pack --no-restore --no-build /p:PackageVersion=$VERSION
- name: Upload
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/cli-v')
run: dotnet nuget push nupkg/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
6 changes: 6 additions & 0 deletions build/extract_version
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# Use sed to extract version pattern
version=$(echo "$1" | sed -E 's/^[^-]+-v?([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?)$/\1/')

echo "$version"
1 change: 0 additions & 1 deletion src/PwSafeClient.CLI/PwSafeClient.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<AssemblyName>pwsafe</AssemblyName>
<Version>1.0.0-beta</Version>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down

0 comments on commit 8d5e8bd

Please sign in to comment.