Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (asv-drones): add workflow for api to publish packet on GitHub #297

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/ApiReleaseDeployAction.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build and Publish Api NuGet

on:
push:
tags:
- "api-v*"

jobs:
build:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/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: Setup NuGet config
env:
NUGET_USERNAME: ${{ secrets.USER_NAME }}
NUGET_PASSWORD: ${{ secrets.GIHUB_NUGET_AUTH_TOKEN }}
run: |
echo "<configuration>" > nuget.config
echo "<packageSources>" >> nuget.config
echo "<add key=\"nuget.org\" value=\"https://api.nuget.org/v3/index.json\" protocolVersion=\"3\" />" >> nuget.config
echo "<add key=\"asv\" value=\"https://nuget.pkg.github.com/asv-soft/index.json\" />" >> nuget.config
echo "</packageSources>" >> nuget.config
echo "<packageSourceCredentials>" >> nuget.config
echo "<asv>" >> nuget.config
echo "<add key=\"Username\" value=\"$NUGET_USERNAME\" />" >> nuget.config
echo "<add key=\"ClearTextPassword\" value=\"$NUGET_PASSWORD\" />" >> nuget.config
echo "</asv>" >> nuget.config
echo "</packageSourceCredentials>" >> nuget.config
echo "</configuration>" >> nuget.config

- 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: echo "VERSION=${TAG#api-v}" >> $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 }}" != "${{ 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} --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"
7 changes: 7 additions & 0 deletions src/Asv.Drones.Gui.Api/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
<Right>lib/net8.0/Asv.Drones.Gui.Api.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>P:Asv.Drones.Gui.Api.ILocalizationService.Accuracy</Target>
<Left>lib/net8.0/Asv.Drones.Gui.Api.dll</Left>
<Right>lib/net8.0/Asv.Drones.Gui.Api.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>P:Asv.Drones.Gui.Api.ILocalizationService.MAh</Target>
Expand Down