feat: add AI (#7) #42
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: Build | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
release: | |
types: | |
- published | |
workflow_dispatch: | |
env: | |
# Disable the .NET logo in the console output. | |
DOTNET_NOLOGO: true | |
# Disable the .NET first time experience to skip caching NuGet packages and speed up the build. | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
# Disable sending .NET CLI telemetry to Microsoft. | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
# Set the build number in MinVer. | |
MINVERBUILDMETADATA: build.${{github.run_number}} | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
name: Build-${{matrix.os}} | |
runs-on: ${{matrix.os}} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v2.4.0 | |
with: | |
lfs: true | |
fetch-depth: 0 | |
- name: "Install .NET SDK" | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 8.0.204 | |
- name: Install Aspire workload | |
run: dotnet workload install aspire | |
- name: "Dotnet Tool Restore" | |
run: dotnet tool restore | |
shell: pwsh | |
- name: "Dotnet Cake Build" | |
run: dotnet cake --target=Build | |
shell: pwsh | |
- name: "Dotnet Cake Test" | |
run: dotnet cake --target=Test | |
shell: pwsh | |
- name: "Dotnet Cake Pack" | |
run: dotnet cake --target=Pack | |
shell: pwsh | |
- name: "Publish Artefacts" | |
uses: actions/upload-artifact@v2.3.1 | |
with: | |
name: ${{matrix.os}} | |
path: "./Artefacts" | |
push-github-container-registry: | |
name: "Push GitHub Container Registry" | |
needs: build | |
if: github.ref == 'refs/heads/main' || github.event_name == 'release' || github.event_name == 'workflow_dispatch' | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to the Container registry | |
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push Docker image | |
id: push | |
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | |
with: | |
context: . | |
file: ./src/Dependify.Cli/Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Generate artifact attestation | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: true | |
push-github-packages: | |
name: "Push GitHub Packages" | |
needs: build | |
if: github.ref == 'refs/heads/main' || github.event_name == 'release' | |
environment: | |
name: "GitHub Packages" | |
url: https://github.com/NikiforovAll/ | |
permissions: | |
packages: write | |
runs-on: windows-latest | |
steps: | |
- name: "Download Artefact" | |
uses: actions/download-artifact@v2.1.0 | |
with: | |
name: "windows-latest" | |
- name: "Dotnet NuGet Add Source" | |
run: dotnet nuget add source https://nuget.pkg.github.com/nikiforovall/index.json --name GitHub --username nikiforovall --password ${{secrets.GITHUB_TOKEN}} | |
shell: pwsh | |
- name: "Dotnet NuGet Push" | |
run: dotnet nuget push .\*.nupkg --api-key ${{ github.token }} --source GitHub --skip-duplicate | |
shell: pwsh | |
push-nuget: | |
name: "Push NuGet Packages" | |
needs: build | |
if: github.event_name == 'release' | |
environment: | |
name: "NuGet" | |
url: https://www.nuget.org/packages/Dependify.Cli | |
runs-on: windows-latest | |
steps: | |
- name: "Download Artefact" | |
uses: actions/download-artifact@v2.1.0 | |
with: | |
name: "windows-latest" | |
- name: "Dotnet NuGet Push" | |
run: | | |
Get-ChildItem .\ -Filter *.nupkg | | |
Where-Object { !$_.Name.Contains('preview') } | | |
ForEach-Object { dotnet nuget push $_ --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key ${{secrets.NUGET_API_KEY}} } | |
shell: pwsh |