Skip to content

Build packages and store artifacts #15

Build packages and store artifacts

Build packages and store artifacts #15

Workflow file for this run

name: Build packages and store artifacts
on:
workflow_dispatch:
inputs:
package-version:
type: string
description: 'package version'
required: false
default: '1.0.0-Test-DATE-TIME'
workflow_call:
inputs:
package-version:
type: string
description: 'package version'
required: true
default: '1.0.0-Test-DATE-TIME'
jobs:
build_job:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
# --------------------------------------------- DotNet SDK
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
# --------------------------------------------- checkout repo
- name: Checkout
uses: actions/checkout@v4
# --------------------------------------------- variables
- name: Define SemVer suffix
run: |
PACKAGEVERSION="${{ inputs.package-version }}"
# replace DATE
DATE_SHORT=$(date +'%Y%m%d')
if [[ "PACKAGEVERSION" == *"$DATE"* ]]; then
PACKAGEVERSION="${PACKAGEVERSION/DATE/$DATE_SHORT}"
fi
# replace TIME
TIME_SHORT=$(date +'%H%M%S')
if [[ "PACKAGEVERSION" == *"$TIME"* ]]; then
PACKAGEVERSION="${PACKAGEVERSION/TIME/$TIME_SHORT}"
fi
# emit env variable
echo "PACKAGEVERSION=PACKAGEVERSION" >> $GITHUB_ENV
echo ${{ env.PACKAGEVERSION }}
# --------------------------------------------- build
- name: Install tools
run: dotnet tool restore
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build -c Release /p:Version=1.0.0-${{ env.PACKAGEVERSION }}
- name: Pack
run: dotnet pack -c Release --no-build --output "."
# --------------------------------------------- publish
- name: Archive
uses: actions/upload-artifact@v4
with:
name: nuget-packages
retention-days: 1
path: |
*.nupkg
*.snupkg