Skip to content

Commit

Permalink
ci: switch fully to GitHub actions instead of AppVeyor
Browse files Browse the repository at this point in the history
  • Loading branch information
skwasjer committed Nov 18, 2023
1 parent d0e41c2 commit 0ebc211
Show file tree
Hide file tree
Showing 16 changed files with 364 additions and 155 deletions.
32 changes: 32 additions & 0 deletions .github/actions/download-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Download artifact
description: Wrapper around GitHub's official action, with additional extraction before download

# https://github.com/actions/download-artifact/blob/main/action.yml
# https://github.com/actions/upload-artifact/issues/199
inputs:
name:
description: Artifact name
required: true
path:
description: Destination path
required: false
default: .

runs:
using: composite
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ${{ inputs.name }}
path: ${{ inputs.path }}

- name: Extract artifacts
run: tar -xvf ${{ inputs.name }}.tar
shell: bash
working-directory: ${{ inputs.path }}

- name: Remove archive
run: rm -f ${{ inputs.name }}.tar
shell: bash
working-directory: ${{ inputs.path }}
47 changes: 47 additions & 0 deletions .github/actions/upload-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Upload artifact
description: Wrapper around GitHub's official action, with additional archiving before upload

# https://github.com/actions/upload-artifact/blob/main/action.yml
# https://github.com/actions/upload-artifact/issues/199
inputs:
name:
description: Artifact name
required: true
path:
description: One or more files, directories or wildcard pattern that describes what to upload
required: true
if-no-files-found:
description: >
The desired behavior if no files are found using the provided path.
Available Options:
warn: Output a warning but do not fail the action
error: Fail the action with an error message
ignore: Do not output any warnings or errors, the action does not fail
required: false
default: warn
retention-days:
description: >
Duration after which artifact will expire in days. 0 means using default retention.
Minimum 1 day.
Maximum 90 days unless changed from the repository settings page.
required: false
default: '0'

runs:
using: composite
steps:
- name: Archive artifacts
run: tar -cv -I 'xz -0 -T0' -f ${{ inputs.name }}.tar $(echo "${{ inputs.path }}" | tr '\n' ' ')
shell: bash

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
if-no-files-found: ${{ inputs.if-no-files-found }}
name: ${{ inputs.name }}
path: ${{ inputs.name }}.tar
retention-days: ${{ inputs.retention-days }}

- name: Remove archive
run: rm -f ${{ inputs.name }}.tar
shell: bash
33 changes: 18 additions & 15 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ on:
schedule:
- cron: '0 7 * * 6'

env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
dotnet-version: |
8.0.x
7.0.x
6.0.x
5.0.x
3.1.x
2.1.x
jobs:
analyze:
name: Analyze
Expand All @@ -38,25 +49,17 @@ jobs:
# 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

steps:
- uses: actions/checkout@v3
# Setup
- uses: actions/setup-dotnet@v3
with:
dotnet-version: |
7.0.x
6.0.x
5.0.x
3.1.x
2.1.x
dotnet-version: ${{ env.dotnet-version }}

- name: dotnet info
run: dotnet --info
- run: dotnet --info

# https://github.com/actions/runner-images/blob/ubuntu22/20230821.1/images/linux/Ubuntu2204-Readme.md
# There is an issue with latest SDK on Linux with .NET Framework:
# https://github.com/microsoft/vstest/issues/4549
# Unfortunatey, it becomes preinstalled with latest GitHub runner images, so have to remove it for now.
- name: Remove latest .NET SDK (7.0.400)
run: sudo rm -rf ${DOTNET_ROOT}/sdk/7.0.400
# Checkout
- uses: actions/checkout@v4
with:
fetch-depth: 1

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/dotnetcore.yml

This file was deleted.

191 changes: 191 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
on:
push:
branches:
- main
release:
types:
- published
pull_request:

name: pipeline
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
dotnet-version: |
8.0.x
7.0.x
6.0.x
5.0.x
3.1.x
2.1.x
jobs:
determine-version:
runs-on: ubuntu-latest
env:
IGNORE_NORMALISATION_GIT_HEAD_MOVE: 1
# v5.10.0 of GitVersion has a fix for incorrect versions when building on tag. See https://github.com/GitTools/GitVersion/issues/2838
# It appears that the fix then had a regression in a later version, so pinning to v5.10.0. See https://github.com/GitTools/GitVersion/issues/3351#issuecomment-1403657689
GITVERSION: '5.10.0'
outputs:
version: ${{ steps.gitversion.outputs.fullSemVer }}
package-version: ${{ steps.gitversion.outputs.fullSemVer }}
assembly-version: ${{ steps.gitversion.outputs.assemblySemVer }}
file-version: ${{ steps.gitversion.outputs.assemblySemFileVer }}
informational-version: ${{ steps.gitversion.outputs.informationalVersion }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Install GitVersion ${{ env.GITVERSION }}
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: ${{ env.GITVERSION }}

- name: Determine version
uses: gittools/actions/gitversion/[email protected]
id: gitversion
with:
useConfigFile: true

build:
needs:
- determine-version
name: build (v${{ needs.determine-version.outputs.version }})
runs-on: ubuntu-latest
env:
msbuild-version-args: /p:Version="${{ needs.determine-version.outputs.version }}" /p:PackageVersion="${{ needs.determine-version.outputs.package-version }}" /p:AssemblyVersion="${{ needs.determine-version.outputs.assembly-version }}" /p:FileVersion="${{ needs.determine-version.outputs.file-version }}" /p:InformationalVersion="${{ needs.determine-version.outputs.informational-version }}"
outputs:
dotnet-version: ${{ env.dotnet-version }}
msbuild-version-args: ${{ env.msbuild-version-args }}
steps:
# Setup
- uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.dotnet-version }}

- run: dotnet --info

# Checkout
- uses: actions/checkout@v4
with:
fetch-depth: 1

# NuGet cache
- name: Restore NuGet global package cache
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.targets','**/*.props','**/*.csproj') }} # Can't use packages.lock.json yet, because Dependabot does not support it.
restore-keys: |
${{ runner.os }}-nuget-
# Restore
- run: dotnet restore

# Build
- run: dotnet build --no-restore -c Release ${{ env.msbuild-version-args }}
- name: Upload build artifacts
uses: ./.github/actions/upload-artifact
with:
name: build
path: |
*/**/bin
*/**/obj
if-no-files-found: error
retention-days: 7

test:
needs: build
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
# Setup
- uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.dotnet-version }}

# Checkout
- uses: actions/checkout@v4
with:
fetch-depth: 1

# Restore build artifacts
- name: Download build artifacts
uses: ./.github/actions/download-artifact
with:
name: build

# Run all tests
- run: dotnet test --no-restore --no-build -c Release

pack:
needs:
- determine-version
- build
runs-on: ubuntu-latest
steps:
# Setup
- uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.dotnet-version }}

# Checkout
- uses: actions/checkout@v4
with:
fetch-depth: 1

# NuGet cache (.NET Framework Reference assemblies are needed for pack)
- name: Restore NuGet global package cache
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.targets','**/*.props','**/*.csproj') }} # Can't use packages.lock.json yet, because Dependabot does not support it.
restore-keys: |
${{ runner.os }}-nuget-
fail-on-cache-miss: true

# Restore build artifacts
- name: Download build artifacts
uses: ./.github/actions/download-artifact
with:
name: build

# Pack
- run: dotnet pack --no-restore --no-build -c Release ${{ needs.build.outputs.msbuild-version-args }}
- name: Upload release artifacts
uses: actions/upload-artifact@v3
with:
name: release-${{ needs.determine-version.outputs.package-version }}
path: |
**/*.*nupkg
if-no-files-found: error
retention-days: 90

deploy:
needs:
- determine-version
- test
- pack
if: github.event_name == 'release'
environment: production
runs-on: ubuntu-latest
steps:
# Restore release artifacts
- name: Download release artifact
uses: actions/download-artifact@v3
with:
name: release-${{ needs.determine-version.outputs.package-version }}

- name: push - nuget.org
env:
NUGET_SOURCE_URL: https://api.nuget.org/v3/index.json
run: dotnet nuget push **/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s ${{ env.NUGET_SOURCE_URL }}
Loading

0 comments on commit 0ebc211

Please sign in to comment.