Build packages and store artifacts #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build packages and store artifacts | |
on: | |
workflow_dispatch: | |
inputs: | |
version-suffix: | |
type: string | |
description: 'semver version suffix' | |
required: false | |
default: 'Test-DATE-TIME' | |
workflow_call: | |
inputs: | |
version-suffix: | |
type: string | |
description: 'semver version suffix' | |
required: true | |
default: 'Test-DATE-TIME' | |
jobs: | |
build_job: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
# --------------------------------------------- variables | |
- name: Define SemVer suffix | |
run: | | |
SEMVERSUFFIX="${{ inputs.version-suffix }}" | |
# replace DATE | |
DATE_SHORT=$(date +'%Y%m%d') | |
if [[ "SEMVERSUFFIX" == *"$DATE"* ]]; then | |
SEMVERSUFFIX="${SEMVERSUFFIX/DATE/$DATE_SHORT}" | |
fi | |
# replace TIME | |
TIME_SHORT=$(date +'%H%M%S') | |
if [[ "SEMVERSUFFIX" == *"$TIME"* ]]; then | |
SEMVERSUFFIX="${SEMVERSUFFIX/TIME/$TIME_SHORT}" | |
fi | |
# emit env variable | |
echo "SEMVERSUFFIX=$SEMVERSUFFIX" >> $GITHUB_ENV | |
echo ${{ env.SEMVERSUFFIX }} | |
# --------------------------------------------- DotNet SDK | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v4 | |
# --------------------------------------------- checkout repo | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# --------------------------------------------- build | |
- name: Install tools | |
run: dotnet tool restore | |
- name: Install dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build -c Release --version-suffix ${{ env.SEMVERSUFFIX }} --verbosity diagnostic | |
- 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 |