Skip to content

Commit e882eb6

Browse files
committed
Modernizing the build process
1 parent c881ca5 commit e882eb6

7 files changed

+47
-173
lines changed

.appveyor.yml

+6-20
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,11 @@ image: Visual Studio 2019
33
skip_branch_with_pr: true
44

55
build_script:
6-
- ps: .\build.appveyor.ps1
7-
6+
- ps: dotnet restore
7+
- ps: dotnet build --no-restore -c Release
8+
- ps: dotnet test --no-restore /p:SkipBuildVersioning=true
9+
- ps: dotnet pack --no-build -c Release /p:PackageOutputPath=build-artifacts
10+
811
test: false
912
artifacts:
10-
- path: '.\build-artifacts\*'
11-
12-
deploy:
13-
- provider: NuGet
14-
artifact: /.*nupkg/
15-
api_key:
16-
secure: QNfyCsBxCLb4iGmaRd2ep7yYY3RMJKw54B7p+ZcFDo5pb8KnWM0ULl4ml2u38s/w
17-
on:
18-
APPVEYOR_REPO_TAG: true
19-
- provider: GitHub
20-
artifact: /.*nupkg/
21-
draft: true
22-
release: $(APPVEYOR_REPO_TAG_NAME)
23-
description: 'TODO'
24-
auth_token:
25-
secure: 8WGv8noklaCJAQEBpcs+VShk/Hql5zbyx0VPhMvzUw0RcG7rAd2KxKIh4gazXlBi
26-
on:
27-
APPVEYOR_REPO_TAG: true
13+
- path: '**\build-artifacts\*'

.github/workflows/build.yml

+36-49
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ main ]
66
pull_request:
77
release:
88
types: [ published ]
@@ -19,47 +19,9 @@ env:
1919

2020
jobs:
2121

22-
version:
23-
name: Identify build version
24-
runs-on: ubuntu-latest
25-
outputs:
26-
BuildVersion: ${{steps.configureBuildVersion.outputs.BUILD_VERSION}}
27-
steps:
28-
- name: Checkout
29-
uses: actions/checkout@v2
30-
- name: Fetch all Git tags
31-
run: git fetch --prune --unshallow --tags
32-
- name: Configure build version
33-
id: configureBuildVersion
34-
run: |
35-
$githubRunId = $env:GITHUB_RUN_ID;
36-
$prNumber = $env:PR_NUMBER;
37-
$gitSourceVersion = git describe --tags --abbrev=7 --always 2>$1;
38-
$gitSourceVersionSplit = [regex]::split($gitSourceVersion, "-(?=\d+-\w+)");
39-
$version = $(if($gitSourceVersionSplit.length -eq 1){"0.0.0"}else{$gitSourceVersionSplit[0]});
40-
$commitsSinceTag = '0';
41-
$commitHash = $gitSourceVersionSplit[0];
42-
if ($gitSourceVersionSplit.length -eq 2) {
43-
$gitMetadata = $gitSourceVersionSplit[1].split("-");
44-
$commitsSinceTag = $gitMetadata[0];
45-
$commitHash = $gitMetadata[1];
46-
}
47-
$buildMetadata = "$($commitHash)-$($githubRunId)";
48-
$customSuffix = $(if($prNumber -ne ''){"-PR$($prNumber)"}elseif($commitsSinceTag -ne '0'){"-dev"});
49-
echo "::set-output name=BUILD_VERSION::$($version)$($customSuffix)+$($buildMetadata)";
50-
shell: pwsh
51-
env:
52-
PR_NUMBER: ${{github.event.number}}
53-
- name: Print build version
54-
run: echo ${{steps.configureBuildVersion.outputs.BUILD_VERSION}}
55-
56-
5722
build:
5823
name: Build ${{matrix.os}}
5924
runs-on: ${{matrix.os}}
60-
needs: version
61-
env:
62-
BUILD_VERSION: ${{needs.version.outputs.BuildVersion}}
6325
strategy:
6426
matrix:
6527
os: [ubuntu-latest, windows-latest, macOS-latest]
@@ -81,11 +43,11 @@ jobs:
8143
- name: Install dependencies
8244
run: dotnet restore
8345
- name: Build
84-
run: dotnet build -c Release --no-restore /p:Version=${{env.BUILD_VERSION}}
46+
run: dotnet build --no-restore -c Release
8547
- name: Test with Coverage
86-
run: dotnet test --logger trx --results-directory ${{env.BUILD_ARTIFACT_PATH}}/coverage --collect "XPlat Code Coverage" --settings CodeCoverage.runsettings
48+
run: dotnet test --no-restore --logger trx --results-directory ${{env.BUILD_ARTIFACT_PATH}}/coverage --collect "XPlat Code Coverage" --settings CodeCoverage.runsettings /p:SkipBuildVersioning=true
8749
- name: Pack
88-
run: dotnet pack -c Release --no-build /p:Version=${{env.BUILD_VERSION}} /p:PackageOutputPath=${{env.BUILD_ARTIFACT_PATH}}
50+
run: dotnet pack --no-build -c Release /p:PackageOutputPath=${{env.BUILD_ARTIFACT_PATH}}
8951
- name: Publish artifacts
9052
uses: actions/upload-artifact@v2
9153
with:
@@ -115,14 +77,39 @@ jobs:
11577
with:
11678
name: coverage-report
11779
path: Cobertura.xml
118-
119-
release:
120-
name: Release
80+
81+
push-to-github-packages:
82+
name: 'Push GitHub Packages'
83+
needs: build
84+
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
85+
environment:
86+
name: 'GitHub Packages'
87+
url: https://github.com/TurnerSoftware/InfinityCrawler/packages
88+
permissions:
89+
packages: write
12190
runs-on: ubuntu-latest
91+
steps:
92+
- name: 'Download build'
93+
uses: actions/download-artifact@v2
94+
with:
95+
name: 'ubuntu-latest'
96+
- name: 'Add NuGet source'
97+
run: dotnet nuget add source https://nuget.pkg.github.com/TurnerSoftware/index.json --name GitHub --username Turnerj --password ${{secrets.GITHUB_TOKEN}} --store-password-in-clear-text
98+
- name: 'Upload NuGet package'
99+
run: dotnet nuget push *.nupkg --api-key ${{secrets.GH_PACKAGE_REGISTRY_API_KEY}} --source GitHub --skip-duplicate --no-symbols true
100+
101+
push-to-nuget:
102+
name: 'Push NuGet Packages'
122103
needs: build
123104
if: github.event_name == 'release'
105+
environment:
106+
name: 'NuGet'
107+
url: https://www.nuget.org/packages/InfinityCrawler
108+
runs-on: ubuntu-latest
124109
steps:
125-
- name: Download build
126-
uses: actions/download-artifact@v2
127-
- run: ls /ubuntu-latest
128-
# TODO: Upload to NuGet & GitHub Packages
110+
- name: 'Download build'
111+
uses: actions/download-artifact@v2
112+
with:
113+
name: 'ubuntu-latest'
114+
- name: 'Upload NuGet package and symbols'
115+
run: dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key ${{secrets.NUGET_API_KEY}}

