Skip to content
name: Build and Publish Api Github only
on:
push:
tags:
- "dev-api-v*"
jobs:
build:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/dev-api-v')
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.x'
- name: Add NuGet source
run: dotnet nuget add source "https://nuget.pkg.github.com/asv-soft/index.json" \--username '${{secrets.USER_NAME}}' \--password '${{secrets.GIHUB_NUGET_AUTH_TOKEN}}' \--store-password-in-clear-text
- name: Install dependencies
run: dotnet restore ./src/Asv.Drones.Gui.Api/Asv.Drones.Gui.Api.csproj
- name: Build
run: dotnet build ./src/Asv.Drones.Gui.Api/Asv.Drones.Gui.Api.csproj --configuration Release --no-restore
- name: Set version variable
env:
TAG: ${{ github.ref_name }}
run: |
newTag=$(echo $TAG | sed 's/dev-api-v//')
newTag="${newTag}-dev"
echo "VERSION=${newTag}" >> $GITHUB_ENV
- name: Read version from Directory.Build.props
id: read-version
run: echo "::set-output name=version::$(grep -oP '<ApiVersion>\K[^<]+' ./src/Directory.Build.props)"
- name: Compare tag with NuGet package version
run: |
if [ "${{ steps.read-version.outputs.version }}-dev" != "${{ env.VERSION }}" ]; then
echo "Error: Tag does not match NuGet package version"
exit 1
fi
- name: Pack package
run: dotnet pack ./src/Asv.Drones.Gui.Api/Asv.Drones.Gui.Api.csproj -c Release /p:Version=${VERSION}-dev --no-build -o .
- name: List output files
run: ls -la
# - name: Push package to GitHub
# run: dotnet nuget push Asv.Drones.Gui.Api.${VERSION}.nupkg --api-key ${{ secrets.GIHUB_NUGET_AUTH_TOKEN }} --skip-duplicate --source "https://nuget.pkg.github.com/asv-soft/index.json"