diff --git a/pipelines/gitlab_generic_packages.yml b/pipelines/gitlab_generic_packages.yml new file mode 100644 index 0000000..85b0a00 --- /dev/null +++ b/pipelines/gitlab_generic_packages.yml @@ -0,0 +1,73 @@ +stages: + - build + - package + - publish + +include: + - template: Security/Secret-Detection.gitlab-ci.yml + - project: 'developerdurp/yml' + ref: 'main' + file: + - 'jobs/ocotopus.yml' + - 'jobs/versioning.yml' + - 'jobs/nuget.yml' + - 'jobs/gitlab.yml' + +secret_detection: + stage: .pre + rules: + - when: always + allow_failure: false + +version: + extends: .version + stage: .pre + rules: + - when: always + +build: + extends: .gitlab-move-files + stage: build + artifacts: + paths: + - $CI_PROJECT_DIR/output + +package: + extends: .octo_package + stage: package + needs: + - job: build + artifacts: true + - job: version + artifacts: true + rules: + - if: $CI_COMMIT_BRANCH =~ '/^release/' + - if: $CI_COMMIT_BRANCH =~ 'main' + - when: never + +upload: + extends: .nuget_push + stage: package + needs: + - job: version + artifacts: true + - job: package + artifacts: true + rules: + - if: $CI_COMMIT_BRANCH =~ '/^release/' + - if: $CI_COMMIT_BRANCH =~ 'main' + - when: never + +publish: + extends: .octo_release + stage: publish + needs: + - job: package + artifacts: true + - job: version + artifacts: true + - job: upload + rules: + - if: $CI_COMMIT_BRANCH =~ '/^release/' + - if: $CI_COMMIT_BRANCH =~ 'main' + - when: never diff --git a/scripts/gitlab/movefiles.sh b/scripts/gitlab/movefiles.sh new file mode 100644 index 0000000..3b89a9d --- /dev/null +++ b/scripts/gitlab/movefiles.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +#%%MULTILINE_YAML_START +#move files to output +mkdir $CI_PROJECT_DIR/output +IFS=";" read -a names <<< $PROJECT_NAME +for i in $names; + do mkdir $CI_PROJECT_DIR/output/$i; + cp -r $CI_PROJECT_DIR/$i $CI_PROJECT_DIR/output/; + done diff --git a/scripts/version-number.sh b/scripts/gitversion/version.sh similarity index 100% rename from scripts/version-number.sh rename to scripts/gitversion/version.sh diff --git a/scripts/nuget/push.sh b/scripts/nuget/push.sh new file mode 100644 index 0000000..740ed57 --- /dev/null +++ b/scripts/nuget/push.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +#%%MULTILINE_YAML_START +#Nuget Push +IFS=";" read -a names <<< $PROJECT_NAME +dotnet nuget add source "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/nuget/index.json" --name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN --store-password-in-clear-text +count=0 +for i in ${names[@]}; + do dotnet nuget push "${CI_PROJECT_DIR}/packages/$i.$VERSION.nupkg" --source gitlab; +done diff --git a/scripts/octopus/create_release.sh b/scripts/octopus/create_release.sh new file mode 100644 index 0000000..2d5fde7 --- /dev/null +++ b/scripts/octopus/create_release.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +#%%MULTILINE_YAML_START +#Octopus Create Release +dotnet /octo/octo.dll create-release --project="$octoproject" --releaseNumber=$VERSION --server=https://octopus.internal.durp.info/ --apiKey=$OCTOAPI --packagesFolder=$CI_PROJECT_DIR/packages + + diff --git a/scripts/octo-pack.sh b/scripts/octopus/pack.sh similarity index 100% rename from scripts/octo-pack.sh rename to scripts/octopus/pack.sh diff --git a/templates/gitlab.tpl.yml b/templates/gitlab.tpl.yml new file mode 100644 index 0000000..073b940 --- /dev/null +++ b/templates/gitlab.tpl.yml @@ -0,0 +1,4 @@ +.gitlab-move-files: + image: registry.durp.info/debian:latest + script: + - ./scripts/gitlab/movefiles.sh diff --git a/templates/nuget.tpl.yml b/templates/nuget.tpl.yml new file mode 100644 index 0000000..22d2964 --- /dev/null +++ b/templates/nuget.tpl.yml @@ -0,0 +1,4 @@ +.nuget_push: + image: registry.durp.info/dotnet/core/sdk:latest + script: + - ./scripts/nuget/push.sh diff --git a/templates/octopus.tpl.yml b/templates/octopus.tpl.yml index c823b05..4601ea6 100644 --- a/templates/octopus.tpl.yml +++ b/templates/octopus.tpl.yml @@ -1,7 +1,12 @@ .octo_package: image: registry.durp.info/octopusdeploy/octo:latest script: - - ./scripts/octo-pack.sh + - ./scripts/octopus/pack.sh artifacts: paths: - $CI_PROJECT_DIR/packages + +.octo_release: + image: registry.durp.info/octopusdeploy/octo:latest + script: + - ./scripts/octopus/pack.sh diff --git a/templates/version.tpl.yml b/templates/version.tpl.yml index 87c69d3..8785278 100644 --- a/templates/version.tpl.yml +++ b/templates/version.tpl.yml @@ -3,7 +3,7 @@ variables: GIT_DEPTH: "0" script: - - ./scripts/version-number.sh + - ./scripts/gitversion/version.sh artifacts: reports: dotenv: version.env