Skip to content

Build packages and store artifacts #18

Build packages and store artifacts

Build packages and store artifacts #18

Workflow file for this run

name: Build packages and store artifacts
on:
workflow_dispatch:
inputs:
nuget-semver:
type: string
description: 'package version'
required: false
default: '1.0.0-Test-DATE-TIME'
workflow_call:
inputs:
nuget-semver:
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: |
NUGETSEMVER="${{ inputs.nuget-semver }}"
# replace DATE
DATE_SHORT=$(date +'%Y%m%d')
if [[ "NUGETSEMVER" == *"$DATE"* ]]; then
NUGETSEMVER="${NUGETSEMVER/DATE/$DATE_SHORT}"
fi
# replace TIME
TIME_SHORT=$(date +'%H%M%S')
if [[ "NUGETSEMVER" == *"$TIME"* ]]; then
NUGETSEMVER="${NUGETSEMVER/TIME/$TIME_SHORT}"
fi
# emit env variable
echo "NUGETSEMVER=$NUGETSEMVER" >> $GITHUB_ENV
echo ${{ env.NUGETSEMVER }}
# --------------------------------------------- build
- name: Install tools
run: dotnet tool restore
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build -c Release /p:Version=${{ env.NUGETSEMVER }}
- 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