Skip to content

Commit dd01189

Browse files
Copilot304NotModifiedCopilot
authored
Move to GitHub Actions (#181)
* Initial plan * Fix solution file path for tests directory Co-authored-by: 304NotModified <[email protected]> * Convert AppVeyor to GitHub Actions with improvements Co-authored-by: 304NotModified <[email protected]> * Fix package creation to match AppVeyor deterministic builds and symbol format Co-authored-by: 304NotModified <[email protected]> * Fix package version to 2.6.0 to match AppVeyor configuration Co-authored-by: 304NotModified <[email protected]> * move version to csproj1 * Update UTF-unknown.csproj * Fix merge conflicts with master branch Co-authored-by: 304NotModified <[email protected]> * Update README badge from AppVeyor to GitHub Actions Co-authored-by: 304NotModified <[email protected]> * change titles * API key to env Co-authored-by: Copilot <[email protected]> * break command line Co-authored-by: Copilot <[email protected]> * zet FileVersion * Fix publish run * fix newlines pack * run single line * 2.0.1 * 2.1 --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: 304NotModified <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent f237cb9 commit dd01189

File tree

7 files changed

+182
-72
lines changed

7 files changed

+182
-72
lines changed

.github/workflows/ci.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
release:
9+
types: [ published ]
10+
11+
env:
12+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
13+
DOTNET_NOLOGO: true
14+
NuGetDirectory: ${{ github.workspace}}/nuget
15+
16+
defaults:
17+
run:
18+
shell: pwsh
19+
20+
jobs:
21+
create_nuget:
22+
runs-on: ubuntu-latest
23+
name: Create NuGet packages
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
28+
29+
- name: Install .NET
30+
uses: actions/setup-dotnet@v4
31+
32+
- name: Cache NuGet packages
33+
uses: actions/cache@v4
34+
with:
35+
path: ~/.nuget/packages
36+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
37+
restore-keys: |
38+
${{ runner.os }}-nuget-
39+
40+
- name: Restore dependencies
41+
run: dotnet restore
42+
43+
- name: Create NuGet package
44+
run: dotnet msbuild -t:Pack src/UTF-unknown.csproj -p:Configuration=Release -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -p:ContinuousIntegrationBuild=true -p:EmbedUntrackedSources=true -p:PackageOutputPath=${{ env.NuGetDirectory }} -verbosity:minimal -p:FileVersion=2.1.${{ github.run_number }}
45+
46+
- name: Upload packages to artifacts
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: nuget
50+
if-no-files-found: error
51+
retention-days: 7
52+
path: ${{ env.NuGetDirectory }}/*
53+
54+
validate_nuget:
55+
runs-on: ubuntu-latest
56+
needs: [ create_nuget ]
57+
steps:
58+
- name: Install .NET
59+
uses: actions/setup-dotnet@v4
60+
61+
- name: Download NuGet package
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: nuget
65+
path: ${{ env.NuGetDirectory }}
66+
67+
- name: Install nuget validator
68+
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
69+
70+
# Validate metadata and content of the NuGet package
71+
# https://www.nuget.org/packages/Meziantou.Framework.NuGetPackageValidation.Tool#readme-body-tab
72+
- name: Validate package
73+
run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg")
74+
75+
run_test:
76+
runs-on: ${{ matrix.os }}
77+
strategy:
78+
matrix:
79+
os: [ ubuntu-latest, windows-latest, macos-latest ]
80+
include:
81+
# Only test on all frameworks on Windows (closest to original AppVeyor setup)
82+
- os: windows-latest
83+
test-framework: ''
84+
# Test only .NET 8.0 on Linux and macOS for efficiency
85+
- os: ubuntu-latest
86+
test-framework: '--framework net8.0'
87+
- os: macos-latest
88+
test-framework: '--framework net8.0'
89+
name: Run tests on ${{ matrix.os }}
90+
steps:
91+
- uses: actions/checkout@v4
92+
93+
- name: Install .NET
94+
uses: actions/setup-dotnet@v4
95+
96+
- name: Cache NuGet packages
97+
uses: actions/cache@v4
98+
with:
99+
path: ~/.nuget/packages
100+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
101+
restore-keys: |
102+
${{ runner.os }}-nuget-
103+
104+
- name: Restore dependencies
105+
run: dotnet restore
106+
107+
- name: Run tests
108+
run: dotnet test --configuration Release --no-restore --logger trx --results-directory "TestResults-${{ matrix.os }}" ${{ matrix.test-framework }}
109+
110+
- name: Upload test results
111+
uses: actions/upload-artifact@v4
112+
if: always()
113+
with:
114+
name: test-results-${{ matrix.os }}
115+
path: TestResults-${{ matrix.os }}/*.trx
116+
117+
deploy:
118+
# Publish only when creating a GitHub Release
119+
# https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository
120+
# You can update this logic if you want to manage releases differently
121+
if: github.event_name == 'release'
122+
runs-on: ubuntu-latest
123+
needs: [ validate_nuget, run_test ]
124+
steps:
125+
- name: Download NuGet package
126+
uses: actions/download-artifact@v4
127+
with:
128+
name: nuget
129+
path: ${{ env.NuGetDirectory }}
130+
131+
- name: Install .NET
132+
uses: actions/setup-dotnet@v4
133+
134+
# Publish the NuGet package to NuGet.org
135+
# To publish to NuGet.org, you need to create an account and generate an API key
136+
# - Create an account on NuGet.org
137+
# - Go to https://www.nuget.org/account/apikeys
138+
# - Create a new API key
139+
# - Copy the API key and add it as a secret in your GitHub repository with the name NUGET_API_KEY
140+
- name: Publish NuGet package to nuget.org
141+
env:
142+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
143+
run: |
144+
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg, *.snupkg)) {
145+
dotnet nuget push $file --source https://api.nuget.org/v3/index.json --skip-duplicate
146+
}

.github/workflows/codeql-analysis.yml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
analyze:
2525
name: Analyze
2626
runs-on: ubuntu-latest
27+
timeout-minutes: 360
2728
permissions:
2829
actions: read
2930
contents: read
@@ -33,39 +34,43 @@ jobs:
3334
fail-fast: false
3435
matrix:
3536
language: [ 'csharp' ]
36-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37-
# Learn more:
38-
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
37+
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
38+
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
39+
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
40+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
3941

4042
steps:
4143
- name: Checkout repository
42-
uses: actions/checkout@v2
44+
uses: actions/checkout@v4
4345

4446
# Initializes the CodeQL tools for scanning.
4547
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@v1
48+
uses: github/codeql-action/init@v3
4749
with:
4850
languages: ${{ matrix.language }}
4951
# If you wish to specify custom queries, you can do so here or in a config file.
5052
# By default, queries listed here will override any specified in a config file.
5153
# Prefix the list here with "+" to use these queries and those in the config file.
52-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
54+
55+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
56+
# queries: security-extended,security-and-quality
5357

54-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
58+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
5559
# If this step fails, then you should remove it and run the build manually (see below)
5660
- name: Autobuild
57-
uses: github/codeql-action/autobuild@v1
61+
uses: github/codeql-action/autobuild@v3
5862

5963
# ℹ️ Command-line programs to run using the OS shell.
60-
# 📚 https://git.io/JvXDl
64+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
6165

62-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63-
# and modify them (or add more) to build your code if your project
64-
# uses a compiled language
66+
# If the Autobuild fails above, remove it and uncomment the following three lines.
67+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
6568

66-
#- run: |
67-
# make bootstrap
68-
# make release
69+
# - run: |
70+
# echo "Run, Build Application using script"
71+
# ./location_of_script_within_repo/buildscript.sh
6972

7073
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v1
74+
uses: github/codeql-action/analyze@v3
75+
with:
76+
category: "/language:${{matrix.language}}"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
# Drafts your next Release notes as Pull Requests are merged into "master"
14-
- uses: release-drafter/release-drafter@v5
14+
- uses: release-drafter/release-drafter@v6
1515
env:
1616
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build status](https://ci.appveyor.com/api/projects/status/xr59ab52cav8vuph/branch/master?svg=true)](https://ci.appveyor.com/project/304NotModified/utf-unknown/branch/master)
1+
[![CI/CD](https://github.com/CharsetDetector/UTF-unknown/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/CharsetDetector/UTF-unknown/actions/workflows/ci.yml)
22
[![NuGet Pre Release](https://img.shields.io/nuget/vpre/UTF.Unknown.svg)](https://www.nuget.org/packages/UTF.Unknown/)
33

44
<!--
@@ -23,7 +23,7 @@ Features:
2323
- New API
2424
- Moved to .NET Standard
2525
- Added more unit tests
26-
- Builds on CI (AppVeyor)
26+
- Builds on CI (GitHub Actions)
2727
- Strong named
2828
- Documentation added
2929
- Multiple bugs from Ude fixed

UTF-unknown.sln

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UTF-unknown", "src\UTF-unkn
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleExample", "example\ConsoleExample.csproj", "{386C6ABF-44EA-4418-B90E-E8D21E4C2475}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UTF-unknown.Tests", "Tests\UTF-unknown.Tests.csproj", "{1922DCC9-A45F-4627-9087-CD492BBF7F38}"
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UTF-unknown.Tests", "tests\UTF-unknown.Tests.csproj", "{1922DCC9-A45F-4627-9087-CD492BBF7F38}"
1111
EndProject
1212
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{089100B1-113F-4E66-888A-E83F3999EAFD}"
1313
ProjectSection(SolutionItems) = preProject
1414
.editorconfig = .editorconfig
15-
appveyor.yml = appveyor.yml
1615
Directory.Build.props = Directory.Build.props
1716
README.md = README.md
1817
EndProjectSection

appveyor.yml

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

src/UTF-unknown.csproj

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
<PropertyGroup>
99
<AssemblyName>UtfUnknown</AssemblyName>
1010
<PackageId>UTF.Unknown</PackageId>
11-
<Version>2.0.0</Version>
12-
<!-- patched in AppVeyor.yml -->
11+
<Version>2.6.0</Version>
1312
<DebugType Condition=" '$(Configuration)' == 'Debug' ">Full</DebugType>
1413
</PropertyGroup>
1514

@@ -85,15 +84,16 @@ Features:
8584

8685
<PropertyGroup>
8786
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\UtfUnknown.xml</DocumentationFile>
88-
<NoWarn>1701;1702;1705,1570,1591</NoWarn>
89-
<AssemblyVersion>2.0.0.0</AssemblyVersion>
90-
<FileVersion>2.0.0.0</FileVersion>
91-
</PropertyGroup>
92-
93-
<ItemGroup>
94-
<None Include="..\logo.png" Pack="true" PackagePath="\" />
95-
<None Include="..\README.md" Pack="true" PackagePath="\" />
96-
</ItemGroup>
87+
<NoWarn>1701;1702;1705,1570,1591</NoWarn>
88+
<!-- Only change AssemblyVersion for major versions -->
89+
<AssemblyVersion>2.0.0.0</AssemblyVersion>
90+
<FileVersion>2.0.0.0</FileVersion>
91+
</PropertyGroup>
92+
93+
<ItemGroup>
94+
<None Include="..\logo.png" Pack="true" PackagePath="\" />
95+
<None Include="..\README.md" Pack="true" PackagePath="\" />
96+
</ItemGroup>
9797

9898
</Project>
9999

0 commit comments

Comments
 (0)