Skip to content

Commit a3ed428

Browse files
authored
Switch to release-it (#11)
1 parent d59d6a0 commit a3ed428

7 files changed

Lines changed: 166 additions & 97 deletions

File tree

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [main, develop]
7+
types: [opened, synchronize, ready_for_review]
8+
9+
# cancel running actions for current PR if new commits were pushed
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
check-changelog:
16+
name: check CHANGELOG.md
17+
if: github.event.pull_request.draft == false
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Get changed files
25+
id: changed-files
26+
uses: tj-actions/changed-files@v37
27+
28+
- name: Check if changelog was touched
29+
run: |
30+
changelogFound=$(echo ${{ steps.changed-files.outputs.all_changed_files }} | grep -ow "CHANGELOG.md" | wc -w)
31+
if [ $changelogFound -eq 0 ]; then
32+
echo '### :boom: Please update the changelog accordingly (https://keepachangelog.com)' >> $GITHUB_STEP_SUMMARY
33+
exit 1
34+
fi
35+
36+
dotnet-build:
37+
name: dotnet build and pack
38+
if: github.event.pull_request.draft == false
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v3
42+
43+
- uses: actions/setup-dotnet@v3
44+
with:
45+
dotnet-version: 6.x
46+
47+
- run: dotnet build -c Release
48+
49+
- run: dotnet pack -c Release --no-build --no-restore -o ./artifacts
50+
51+
- run: mv ./artifacts/*.nupkg ./artifacts/Neolution.Extensions.Configuration.GoogleSecrets.${{ github.run_id }}-${{ github.run_attempt }}.nupkg
52+
53+
- name: Upload artifact
54+
uses: actions/upload-artifact@v3
55+
with:
56+
name: "nuget-package"
57+
path: ./artifacts/*.nupkg
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Create Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_type:
7+
type: choice
8+
description: Semantic Version Type
9+
options:
10+
- automatic
11+
- patch
12+
- minor
13+
- major
14+
15+
pre_release:
16+
type: choice
17+
description: Stage
18+
options:
19+
- stable
20+
- rc
21+
- beta
22+
- alpha
23+
24+
jobs:
25+
release-it:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: tibdex/github-app-token@v1
29+
id: generate-token
30+
with:
31+
app_id: ${{ secrets.RELEASE_BOT_APP_ID }}
32+
private_key: ${{ secrets.RELEASE_BOT_APP_PRIVATE_KEY }}
33+
34+
- name: checkout
35+
uses: actions/checkout@v3
36+
with:
37+
token: ${{ steps.generate-token.outputs.token }}
38+
# we need everything so release-it can compare the current version with the latest tag
39+
fetch-depth: 0
40+
41+
- name: initialize mandatory git config
42+
run: |
43+
git config user.name "GitHub Release Bot"
44+
git config user.email release-bot@neolution.ch
45+
46+
- name: install @release-it/keep-a-changelog
47+
run: npm install -g release-it @release-it/keep-a-changelog @neolution-ch/release-it-dotnet-plugin
48+
49+
- name: run release-it
50+
run: |
51+
params=()
52+
53+
if [[ ${{ github.event.inputs.version_type }} != "automatic" ]]; then
54+
params+=(${{ github.event.inputs.version_type }})
55+
fi
56+
57+
if [[ ${{ github.event.inputs.pre_release }} != "stable" ]]; then
58+
params+=(--preRelease=${{ github.event.inputs.pre_release }})
59+
params+=(--plugins.@release-it/keep-a-changelog.keepUnreleased)
60+
params+=(--no-plugins.@release-it/keep-a-changelog.strictLatest)
61+
fi
62+
63+
params+=(--ci)
64+
params+=(--plugins.@neolution-ch/release-it-dotnet-plugin.nugetApiKey=${{ secrets.NUGET_API_KEY_NEOLUTION }})
65+
66+
echo "command: release-it ${params[@]}"
67+
release-it "${params[@]}"
68+
env:
69+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}

.github/workflows/dotnet-publish.yml

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

.github/workflows/dotnet.yml

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

.release-it.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"git": {
3+
"push": true
4+
},
5+
"npm": {
6+
"publish": false,
7+
"skipChecks": true
8+
},
9+
"github": {
10+
"release": true
11+
},
12+
"plugins": {
13+
"@release-it/keep-a-changelog": {
14+
"filename": "CHANGELOG.md",
15+
"addVersionUrl": true,
16+
"addUnreleased": true,
17+
"strictLatest": false
18+
},
19+
"@neolution-ch/release-it-dotnet-plugin": {
20+
"csprojFile": "./GoogleSecrets/GoogleSecrets.csproj",
21+
"buildConfiguration": "Release",
22+
"nugetApiKey": "overridden in GitHub workflow"
23+
}
24+
},
25+
"hooks": {
26+
"before:git:release": "npx prettier -y --write CHANGELOG.md && git add CHANGELOG.md"
27+
}
28+
}

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

GoogleSecrets/GoogleSecrets.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<Company>Neolution AG</Company>
1010
<Product>Add Google Secrets to the Configuration</Product>
1111
<GenerateDocumentationFile>true</GenerateDocumentationFile>
12-
<PackageVersion>1.1.7</PackageVersion>
1312
</PropertyGroup>
1413

1514
<ItemGroup>

0 commit comments

Comments
 (0)