Skip to content

Commit

Permalink
Initial commit 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
slang25 committed Oct 10, 2024
0 parents commit 2c9c8d6
Show file tree
Hide file tree
Showing 70 changed files with 7,114 additions and 0 deletions.
156 changes: 156 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: build

on:
push:
branches: [ main ]
tags: [ v* ]
pull_request:
branches: [ main, dotnet-vnext ]
workflow_dispatch:

env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
NUGET_XMLDOC_MODE: skip
TERM: xterm

permissions:
contents: read

jobs:
build:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}

outputs:
dotnet-sdk-version: ${{ steps.setup-dotnet.outputs.dotnet-version }}

permissions:
attestations: write
contents: write
id-token: write

strategy:
fail-fast: false
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
include:
- os: macos-latest
os-name: macos
- os: ubuntu-latest
os-name: linux
- os: windows-latest
os-name: windows

steps:

- name: Checkout code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Setup .NET SDK
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
id: setup-dotnet

- name: Setup NuGet cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props') }}
restore-keys: ${{ runner.os }}-nuget-

- name: Build, Test and Package
shell: pwsh
run: ./build.ps1

- uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
name: Upload coverage to Codecov
with:
file: ./artifacts/coverage/coverage.cobertura.xml
flags: ${{ matrix.os-name }}
token: ${{ secrets.CODECOV_TOKEN }}

# - name: Generate SBOM
# uses: anchore/sbom-action@61119d458adab75f756bc0b9e4bde25725f86a7a # v0.17.2
# with:
# artifact-name: build-${{ matrix.os-name }}.spdx.json
# output-file: ./artifacts/build.spdx.json
# path: ./artifacts/bin
# upload-release-assets: ${{ runner.os == 'Windows' }}

- name: Attest artifacts
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
if: |
runner.os == 'Windows' &&
github.event.repository.fork == false &&
(github.ref_name == github.event.repository.default_branch || startsWith(github.ref, 'refs/tags/v'))
with:
subject-path: |
./artifacts/bin/LocalSqsSnsMessaging/release*/LocalSqsSnsMessaging.dll
./artifacts/package/release/*
- name: Publish artifacts
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: artifacts-${{ matrix.os-name }}
path: ./artifacts

- name: Publish NuGet packages
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: packages-${{ matrix.os-name }}
path: ./artifacts/package/release
if-no-files-found: error

validate-packages:
needs: build
runs-on: ubuntu-latest
steps:

- name: Download packages
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: packages-windows

- name: Setup .NET SDK
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
with:
dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }}

- name: Validate NuGet packages
shell: pwsh
run: |
dotnet tool install --global dotnet-validate --version 0.0.1-preview.304
$packages = Get-ChildItem -Filter "*.nupkg" | ForEach-Object { $_.FullName }
$invalidPackages = 0
foreach ($package in $packages) {
dotnet validate package local $package
if ($LASTEXITCODE -ne 0) {
$invalidPackages++
}
}
if ($invalidPackages -gt 0) {
Write-Output "::error::$invalidPackages NuGet package(s) failed validation."
exit 1
}
publish-nuget:
needs: [ build, validate-packages ]
runs-on: ubuntu-latest
if: |
github.event.repository.fork == false &&
startsWith(github.ref, 'refs/tags/v')
steps:

- name: Download packages
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: packages-windows

- name: Setup .NET SDK
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
with:
dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }}

- name: Push NuGet packages to NuGet.org
run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_TOKEN }} --skip-duplicate --source https://api.nuget.org/v3/index.json
76 changes: 76 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: release

on:
workflow_dispatch:
inputs:
publish:
description: 'If true, does not create the release as a draft.'
required: false
type: boolean
default: false

permissions: {}

jobs:
release:
runs-on: [ ubuntu-latest ]

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false

permissions:
contents: write
issues: write

steps:

- name: Checkout code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Get version
id: get-version
shell: pwsh
run: |
$properties = Join-Path "." "Directory.Build.props"
$xml = [xml](Get-Content $properties)
$version = $xml.SelectSingleNode('Project/PropertyGroup/VersionPrefix').InnerText
"version=${version}" >> $env:GITHUB_OUTPUT
- name: Create release
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
DRAFT: ${{ inputs.publish != true }}
VERSION: ${{ steps.get-version.outputs.version }}
with:
script: |
const { repo, owner } = context.repo;
const draft = process.env.DRAFT === 'true';
const version = process.env.VERSION;
const tag_name = `v${version}`;
const name = tag_name;
const { data: notes } = await github.rest.repos.generateReleaseNotes({
owner,
repo,
tag_name,
target_commitish: process.env.DEFAULT_BRANCH,
});
const body = notes.body
.split('\n')
.filter((line) => !line.includes(' @dependabot '))
.filter((line) => !line.includes(' @github-actions '))
.join('\n');
const { data: release } = await github.rest.repos.createRelease({
owner,
repo,
tag_name,
name,
body,
draft,
});
core.notice(`Created release ${release.name}: ${release.html_url}`);
Loading

0 comments on commit 2c9c8d6

Please sign in to comment.