fix(ci): bumping version to test Woodpecker CI

This commit is contained in:
D. Moonfire 2022-09-02 10:07:38 -05:00
parent c3c3d60e5f
commit cf06d4cd3d
4 changed files with 46 additions and 54 deletions

View file

@ -1,45 +0,0 @@
include:
- template: Security/SAST.gitlab-ci.yml
stages:
- build
- test
- release
default:
image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest
build:
stage: build
script:
- nix develop --command scripts/build.sh
rules:
- if: $CI_COMMIT_BRANCH
test:
stage: test
script:
- nix develop --command scripts/test.sh
artifacts:
when: always
paths:
- ./**/*test-result.xml
- ./coverage/Cobertura.xml
- ./coverage/Summary.*
- ./**/*.nupkg
reports:
junit:
- ./**/*test-result.xml
cobertura:
- ./coverage/Cobertura.xml
publish:
stage: release
before_script:
# Set it up so we can push the tag
- project_url=$(echo $CI_PROJECT_URL | sed 's/https:\/\///')
- git remote set-url origin https://oauth2:$GITLAB_TOKEN@$project_url
script:
- nix develop --command scripts/release.sh
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

36
.woodpecker.yml Normal file
View file

@ -0,0 +1,36 @@
clone:
git:
image: woodpeckerci/plugin-git
settings:
tags: true
pipeline:
build:
image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest
commands:
- nix develop --command scripts/build.sh
when:
event: [push, pull_request, tag]
tag: v*
test:
image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest
commands:
- nix develop --command scripts/test.sh
when:
event: [push, pull_request]
#paths:
# - ./**/*test-result.xml
# - ./coverage/Cobertura.xml
# - ./coverage/Summary.*
# - ./**/*.nupkg
release-main:
image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest
commands:
- nix develop --command scripts/release.sh
secrets:
- gitea_token
when:
event: push
branch: main

View file

@ -14,6 +14,10 @@ This builds the project and creates the binaries in debug mode.
This runs any required tests.
## `format.sh`
This is used to format the code base using our standards. It matches the commands in the `lefthook` pre-commit hook.
## `release.sh`
Intended to run in a CI environment, this creates a NuGet package and publishes it.

View file

@ -4,15 +4,9 @@ cd $(dirname $0)/..
./scripts/setup.sh || exit 1
# Verify the input.
if [ "x$NUGET_TOKEN" = "x" ]
if [ "x$GITEA_TOKEN" = "x" ]
then
echo "the environment variable NUGET_TOKEN is not defined"
exit 1
fi
if [ "x$NUGET_PUSH_URL" = "x" ]
then
echo "the environment variable NUGET_PUSH_URL is not defined"
echo "the environment variable GITEA_TOKEN is not defined"
exit 1
fi
@ -35,9 +29,12 @@ echo "$(basename $0): building project $SEMVER"
dotnet build
# Create and publish the NuGet packages.
echo "$(basename $0): registering NuGet source"
dotnet nuget add source --name mfgames --username dmoonfire --password $GITEA_TOKEN https://src.mfgames.com/api/packages/mfgames-cil/nuget/index.json
echo "$(basename $0): publishing NuGet package"
dotnet pack --include-symbols --include-source
dotnet nuget push src/*/bin/Debug/*.nupkg --api-key $NUGET_TOKEN --source $NUGET_PUSH_URL
dotnet nuget push --source mfgamessrc/*/bin/Debug/*.nupkg
# Tag and push, but only if we don't have a tag.
if ! git tag | grep $SEMVER >& /dev/null