Update config.yml

This commit is contained in:
Koen Plasmans 2022-11-29 11:20:56 +01:00 committed by GitHub
parent 7a38757c5b
commit 2d7d863391
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,18 +1,14 @@
version: 2.1 version: 2.1
parameters: parameters:
project-folder: PROJECT-NAME:
type: string type: string
default: "SMBLibrary/" default: "SMBLibrary"
csproj-file: csproj-file:
type: string type: string
default: "SMBLibrary.csproj" default: "SMBLibrary.csproj"
nuget-output-file:
type: string
default: "bin/Release/Lansweeper.SMBLibrary.1.7.0.nupkg"
git-primary-branch: git-primary-branch:
type: string type: string
default: "master" default: "master"
@ -20,7 +16,7 @@ parameters:
executors: executors:
node: node:
docker: docker:
- image: circleci/node:12 - image: cimg/node:18.9.0
orbs: orbs:
win: circleci/windows@2.2.0 win: circleci/windows@2.2.0
@ -39,25 +35,26 @@ commands:
</packageSources> </packageSources>
<packageSourceCredentials> <packageSourceCredentials>
<github> <github>
<add key='Username' value='LansweeperCloudDevelopment' /> <add key='Username' value='$GITHUB_USER' />
<add key='ClearTextPassword' value='$env:GITHUB_TOKEN' /> <add key='ClearTextPassword' value='$GITHUB_TOKEN' />
</github> </github>
</packageSourceCredentials> </packageSourceCredentials>
</configuration>" </configuration>" >> nuget.config
Out-File -FilePath nuget.config -InputObject $xml -Encoding ASCII
install-deps: install-deps:
description: "Install and cache dependencies" description: "Install and cache dependencies"
steps: steps:
# Download and cache dependencies
- restore_cache: - restore_cache:
keys: keys:
- << pipeline.parameters.project-folder >>-dependencies-{{ checksum "yarn.lock" }} - << pipeline.parameters.PROJECT-NAME >>-deps-cache-{{ checksum "yarn.lock" }}
- run: yarn install --pure-lockfile - << pipeline.parameters.PROJECT-NAME >>-deps-cache- # when lock file changes, use increasingly general patterns to restore cache
- run:
name: Install Dependencies
command: yarn --frozen-lockfile --cache-folder ~/.cache/yarn
- save_cache: - save_cache:
key: << pipeline.parameters.PROJECT-NAME >>-deps-cache-{{ checksum "yarn.lock" }}
paths: paths:
- node_modules - ~/.cache/yarn
key: << pipeline.parameters.project-folder >>-dependencies-{{ checksum "yarn.lock" }}
jobs: jobs:
build: build:
@ -66,35 +63,53 @@ jobs:
steps: steps:
- checkout - checkout
- nuget-prepare - nuget-prepare
- run: dotnet build << pipeline.parameters.project-folder >><< pipeline.parameters.csproj-file >> --configuration Release - run: dotnet build << pipeline.parameters.PROJECT-NAME >>/<< pipeline.parameters.csproj-file >> --configuration Release
- persist_to_workspace: - persist_to_workspace:
root: . root: .
paths: paths:
- . - .
nuget-publish: release:
executor: node
steps:
- attach_workspace:
at: .
- install-deps
- run: yarn release
- persist_to_workspace:
root: .
paths:
- .
publish_nuget_package:
executor: executor:
name: win/default name: win/default
steps: steps:
- attach_workspace: - attach_workspace:
at: . at: .
- run: - run:
name: Set correct version in csproj file, build and pack it name: install jq
command: apt update && apt install jq -y
- run:
name: Persist next version to environment
command: echo "export VERSION=$(cat package.json | jq --raw-output '.version')" >> $BASH_ENV
- run:
name: Replace nuspec version string with next release
command: sed -i -E 's/<Version>/<Version>'"$VERSION"'/' ./SMBLibrary/SMBLibrary.csproj
- run:
name: Pack the nuget
command: dotnet pack ./<< pipeline.parameters.PROJECT-NAME >>/<< pipeline.parameters.csproj-file >> --configuration Release
- run:
name: Push the nuget
command: | command: |
$env:package_version = "1.7.0" VERSION=$(cat package.json | jq --raw-output '.version')
$file = Get-Item << pipeline.parameters.project-folder >><< pipeline.parameters.csproj-file >> dotnet nuget push ./<< pipeline.parameters.PROJECT-NAME >>/bin/Release/<< pipeline.parameters.PROJECT-NAME >>.$VERSION.nupkg --source "github" --api-key $GITHUB_TOKEN
[xml]$cn = Get-Content $file
$cn.Project.PropertyGroup.Version="$env:package_version"
$cn.Save($file.FullName)
type ./<< pipeline.parameters.project-folder >><< pipeline.parameters.csproj-file >>
- run:
name: Pack the package
command: dotnet pack << pipeline.parameters.project-folder >><< pipeline.parameters.csproj-file >> --configuration Release
- run:
name: Publish the package
command: |
dotnet nuget push << pipeline.parameters.project-folder >><< pipeline.parameters.nuget-output-file >> --source "github" --api-key $env:GITHUB_TOKEN
workflows: workflows:
version: 2 version: 2
@ -108,9 +123,19 @@ workflows:
branches: branches:
only: << pipeline.parameters.git-primary-branch >> only: << pipeline.parameters.git-primary-branch >>
- nuget-publish: - release:
requires: requires:
- build - build
context:
- lec-github-release
- lec-npm-ro
filters:
branches:
only: << pipeline.parameters.git-primary-branch >>
- publish_nuget_package:
requires:
- release
context: context:
- lec-github-packages-rw - lec-github-packages-rw
filters: filters: