This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-markdown-cil/scripts/release.sh

56 lines
1.6 KiB
Bash
Raw Normal View History

2022-09-06 03:37:35 +00:00
#!/usr/bin/env sh
# Set up logging.
log() { echo "️🚢 $(basename $0): $@"; }
# Move into the root folder and make sure we're set up.
2022-09-06 03:37:35 +00:00
cd $(dirname $0)/..
./scripts/setup.sh || exit 1
# Verify the input.
if [ "x$GITEA_TOKEN" = "x" ]
then
log "the environment variable GITEA_TOKEN is not defined"
2022-09-06 03:37:35 +00:00
exit 1
fi
# Clean up everything from the previous runs.
log "cleaning project"
2022-09-06 03:37:35 +00:00
dotnet clean
# Version the file based on the Git repository.
log "setting project version"
2022-09-06 03:37:35 +00:00
(cd src && dotnet dotnet-gitversion /updateprojectfiles)
SEMVER="v$(dotnet gitversion /output json | jq -r .SemVer)"
if [ "x$SEMVER" = "x" ]
then
log "cannot figure out the semantic version"
2022-09-06 03:37:35 +00:00
exit 1
fi
# Build to pick up the new version.
log "building project $SEMVER"
2022-09-06 03:37:35 +00:00
dotnet build || exit 1
# Create and publish the NuGet packages.
log "creating NuGet packages"
2022-09-06 03:37:35 +00:00
dotnet pack -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg || exit 1
log "publishing NuGet package"
2022-09-06 03:37:35 +00:00
dotnet nuget remove source mfgames.com >& /dev/null
dotnet nuget add source --name mfgames.com --username dmoonfire --password $GITEA_TOKEN https://src.mfgames.com/api/packages/mfgames-cil/nuget/index.json --store-password-in-clear-text || exit 1
dotnet nuget push --skip-duplicate --source mfgames.com src/*/bin/Debug/*.nupkg || exit 1
# Tag and push, but only if we don't have a tag.
if ! git tag | grep $SEMVER >& /dev/null
then
log "tagging and pushing"
2022-09-06 03:37:35 +00:00
git remote add publish https://dmoonfire:$GITEA_TOKEN@src.mfgames.com/mfgames-cil/$(basename $(git config --get remote.origin.url))
git tag $SEMVER
git push publish $SEMVER || exit 1
git remote remove publish
else
log "not tagging, already exists"
2022-09-06 03:37:35 +00:00
fi