Skip to content

Publish Lykke Infrastructure NuGet Package #3

Publish Lykke Infrastructure NuGet Package

Publish Lykke Infrastructure NuGet Package #3

name: Publish Lykke Infrastructure NuGet Package
# This workflow is agreed on and requirements are documented
# in https://bit.ly/4529Q9Q.
on:
workflow_dispatch:
inputs:
version:
description: 'Version number (e.g. v1.0.0)'
required: true
default: 'v1.0.0'
create_release:
description: 'Create a GitHub release'
required: true
default: 'true'
update_changelog:
description: 'Update CHANGELOG.md'
required: true
default: 'true'
release_name:
description: 'Release name. If empty, will be extracted from CHANGELOG.md or default value [Release ${VERSION}] will be used'
required: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Checkout deployment tools
run: |
git clone -v https://${{ secrets.BITBUCKET_USER }}:${{ secrets.BITBUCKET_PASSWORD }}@bitbucket.org/lykke-snow/lykke.snow.deployment.git lykke.snow.deployment
- name: Parse version number
uses: LykkeBusiness/.github/actions/parse-version@parse-version-v1
with:
version: ${{ github.event.inputs.version }}
- name: Inject new version into changelog file
if: ${{ github.event.inputs.update_changelog == 'true' }}
uses: LykkeBusiness/.github/actions/inject-version-changelog@inject-version-changelog-v2
with:
version: ${{ env.TAG_NUMBERS }}
- name: Update .csproj files with new version
uses: LykkeBusiness/.github/actions/update-version-csproj@update-version-csproj-v1
with:
version: ${{ env.TAG_NUMBERS }}
# Tags the current commit with the new version
- name: Tag version
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
git add -A
git reset -- lykke.snow.deployment
git commit -m "Version ${{ env.TAG_NUMBERS }}"
git tag -fa ${{ github.event.inputs.version }} -m "${{ github.event.inputs.version }}"
git push origin --tags
git push origin ${{ github.ref }}
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x' # Using .NET 6
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
- name: Pack
run: dotnet pack --no-build --configuration Release -o out
- name: Push
run: dotnet nuget push out/*.nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Extract release notes from changelog file
if: ${{ github.event.inputs.create_release == 'true' }}
uses: LykkeBusiness/.github/actions/extract-notes-changelog@extract-notes-changelog-v1
with:
auto_name_release: true
release_name: ${{ github.event.inputs.release_name }}
version: ${{ env.TAG_NUMBERS }}
# Creates a GitHub release with the release name and release notes from CHANGELOG.md
- name: Create GitHub Release
if: ${{ github.event.inputs.create_release == 'true' }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.version }}
release_name: ${{ env.RELEASE_NAME }}
body_path: ${{ env.RELEASE_NOTES_FILE }}
draft: false
prerelease: false
- name: Clean up temporary files
run: rm -f ${{ env.RELEASE_NOTES_FILE }}