Skip to content

Commit

Permalink
Create releases.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu-Core committed Apr 5, 2024
1 parent f15fe15 commit 8ef1958
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: releases

on:
workflow_dispatch:

env:
DOTNET_NOLOGO: true # Disable the .NET logo
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Disable the .NET first time experience
DOTNET_CLI_TELEMETRY_OPTOUT: true # Disable sending .NET CLI telemetry
DOTNET_VERSION: '8.0'
CSPROJ_FILE_PATH: 'src/Serilog.Sinks.SQLite/Serilog.Sinks.SQLite.csproj'

jobs:
build:
runs-on: ubuntu-latest
steps:
# Checkout the code
- uses: actions/checkout@v3
with:
fetch-depth: 0

# Install .NET SDK
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '${{ env.DOTNET_VERSION }}.x'

# Restore Dependencies
- name: Restore Dependencies
run: dotnet restore ${{ env.CSPROJ_FILE_PATH }}

# Get the commit count and format the version
- name: Get commit count and format version
id: version
shell: bash
run: |
commit_count=$(git rev-list --count HEAD)
major=$((commit_count / 100 + 1))
minor=$((commit_count % 100 / 10))
patch=$((commit_count % 10))
formatted_version="$major.$minor.$patch"
echo "VERSION=$formatted_version" >> $GITHUB_ENV
- name: Build
run: dotnet build ${{ env.CSPROJ_FILE_PATH }} --configuration Release --no-restore

- name: Pack
run: dotnet pack ${{ env.CSPROJ_FILE_PATH }} -p:PackageVersion=${{ env.VERSION }} -c:Release --no-build --output nupkgs

- name: Push NuGet Package
shell: bash
run: dotnet nuget push nupkgs/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_API_KEY}}

0 comments on commit 8ef1958

Please sign in to comment.