From cf06d4cd3d6562afb73bf1f895cfac7366f3a4b3 Mon Sep 17 00:00:00 2001 From: "D. Moonfire" Date: Fri, 2 Sep 2022 10:07:38 -0500 Subject: [PATCH] fix(ci): bumping version to test Woodpecker CI --- .gitlab-ci.yml | 45 --------------------------------------------- .woodpecker.yml | 36 ++++++++++++++++++++++++++++++++++++ scripts/README.md | 4 ++++ scripts/release.sh | 15 ++++++--------- 4 files changed, 46 insertions(+), 54 deletions(-) delete mode 100644 .gitlab-ci.yml create mode 100644 .woodpecker.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index f240c67..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -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 diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..3f25d63 --- /dev/null +++ b/.woodpecker.yml @@ -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 diff --git a/scripts/README.md b/scripts/README.md index 6245177..f357938 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -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. diff --git a/scripts/release.sh b/scripts/release.sh index f64cd3d..b43c343 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -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