Skip to content

Add Grass to Cedar Forest WIP #79

Add Grass to Cedar Forest WIP

Add Grass to Cedar Forest WIP #79

Workflow file for this run

name: release
on:
push:
branches:
- "main"
tags:
- "*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set VERSION variable
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
# For tag pushes, use the tag version directly
VERSION=${GITHUB_REF/refs\/tags\//}
else
git fetch --tags # Ensure all tags are fetched
# Get the latest base tag (e.g., "0.1.0")
LATEST_TAG=$(git describe --tags --abbrev=0)
# Get the current week using Monday as the first day
WEEK=$(date +'%W')
WEEK=$((10#$WEEK))
YEAR=$(date +'%Y')
# Calculate Monday of the current week (works on GNU date)
MONDAY=$(date -d "today - $(($(date +%u)-1)) days" +%Y-%m-%d)
# Count the number of commits made since Monday
BUILD_NUMBER=$(git rev-list --count HEAD --since="$MONDAY")
# Construct the version string with the commit count as the build number
VERSION="${LATEST_TAG}-preview.${YEAR}.${WEEK}.${BUILD_NUMBER}"
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build /p:CiVersion=${VERSION} --configuration Release --no-restore
- name: Pack
run: dotnet pack --configuration Release --no-build --output bin
- name: Push (allow overwriting)
run: dotnet nuget push bin/*.nupkg --source="https://api.nuget.org/v3/index.json" --api-key ${{secrets.NUGET_API_KEY}}