-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
41 lines (36 loc) · 1.44 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const {series} = require('gulp')
const {waitForProcess, defaultSpawnOptions} = require('@mikeyt23/node-cli-utils')
const {spawn} = require('child_process')
const fs = require('fs')
const path = require('path')
require('dotenv').config()
const projPath = './src/MikeyT.EnvironmentSettings'
const packageDir = path.join(projPath, 'bin/Debug')
async function pack() {
const spawnOptions = {...defaultSpawnOptions, cwd: './src/MikeyT.EnvironmentSettings'}
await waitForProcess(spawn('dotnet', ['pack'], spawnOptions))
}
async function publish() {
const packageName = await getPackageName()
console.log('publishing ' + packageName)
const spawnOptions = {...defaultSpawnOptions, cwd: packageDir}
await waitForProcess(spawn('dotnet', [
'nuget',
'push',
packageName,
'--api-key',
process.env.NUGET_API_KEY,
'--source',
'https://api.nuget.org/v3/index.json'], spawnOptions))
}
async function getPackageName() {
const csprojPath = path.join(projPath, 'MikeyT.EnvironmentSettings.csproj')
const csproj = fs.readFileSync(csprojPath, 'utf-8')
const versionTag = '<PackageVersion>'
const xmlVersionTagIndex = csproj.indexOf(versionTag)
const versionStartIndex = xmlVersionTagIndex + versionTag.length
const versionStopIndex = csproj.indexOf('<', versionStartIndex)
const version = csproj.substring(versionStartIndex, versionStopIndex)
return `MikeyT.EnvironmentSettings.${version}.nupkg`
}
exports.publish = series(pack, publish)