Skip to content

Commit b362852

Browse files
authored
Migrate to GitHub CI workflow (#201)
1 parent 28bd9c5 commit b362852

2 files changed

Lines changed: 106 additions & 72 deletions

File tree

.github/workflows/ci.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
tags: [ 'v*' ]
7+
paths-ignore:
8+
- '*.md'
9+
- '*.txt'
10+
- '.git*'
11+
pull_request:
12+
branches: [ master ]
13+
paths-ignore:
14+
- '*.md'
15+
- '*.txt'
16+
- '.git*'
17+
18+
env:
19+
CONFIGURATION: Release
20+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
21+
DOTNET_CLI_TELEMETRY_OPTOUT: true
22+
23+
jobs:
24+
build:
25+
strategy:
26+
matrix:
27+
os: [windows-2022, ubuntu-22.04]
28+
runs-on: ${{ matrix.os }}
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Setup .NET
37+
uses: actions/setup-dotnet@v4
38+
with:
39+
global-json-file: global.json
40+
dotnet-version: '6.0.x'
41+
42+
- name: Display .NET info
43+
run: dotnet --info
44+
45+
- name: Restore tools
46+
run: dotnet tool restore
47+
48+
- name: Build
49+
run: dotnet build --configuration ${{ env.CONFIGURATION }}
50+
51+
- name: Pack (Windows only)
52+
if: runner.os == 'Windows'
53+
shell: pwsh
54+
run: |
55+
$commitTimestamp = git log -1 --format=%cI
56+
if ($LASTEXITCODE) { throw "Failed to get commit timestamp" }
57+
$versionSuffix = ([datetimeoffset]$commitTimestamp).ToUniversalTime().ToString('yyyyMMdd''t''HHmm')
58+
59+
$releaseNotesFile = [System.IO.Path]::GetTempFileName()
60+
$tag = '${{ github.ref_name }}'
61+
$isTag = '${{ github.ref_type }}' -eq 'tag'
62+
63+
# if the tag starts with "v", as in "v1.0.0", assume it's a release
64+
if ($isTag -and $tag -clike 'v*') {
65+
$url = '${{ github.server_url }}/${{ github.repository }}'
66+
Add-Content $releaseNotesFile -Encoding UTF8 "See: ${url}/releases/tag/$tag"
67+
Add-Content $releaseNotesFile -Encoding UTF8 ''
68+
# if tag ends in "-" followed by dot-separated identifiers...
69+
if ($tag -match '(?<=-)[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$') {
70+
$versionSuffix = $matches[0] # ...then use as suffix for pre-release
71+
} else {
72+
$versionSuffix = $null # ... else use no suffix for a release
73+
}
74+
}
75+
76+
Add-Content $releaseNotesFile -Encoding UTF8 "Commit @ ${{ github.sha }}"
77+
$packArgs = @()
78+
if ($versionSuffix) {
79+
$packArgs += @('--version-suffix', $versionSuffix)
80+
}
81+
dotnet pack --no-build --configuration ${{ env.CONFIGURATION }} @packArgs "-p:PackageReleaseNotesFile=$releaseNotesFile"
82+
if ($LASTEXITCODE) { throw "Pack failed" }
83+
84+
Get-ChildItem -File -Filter docopt.net.*.nupkg dist |
85+
Select-Object -ExpandProperty FullName |
86+
ForEach-Object { dotnet sourcelink test $_; if ($LASTEXITCODE) { throw "SourceLink test failed for $_" } }
87+
88+
- name: Test
89+
run: dotnet test --no-build --configuration ${{ env.CONFIGURATION }}
90+
91+
- name: Integration Tests (Windows)
92+
if: runner.os == 'Windows'
93+
shell: pwsh
94+
run: ./tests/Integration/run.ps1 -NoPack
95+
96+
- name: Integration Tests (Linux)
97+
if: runner.os == 'Linux'
98+
shell: pwsh
99+
run: ./tests/Integration/run.ps1
100+
101+
- name: Upload NuGet packages
102+
if: runner.os == 'Windows'
103+
uses: actions/upload-artifact@v4
104+
with:
105+
name: NuGet
106+
path: dist/*.nupkg

appveyor.yml

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

0 commit comments

Comments
 (0)