Skip to content

Commit f31e4cf

Browse files
authoredSep 24, 2024··
Release v0.1.4 (#8)
This release decouples NuGet package publishing and Github Releases for now. Signed-off-by: Philip Conrad <philip@chariot-chaser.net>
1 parent 77117b5 commit f31e4cf

File tree

5 files changed

+101
-104
lines changed

5 files changed

+101
-104
lines changed
 

‎.github/workflows/03_publish.yaml

-100
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: "3a – Publish Package to NuGet"
2+
3+
# Trigger the action on push to main
4+
on:
5+
push:
6+
branches:
7+
- "main"
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
concurrency: ${{ github.workflow }}-${{ github.ref }}
12+
13+
env:
14+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
15+
DOTNET_NOLOGO: true
16+
NuGetDirectory: ${{ github.workspace }}/nuget
17+
18+
jobs:
19+
build-and-publish:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0 # Get all history for automatic versioning
25+
26+
- name: Setup .NET
27+
uses: actions/setup-dotnet@v4
28+
29+
- name: Restore dependencies
30+
run: dotnet restore
31+
32+
- name: Build
33+
run: dotnet build --configuration Release --no-restore
34+
35+
- name: Test
36+
run: dotnet test --no-restore --verbosity normal
37+
38+
- name: Get latest version from NuGet
39+
id: nuget_version
40+
run: |
41+
$latestVersion = (Invoke-WebRequest -Uri "https://api.nuget.org/v3-flatcontainer/styra.opa.aspnetcore/index.json" | ConvertFrom-Json).versions[-1]
42+
echo "LATEST_VERSION=$latestVersion" >> $env:GITHUB_OUTPUT
43+
shell: pwsh
44+
45+
- name: Get current version
46+
id: current_version
47+
run: |
48+
$currentVersion = (Select-Xml -Path src/Styra.Opa.AspNetCore/Styra.Opa.AspNetCore.csproj -XPath "//PackageVersion").Node.InnerText
49+
echo "CURRENT_VERSION=$currentVersion" >> $env:GITHUB_OUTPUT
50+
shell: pwsh
51+
52+
- name: Pack
53+
run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }} --no-build
54+
55+
- name: Publish NuGet package
56+
if: steps.nuget_version.outputs.LATEST_VERSION != steps.current_version.outputs.CURRENT_VERSION
57+
run: |
58+
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Filter *.nupkg)) {
59+
dotnet nuget push $file --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
60+
}
61+
shell: pwsh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "3 – Publish Github Release"
2+
3+
# Trigger the action on push to main
4+
on:
5+
push:
6+
tags:
7+
- "v*" # Trigger on tags starting with 'v'
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
concurrency: ${{ github.workflow }}-${{ github.ref }}
12+
13+
env:
14+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
15+
DOTNET_NOLOGO: true
16+
NuGetDirectory: ${{ github.workspace }}/nuget
17+
18+
jobs:
19+
github-release:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0 # Get all history for automatic versioning
25+
26+
- name: Generate Styra.Opa.AspNetCore GH release notes
27+
run: scripts/latest-release-notes.sh --output=SDK_RELEASE_NOTES.md
28+
env:
29+
VERSION: ${{ steps.current_version.outputs.CURRENT_VERSION }}
30+
31+
- name: Create Styra.Opa.AspNetCore GH release
32+
uses: softprops/action-gh-release@v2
33+
with:
34+
name: ${{ github.ref_name }}
35+
body_path: SDK_RELEASE_NOTES.md
36+
tag_name: ${{ github.ref }}

‎CHANGELOG.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
All notable changes to this project will be documented in this file. This
44
project adheres to [Semantic Versioning](http://semver.org/).
55

6-
## 0.1.2, 0.1.3
6+
## 0.1.4
77

8-
These releases are also release engineering tests, aimed at sorting out automated publishing of a Github Release and NuGet package.
8+
This release decouples Github Releases from NuGet package updates.
99

10-
## 0.1.0, 0.1.1
10+
## 0.1.0, 0.1.1, 0.1.2, 0.1.3
1111

1212
These releases are release engineering tests, aimed at sorting out automated publishing of a Github Release and NuGet package.

‎src/Styra.Opa.AspNetCore/Styra.Opa.AspNetCore.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<PackageId>Styra.Opa.AspNetCore</PackageId>
4-
<Version>0.1.0</Version>
4+
<Version>0.1.4</Version>
55
<Authors>Styra</Authors>
66
<TargetFramework>net8.0</TargetFramework>
77
<IsPackable>true</IsPackable>

0 commit comments

Comments
 (0)
Please sign in to comment.