Skip to content

publish

publish #87

Workflow file for this run

# Builds a final release version and pushes to nuget.org
# whenever a release is published.
# Requires: secrets.NUGET_API_KEY
name: publish
on:
workflow_dispatch:
release:
types: [prereleased, released] # pre-release
env:
DOTNET_NOLOGO: true
Configuration: Release
PackOnBuild: true
VersionLabel: ${{ github.ref }}
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 🤘 checkout
uses: actions/checkout@v4
- name: ⚙ dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.x
8.x
9.x
- name: 🙏 build
run: dotnet build -m:1
- name: ⚙ azurite
run: |
npm install azurite
npx azurite &
- name: 🧪 test
env:
GH_TOKEN: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
run: dotnet test
- name: 🚀 sleet
env:
SLEET_CONNECTION: ${{ secrets.SLEET_CONNECTION }}
if: env.SLEET_CONNECTION != ''
run: |
dotnet tool update sleet -g --allow-downgrade --version $(curl -s --compressed ${{ vars.SLEET_FEED_URL }} | jq '.["sleet:version"]' -r)
sleet push bin --config none -f --verbose -p "SLEET_FEED_CONTAINER=nuget" -p "SLEET_FEED_CONNECTIONSTRING=${{ secrets.SLEET_CONNECTION }}" -p "SLEET_FEED_TYPE=azure" || echo "No packages found"
- name: 🚀 nuget
if: github.ref_type == 'tag'
working-directory: bin
run: dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} --skip-duplicate
- name: ⬆️ upload
if: success()
uses: actions/upload-artifact@v4
with:
name: pkg
path: bin/*
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: 🤘 checkout
uses: actions/checkout@v4
# Azure App registration with federeted credentials and Storage Blob Data Contributor role in target AZURE_BLOB_URL
# See https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation-create-trust-user-assigned-managed-identity?pivots=identity-wif-mi-methods-azp#github-actions-deploying-azure-resources
- name: 🔓 azure login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: ⚙ func 4.x
run: npm i -g azure-functions-core-tools@4 --unsafe-perm true
- name: 🚀 deploy
working-directory: src/Web
run: func azure functionapp publish sponsorlink --dotnet-isolated