Skip to content

Commit

Permalink
build pipeline: change verson creation and remove nuget artifact uplo…
Browse files Browse the repository at this point in the history
…ad to github
  • Loading branch information
petar-m committed Dec 29, 2023
1 parent dc20192 commit 8017d4e
Showing 1 changed file with 24 additions and 28 deletions.
52 changes: 24 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- "*.drawio"
- ".gitignore"
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
- '[0-9]+.[0-9]+.[0-9]+(-.*)'
pull_request:
branches: [ main ]
paths-ignore:
Expand All @@ -23,8 +23,7 @@ jobs:
build:

runs-on: ubuntu-latest
env:
IS_TAG: ${{ startsWith(github.ref, 'refs/tags/') }}

permissions:
id-token: write
contents: read
Expand All @@ -37,18 +36,29 @@ jobs:
- id: set-version
name: Set Version
run: |
if ${IS_TAG} == true; then
version=$(echo ${{ github.ref }} | cut -c 11-)
echo "VERSION=$version" >> $GITHUB_ENV
ref=${{ github.ref }}
pattern="^refs/tags/[0-9]+.[0-9]+.[0-9]+(-.*)$"
if [[ $ref =~ $pattern ]]; then
is_release=true
else
is_release=false
fi
echo "IS_RELEASE=$is_release" >> $GITHUB_ENV
if $IS_RELEASE == true; then
version=$(echo $ref | cut -c 11-)
else
version="$(date +'%Y').$(date +'%m').$(date +'%d').$(date +'%H%M')"
echo "VERSION=$version" >> $GITHUB_ENV
version="0.0.1-build$(date +'%Y%m%d'-'%H%M%S')"
fi
echo "VERSION=$version" >> $GITHUB_ENV
- id: print-version
name: Print Version
run: |
echo "is tag: $IS_TAG"
echo "is release: ${{ env.IS_RELEASE }}"
echo "version: ${{ env.VERSION }}"
- name: Setup .NET
Expand All @@ -74,25 +84,11 @@ jobs:
reporter: dotnet-trx

- name: Create NuGet Package
if: ${{ env.IS_TAG == 'true' }}
if: success() && ${{ env.IS_RELEASE == 'true' }}
run: dotnet pack src/M.EventBrokerSlim/M.EventBrokerSlim.csproj -p:PackageVersion=${{ env.VERSION }} --output ./ --configuration Release --no-restore --no-build -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg

- name: Upload a Nuget Package Build Artifact
if: ${{ env.IS_TAG == 'true' }}
uses: actions/upload-artifact@v2.2.4
with:
name: NuGet package
path: ./*.nupkg
retention-days: 1

- name: Upload a Nuget Symbols Package Build Artifact
if: ${{ env.IS_TAG == 'true' }}
uses: actions/upload-artifact@v2.2.4
with:
name: NuGet symbols package
path: ./*.snupkg
retention-days: 1

- name: Publish NuGet Package
if: ${{ env.IS_TAG == 'true' }}
run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API }} -s https://api.nuget.org/v3/index.json
if: success() && ${{ env.IS_RELEASE == 'true' }}
# run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API }} -s https://api.nuget.org/v3/index.json
run: |
echo "ulpoading package"

0 comments on commit 8017d4e

Please sign in to comment.