Build upgrades #309
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: All packages build | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: | |
- '**/*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/workflows/parts/cache/ | |
- name: Decode the Signing Key | |
# Generated via powershell: `[System.Convert]::ToBase64String((Get-Content '.\OpenApiCodegen.snk' -Encoding Byte)) | Set-Clipboard` and saved to GitHub Secrets SIGNING_KEY | |
run: | | |
if [ -n "${{ secrets.SIGNING_KEY }}" ]; then | |
echo "${{ secrets.SIGNING_KEY }}" | base64 --decode > ./OpenApiCodegen.snk | |
fi | |
########### | |
# BUILD | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: | | |
if [[ $VERSION_SUFFIX ]]; then | |
VERSION_SUFFIX_PARAM="--version-suffix sha.$VERSION_SUFFIX" | |
else | |
VERSION_SUFFIX_PARAM='' | |
fi | |
dotnet build --no-restore --configuration Release ${VERSION_SUFFIX_PARAM} | |
env: | |
VERSION_SUFFIX: ${{ github.ref != 'refs/heads/main' && github.sha || '' }} | |
########### | |
# TEST | |
- name: Test | |
run: dotnet test --no-build --verbosity normal --configuration Release --collect:"XPlat Code Coverage" | |
- name: 'Upload Code Coverage' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: code-coverage | |
path: ./lib/*/TestResults/*/coverage.cobertura.xml | |
retention-days: 7 | |
# - name: Record code coverage | |
# uses: 5monkeys/cobertura-action@master | |
# with: | |
# path: ./lib/*/TestResults/*/coverage.cobertura.xml | |
# repo_token: ${{ secrets.GITHUB_TOKEN }} | |
# minimum_coverage: 90 | |
# fail_below_threshold: false | |
- name: Test MVC examples build | |
if: ${{ github.ref != 'refs/heads/main' }} | |
run: ./examples/dotnetcore-server-interfaces/tooling/build-examples.ps1 -VersionSuffix "sha.$VERSION_SUFFIX" | |
env: | |
VERSION_SUFFIX: ${{ github.ref != 'refs/heads/main' && github.sha || '' }} | |
########### | |
# PUBLISH | |
- name: Publish NuGet packages to GitHub registry if new version number | |
if: ${{ github.ref != 'refs/heads/main' }} | |
run: dotnet nuget push ./artifacts/packages/Release/*.nupkg -k ${GITHUB_TOKEN} -s https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json --skip-duplicate --no-symbols | |
continue-on-error: true # Dependabot and other outside contributors can't push to our GitHub packages | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish NuGet packages to NuGet registry if new version number | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: dotnet nuget push ./artifacts/packages/Release/*.nupkg -k ${NUGET_API_KEY} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols | |
env: | |
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
- name: Set publish NPM registry | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
echo '@principlestudios:registry=$NODE_REGISTRY' > ~/.npmrc | |
env: | |
NODE_REGISTRY: ${{ github.ref != 'refs/heads/main' && 'https://npm.pkg.github.com/' || 'https://registry.npmjs.org/' }} | |
- name: Publish npm packages | |
working-directory: ./artifacts/packages/Release | |
run: | | |
find . -type f -regex ".*\.tgz" -exec npm publish "{}" --access public \; | |
env: | |
NODE_AUTH_TOKEN: "${{ github.ref == 'refs/heads/main' && secrets.NPM_TOKEN || secrets.GITHUB_TOKEN }}" |