Skip to content

Commit

Permalink
Add CI/CD pipeline (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt authored Jun 5, 2022
1 parent 464dd7f commit 1ac0ab9
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
on:
push:
branches:
- main
tags:
- v*
pull_request:

jobs:

build_packages:
runs-on: ubuntu-20.04
env:
Configuration: Release
TreatWarningsAsErrors: true
WarningsNotAsErrors: 1591
defaults:
run:
working-directory: src
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Update path
run: echo ":/github/home/.dotnet/tools" >> $GITHUB_PATH
- run: dotnet tool install -g GitVersion.Tool --version 5.10.1 --ignore-failed-sources
- run: dotnet tool install -g dotnet-validate --version 0.0.1-preview.304
- name: Resolve semantic version
id: semantic_version
run: |
semantic_version=$(dotnet-gitversion /showvariable SemVer)
echo "semantic_version=$semantic_version" >> $GITHUB_ENV
working-directory: ./
- name: Resolve assembly version
id: assembly_version
run: |
assembly_version=$(dotnet-gitversion /showvariable AssemblySemVer)
echo "assembly_version=$assembly_version" >> $GITHUB_ENV
working-directory: ./
- run: dotnet restore --configfile nuget.config
#- run: dotnet format --no-restore --verify-no-changes
- run: dotnet build --no-restore /p:Version=${{ env.assembly_version }}
- run: dotnet test --no-build
- run: dotnet pack --no-build /p:PackageVersion=${{ env.semantic_version }}
- uses: actions/upload-artifact@v3
with:
name: nuget_packages
path: src/LinqToRegex/bin/Release/*nupkg

release_packages:
runs-on: ubuntu-20.04
needs: [build_packages]
if: github.ref == 'refs/heads/main' && github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
steps:
- uses: actions/download-artifact@v3
with:
name: nuget_packages
path: nuget_packages
- run: dotnet nuget push "*.nupkg" -k NUGET_API_KEY -s "https://api.nuget.org/v3/index.json"
working-directory: nuget_packages
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @josefpihrt
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add CI/CD pipeline

### Changed

- Rename `master` to `main`.
Expand Down
9 changes: 9 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
build-metadata-padding: 4
mode: ContinuousDeployment

branches:
master:
tag: beta
pull-request:
tag: alpha
tag-number-pattern: '[/-](?<number>\d+)[-/]'
1 change: 1 addition & 0 deletions src/LinqToRegex.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{910EF5C5-2E30-4596-A63C-5C6344655D02}"
ProjectSection(SolutionItems) = preProject
..\.editorconfig = ..\.editorconfig
..\.github\workflows\build.yml = ..\.github\workflows\build.yml
..\CHANGELOG.md = ..\CHANGELOG.md
Directory.Build.props = Directory.Build.props
..\LICENSE.txt = ..\LICENSE.txt
Expand Down
9 changes: 9 additions & 0 deletions src/nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>

<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>

</configuration>

0 comments on commit 1ac0ab9

Please sign in to comment.