Skip to content

Commit 95d5afa

Browse files
authored
Integrate release-it in all workflows and add changelog (#13)
* Add changelog * Try different way to get the version number * Change trigger for publishing nuget package * Rename Github Action Workflow files * Prepend CI versioning with 0. to avoid problems when accidentally pushing to Nuget.org
1 parent 55ccef8 commit 95d5afa

5 files changed

Lines changed: 58 additions & 87 deletions

File tree

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
name: Publish NuGet package
33

44
on:
5-
push:
6-
tags:
7-
- 'v*.*.*'
8-
workflow_dispatch:
5+
release:
6+
types: [published]
97

108
env:
119
ARTIFACTS_FEED_URL: https://api.nuget.org/v3/index.json
@@ -16,23 +14,16 @@ jobs:
1614
runs-on: ubuntu-latest
1715
steps:
1816
- name: Checkout
19-
uses: actions/checkout@v2
20-
with:
21-
fetch-depth: 0 # Needed for GitVersion to function correctly
22-
23-
- name: Install GitVersion
24-
uses: gittools/actions/gitversion/setup@v0.9.7
25-
with:
26-
versionSpec: '5.x'
27-
28-
- name: Determine version number with GitVersion
29-
uses: gittools/actions/gitversion/execute@v0.9.7
30-
17+
uses: actions/checkout@v3
18+
19+
- name: Determine version for NuGet package
20+
run: echo NUGET_VERSION=${GITHUB_REF#refs/tags/v} >> $GITHUB_ENV
21+
3122
- name: Replace version number in nuspec files
32-
run: 'sed -i -e "s/{{NuGetVersion}}/$GITVERSION_NUGETVERSION/g" *.nuspec **/*.targets'
23+
run: 'sed -i -e "s/{{NuGetVersion}}/$NUGET_VERSION/g" *.nuspec **/*.targets'
3324

3425
- name: Setup NuGet.exe for use with actions
35-
uses: NuGet/setup-nuget@v1.0.5
26+
uses: NuGet/setup-nuget@v1.2.0
3627

3728
- name: Create main package
3829
run: nuget pack Neolution.CodeAnalysis.nuspec

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
publish:
12+
name: build & pack
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
18+
- name: Determine version for NuGet package
19+
run: echo NUGET_VERSION=0.$(date '+%Y.%m')-ci.$(date '+%d%H%M%S') >> $GITHUB_ENV
20+
21+
- name: Replace version number in nuspec files
22+
run: 'sed -i -e "s/{{NuGetVersion}}/$NUGET_VERSION/g" *.nuspec **/*.targets'
23+
24+
- name: Setup NuGet.exe for use with actions
25+
uses: NuGet/setup-nuget@v1.2.0
26+
27+
- name: Create main package
28+
run: nuget pack Neolution.CodeAnalysis.nuspec
29+
30+
- name: Create TestsRuleset package
31+
run: nuget pack Neolution.CodeAnalysis.TestsRuleset.nuspec

.github/workflows/create-release.yml

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ on:
77
type: choice
88
description: Semantic Version Type
99
options:
10-
- major
11-
- minor
12-
- patch
1310
- no-version-update
11+
- patch
12+
- minor
13+
- major
1414

1515
pre_release:
1616
type: choice
17-
description: Pre Release?
17+
description: Stage
1818
options:
1919
- stable
20-
- alpha
21-
- beta
2220
- rc
21+
- beta
22+
- alpha
2323

2424
jobs:
2525
release-it:
@@ -65,27 +65,3 @@ jobs:
6565
release-it -y "${params[@]}"
6666
env:
6767
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
68-
69-
- name: Get next release number
70-
run: |
71-
echo "RELEASE_VERSION=$(release-it --release-version --dry-run)" >> $GITHUB_ENV
72-
73-
- name: Print release version
74-
run: echo "The next release number is ${{ env.RELEASE_VERSION }}"
75-
76-
- name: Replace version number in nuspec files
77-
run: 'sed -i -e "s/{{NuGetVersion}}/$GITVERSION_NUGETVERSION/g" *.nuspec'
78-
79-
- name: Setup NuGet.exe for use with actions
80-
uses: NuGet/setup-nuget@v1.0.5
81-
82-
- name: Create main package
83-
run: nuget pack Neolution.CodeAnalysis.nuspec
84-
85-
- name: Create TestsRuleset package
86-
run: nuget pack Neolution.CodeAnalysis.TestsRuleset.nuspec
87-
88-
- name: Push all packages to Nuget.org
89-
run: dotnet nuget push --skip-duplicate -s $ARTIFACTS_FEED_URL -k $NUGET_AUTH_TOKEN **/*.nupkg
90-
env:
91-
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY_NEOLUTION }}

.github/workflows/dotnet.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6+
and adheres to a project-specific [Versioning](/README.md).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
12+
- Changelog

0 commit comments

Comments
 (0)