Skip to content

version 1.6.4 test (fix) #10

version 1.6.4 test (fix)

version 1.6.4 test (fix) #10

Workflow file for this run

name: Build and Publish NuGet
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
env:
NUGET_SOURCE_URL: 'https://api.nuget.org/v3/index.json'
GITHUB_PACKAGES_URL: 'https://nuget.pkg.github.com/asv-soft/index.json'
PROJECT_NAME: 'Asv.Gnss'
PROPS_VERSION_VAR_NAME: 'ProductVersion'
jobs:
build:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Add NuGet source
run: dotnet nuget add source ${{ env.GITHUB_PACKAGES_URL }} \--username '${{secrets.USER_NAME}}' \--password '${{secrets.GIHUB_NUGET_AUTH_TOKEN}}' \--store-password-in-clear-text
- name: Install dependencies
run: |
dotnet restore ./src/${{env.PROJECT_NAME}}/${{env.PROJECT_NAME}}.csproj
dotnet restore ./src/${{env.PROJECT_NAME}}.Prometheus/${{env.PROJECT_NAME}}.Prometheus.csproj
- name: Build
run: |
dotnet build ./src/${{env.PROJECT_NAME}}/${{env.PROJECT_NAME}}.csproj --configuration Release --no-restore
dotnet build ./src/${{env.PROJECT_NAME}}.Prometheus/${{env.PROJECT_NAME}}.Prometheus.csproj --configuration Release --no-restore
- name: Set version variable
env:
TAG: ${{ github.ref_name }}
run: echo "VERSION=${TAG#v}" >> $GITHUB_ENV
- name: Read version from Directory.Build.props
id: read-version
run: |
version=$(grep -oP '<${{env.PROPS_VERSION_VAR_NAME}}>\K[^<]+' ./src/Directory.Build.props)
echo "PropsVersion=${version}" >> $GITHUB_ENV
- name: Compare tag with NuGet package version
run: |
if [ "${{ env.PropsVersion }}" != "${{ env.VERSION }}" ]; then
echo "Error: Tag does not match NuGet package version"
exit 1
fi
- name: Tests
run: |
dotnet test ./src/${{env.PROJECT_NAME}}.Tests/${{env.PROJECT_NAME}}.Tests.csproj
- name: Pack package
run: dotnet pack ./src/${{env.PROJECT_NAME}}/${{env.PROJECT_NAME}}.csproj -c Release /p:Version=${VERSION} /p:NuspecFile=Asv.Gnss.nuspec --no-build -o .
- name: List output files
run: ls -la