Skip to content

Commit

Permalink
Merge pull request #35 from iBrotNano/feature/#8
Browse files Browse the repository at this point in the history
Feature/#8
  • Loading branch information
iBrotNano committed Mar 16, 2023
2 parents 69debcc + 76cd229 commit 8e77e87
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 22 deletions.
70 changes: 51 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
name: build
name: build # Name of the action

env:
VERSION_MAJOR: 1
VERSION_MINOR: 0
VERSION_PATCH: 5
VERSION_BUILD: ${{ github.run_number }}
VERSION_SUFFIX: ${{ github.ref_name }}
VERSION_MAJOR: 1 # Major version of the package. Will be set in the project and binaries.
VERSION_MINOR: 0 # Minor version of the package. Will be set in the project and binaries.
VERSION_PATCH: 5 # Patch version of the package. Will be set in the project and binaries.
VERSION_BUILD: ${{ github.run_number }} # The run number is used as a build number for the version.
VERSION_SUFFIX: ${{ github.ref_name }} # The branch name is used to generate a suffix for pre-releases.

on:
workflow_dispatch:
workflow_dispatch: # Start a run through the UI.
push:
branches: [ "main", "feature/*", "bugfix/*" ]
branches: [ "main", "feature/*", "bugfix/*", "production" ] # Starts on pushes to this branches.
pull_request:
branches: [ "main", "feature/*", "bugfix/*" ]
branches: [ "main", "production" ] # Starts on pull requests to this branches.

jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-latest # Uses this image for building.

permissions: write-all
permissions: write-all # Needed to write tags and perform other tasks.

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3 # Git checkout
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 7.0.x # The used .NET version.
- name: Restore dependencies
run: dotnet restore
- name: Generate package version for regular builds
run: echo "PACKAGE_VERSION=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH-${VERSION_SUFFIX/\/#/-}-$VERSION_BUILD" >> $GITHUB_ENV
if: github.event_name != 'pull_request'
if: github.event_name != 'pull_request' && github.ref_name != 'production'
- name: Generate package version for PRs
run: echo "PACKAGE_VERSION=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH-PR-$VERSION_BUILD" >> $GITHUB_ENV
if: github.event_name == 'pull_request'
- name: Generate package version for production builds
run: echo "PACKAGE_VERSION=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH" >> $GITHUB_ENV
if: github.ref_name == 'production'
- name: Generate assembly version
run: echo "ASSEMBLY_VERSION=$VERSION_MAJOR.0.0.0" >> $GITHUB_ENV
- name: Generate file version
Expand All @@ -49,22 +52,51 @@ jobs:
sed -i -e "s/<InformationalVersion>4.7.11<\/InformationalVersion>/<InformationalVersion>$PACKAGE_VERSION<\/InformationalVersion>/g" Directory.Build.props
sed -i -e "s/<AssemblyVersion>4.7.1.1<\/AssemblyVersion>/<AssemblyVersion>$ASSEMBLY_VERSION<\/AssemblyVersion>/g" Directory.Build.props
sed -i -e "s/4.7.1.1/$PACKAGE_VERSION/g" README.md
sed -i -e "s/4.7.1.1/$PACKAGE_VERSION/g" CHANGELOG.md
- name: pkgdeps/git-tag-action
uses: pkgdeps/git-tag-action@v2.0.1
uses: pkgdeps/git-tag-action@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_repo: ${{ github.repository }}
git_commit_sha: ${{ github.sha }}
version: ${{ env.PACKAGE_VERSION }}
git_tag_prefix: "v"
if: github.ref_name == 'production'
- name: Build
run: dotnet build --no-restore -c Release -p:CONTINUOUS_INTEGRATION_BUILD=true
- name: Test
run: dotnet test -c Release --no-build --verbosity normal
- name: Pack
run: dotnet pack MarcelMelzig.TestEnvironment/MarcelMelzig.TestEnvironment.csproj --no-build -c Release -p:CONTINUOUS_INTEGRATION_BUILD=true
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3.1.2
- name: NuGet Repo Cleanup # Removes old pre-release packages from GitHub'S NuGet repository.
uses: actions/delete-package-versions@v4
with:
name: projectfiles
path: /home/runner/work/TestEnvironment/TestEnvironment/*
package-name: MarcelMelzig.TestEnvironment
package-type: nuget
min-versions-to-keep: 1
delete-only-pre-release-versions: true
- name: Upload Nuget
uses: actions/upload-artifact@v3
with:
name: NuGet
path: /home/runner/work/TestEnvironment/TestEnvironment/target/nugets/Release/*
- name: Upload Docs
uses: actions/upload-artifact@v3
with:
name: Docs
path: /home/runner/work/TestEnvironment/TestEnvironment/*.md
- name: Publish To Github NuGet Repo
run: |
dotnet nuget add source --username iBrotNano --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/iBrotNano/index.json"
dotnet nuget push "target/nugets/Release/MarcelMelzig.TestEnvironment.$PACKAGE_VERSION.nupkg" --source "github"
- name: Create release draft
uses: softprops/action-gh-release@v1
if: github.ref_name == 'production'
with:
files: |
README.md
LICENSE
CHANGELOG.md
body_path: CHANGELOG.md
draft: true
tag_name: "v${{ env.PACKAGE_VERSION }}"
1 change: 1 addition & 0 deletions AppExample/AppExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<WarningLevel>0</WarningLevel>
</PropertyGroup>

<ItemGroup>
Expand Down
24 changes: 22 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
# Changelog

## Version 1.0.5
## Version 4.7.1.1

### Changes
### Installation

The NuGet can be installed from GitHub’s NuGet Repository.

---

**Info:** [Working with the NuGet registry - GitHub Docs](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry#installing-a-package) documents how to reference GitHub’s NuGet repository.

---

```shell
dotnet add package MarcelMelzig.TestEnvironment --version 4.7.1.1
```

### What's new?

This is the initial release of the project. Hopefully it will help you to set up some useful test environments.

A fully automatic build pipeline is set up for the project. So you can await new features asap. All uses SemVer. Everything is published with docs production ready and you can even debug into the code with SourceLink.

### All Changes

- [Set the version by an action #1](https://github.com/iBrotNano/TestEnvironment/issues/1)
- [Add issue templates to the repo #2](https://github.com/iBrotNano/TestEnvironment/issues/2)
Expand Down
10 changes: 9 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<PackageIcon>Seat-Belt-256.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryType>Git</RepositoryType>
<PackageReleaseNotes>Initial version.</PackageReleaseNotes>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<!-- Here some configuration for the development and the build of this project is done. -->
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down Expand Up @@ -46,4 +45,13 @@
<PropertyGroup Condition="'$(CREATE_NUGET)' == 'true'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<Target Name="PreparePackageReleaseNotesFromFile" BeforeTargets="GenerateNuspec">
<ReadLinesFromFile File="../CHANGELOG.md" >
<Output TaskParameter="Lines" ItemName="ReleaseNoteLines"/>
</ReadLinesFromFile>
<PropertyGroup>
<PackageReleaseNotes>@(ReleaseNoteLines, '%0a')</PackageReleaseNotes>
</PropertyGroup>
</Target>
</Project>
1 change: 1 addition & 0 deletions TestProjectExample/TestProjectExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<WarningLevel>0</WarningLevel>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 8e77e87

Please sign in to comment.