-
Notifications
You must be signed in to change notification settings - Fork 23
59 lines (49 loc) · 2.14 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# publishes to nuget if the version number in PrettyPrompt.csproj changes
name: publish to nuget
on:
push:
branches:
- main
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: Check for new version
id: CheckReleaseRequired
shell: pwsh
run: |
$publishedversions = (Find-Package -AllVersions -AllowPrereleaseVersions -Name "PrettyPrompt").Version
echo "Found published versions: $publishedversions"
if ($publishedversions.Count -gt 0) {
$csproj = [xml](Get-Content ./src/PrettyPrompt/PrettyPrompt.csproj)
$localversion = $csproj.Project.PropertyGroup.Version[0]
echo "Version in the repository is $localversion"
$isReleaseRequired = (-not $publishedversions.Contains($localversion)).ToString().ToLower()
echo "Release required: $isReleaseRequired"
echo "::set-output name=LOCAL_VERSION::v$localversion"
echo "::set-output name=IS_RELEASE_REQUIRED::$isReleaseRequired"
}
- name: Install Dotnet
uses: actions/setup-dotnet@v1
if: steps.CheckReleaseRequired.outputs.IS_RELEASE_REQUIRED == 'true'
with:
dotnet-version: |
8.0.x
- name: Create NuGet Package
if: steps.CheckReleaseRequired.outputs.IS_RELEASE_REQUIRED == 'true'
run: dotnet pack ./src/PrettyPrompt/PrettyPrompt.csproj -c Release -p:ContinuousIntegrationBuild=true
- name: Publish to NuGet
if: steps.CheckReleaseRequired.outputs.IS_RELEASE_REQUIRED == 'true'
run: dotnet nuget push --skip-duplicate --api-key ${{secrets.NUGET_API_KEY}} --source 'https://api.nuget.org/v3/index.json' .\src\PrettyPrompt\bin\Release\PrettyPrompt.*.nupkg
- name: Create Git Tag
if: steps.CheckReleaseRequired.outputs.IS_RELEASE_REQUIRED == 'true'
uses: actions/github-script@v6
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.CheckReleaseRequired.outputs.LOCAL_VERSION }}',
sha: context.sha
})