InfinityCrawler.sln

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29001.49
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31808.319
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "global", "global", "{F0B4D082-200A-4DD3-9291-872B7F2A991E}"
77
ProjectSection(SolutionItems) = preProject
88
.appveyor.yml = .appveyor.yml
99
.codecov.yml = .codecov.yml
1010
.editorconfig = .editorconfig
1111
.gitignore = .gitignore
12-
build.appveyor.ps1 = build.appveyor.ps1
13-
build.ps1 = build.ps1
14-
buildconfig.json = buildconfig.json
1512
CodeCoverage.runsettings = CodeCoverage.runsettings
1613
License.txt = License.txt
1714
README.md = README.md

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
![Icon](images/icon.png)
44
# Infinity Crawler
5-
A simple but powerful web crawler library in C#
5+
A simple but powerful web crawler library for .NET
66

7-
[![AppVeyor](https://img.shields.io/appveyor/ci/Turnerj/infinitycrawler/master.svg)](https://ci.appveyor.com/project/Turnerj/infinitycrawler)
8-
[![Codecov](https://img.shields.io/codecov/c/github/turnersoftware/infinitycrawler/master.svg)](https://codecov.io/gh/TurnerSoftware/infinitycrawler)
7+
![Build](https://img.shields.io/github/workflow/status/TurnerSoftware/infinitycrawler/Build)
8+
[![Codecov](https://img.shields.io/codecov/c/github/turnersoftware/infinitycrawler/main.svg)](https://codecov.io/gh/TurnerSoftware/infinitycrawler)
99
[![NuGet](https://img.shields.io/nuget/v/InfinityCrawler.svg)](https://www.nuget.org/packages/InfinityCrawler)
1010
</div>
1111

build.appveyor.ps1

-35
This file was deleted.

build.ps1

-58
This file was deleted.

buildconfig.json

-3
This file was deleted.

0 commit comments

Comments
 (0)