appveyor: Add auto build script support
Some checks failed
continuous-integration/appveyor/branch AppVeyor build failed
Some checks failed
continuous-integration/appveyor/branch AppVeyor build failed
service-core: Update to version 3
This commit is contained in:
parent
fae74e10ff
commit
9a07149c86
9 changed files with 90 additions and 77 deletions
|
@ -1,34 +0,0 @@
|
|||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
- image: circleci/node:latest
|
||||
working_directory: ~/app
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Install npm deployment app
|
||||
command: sudo npm install -g github-release-cli
|
||||
- deploy:
|
||||
name: Create a release
|
||||
command: |
|
||||
PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[", ]//g')
|
||||
echo "Packaging to ${CIRCLE_PROJECT_REPONAME}_build-sc.zip"
|
||||
zip "${CIRCLE_PROJECT_REPONAME}_build-sc.zip" index.mjs package.json api/**
|
||||
echo "Creating release '${PACKAGE_VERSION}.${CIRCLE_BUILD_NUM}'"
|
||||
github-release upload \
|
||||
--commitish $CIRCLE_SHA1 \
|
||||
--token $GITHUB_TOKEN \
|
||||
--owner $CIRCLE_PROJECT_USERNAME \
|
||||
--repo $CIRCLE_PROJECT_REPONAME \
|
||||
--tag "v${PACKAGE_VERSION}.${CIRCLE_BUILD_NUM}" \
|
||||
--name "v${PACKAGE_VERSION}.${CIRCLE_BUILD_NUM}" \
|
||||
--body "Automatic CircleCI Build of v${PACKAGE_VERSION}.${CIRCLE_BUILD_NUM} from ${CIRCLE_SHA1}" \
|
||||
sc-helloworld_build-sc.zip
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build_deploy:
|
||||
jobs:
|
||||
- build:
|
||||
context: github-thething
|
BIN
7zas
Normal file
BIN
7zas
Normal file
Binary file not shown.
|
@ -2,10 +2,9 @@ import path from 'path'
|
|||
import { readFileSync } from 'fs'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
export function run(config, db, log, core, http, orgPort) {
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const staticPackage = path.join(__dirname,'../package.json')
|
||||
let packageInfo = JSON.parse(readFileSync(staticPackage))
|
||||
export function run(http, orgPort, ctx) {
|
||||
let packagePath = ctx.util.getPathFromRoot('./package.json')
|
||||
let packageInfo = JSON.parse(readFileSync(packagePath))
|
||||
|
||||
const server = http.createServer(function (req, res) {
|
||||
res.writeHead(200);
|
||||
|
@ -15,13 +14,9 @@ export function run(config, db, log, core, http, orgPort) {
|
|||
|
||||
let port = orgPort || 4000
|
||||
|
||||
server.listen(port, '0.0.0.0', function(err) {
|
||||
if (err) {
|
||||
log.fatal(err)
|
||||
log.event.error('Error starting server: ' + err.message)
|
||||
return process.exit(2)
|
||||
}
|
||||
log.event.info(`Server is listening on ${port} serving package ${staticPackage}`)
|
||||
log.info(`Server is listening on ${port} serving package ${staticPackage}`)
|
||||
return server.listenAsync(port, '0.0.0.0')
|
||||
.then(function() {
|
||||
ctx.log.event.info(`Server is listening on ${port} serving package ${packagePath}`)
|
||||
ctx.log.info(`Server is listening on ${port} serving package ${packagePath}`)
|
||||
})
|
||||
}
|
65
appveyor.yml
Normal file
65
appveyor.yml
Normal file
|
@ -0,0 +1,65 @@
|
|||
# version format
|
||||
version: '{build}'
|
||||
deploy: on
|
||||
|
||||
# branches to build
|
||||
branches:
|
||||
# whitelist
|
||||
only:
|
||||
- master
|
||||
|
||||
# Do not build on tags (GitHub, Bitbucket, GitLab, Gitea)
|
||||
skip_tags: true
|
||||
|
||||
# Maximum number of concurrent jobs for the project
|
||||
max_jobs: 1
|
||||
clone_depth: 1
|
||||
|
||||
# Build worker image (VM template)
|
||||
build_cloud: Docker
|
||||
|
||||
environment:
|
||||
APPVEYOR_SSH_KEY: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBRMxhawMlUlQ8l4pOaeHsZl8XDO54WQngkYM1U/XB4m samsyn\jonatan@JonatanAMD
|
||||
docker_image: node:16-alpine
|
||||
npm_config_cache: /appveyor/projects/cache
|
||||
|
||||
test_script:
|
||||
- sh: |
|
||||
echo "no tests"
|
||||
|
||||
# on successful build
|
||||
on_success:
|
||||
- sh: |
|
||||
apk add curl jq
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Finished installling curl and jq"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
CURR_VER=$(cat package.json | jq -r .version)
|
||||
echo "Checking https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases for version v${CURR_VER}"
|
||||
curl -s -X GET -H "Authorization: token $deploytoken" https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases | grep -o "\"name\"\:\"v${CURR_VER}\"" > /dev/null
|
||||
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo "Release already exists, nothing to do.";
|
||||
else
|
||||
./test/7zas a -mx9 "${CURR_VER}_build-sc.7z" package.json index.mjs api
|
||||
echo "Creating release on gitea"
|
||||
RELEASE_RESULT=$(curl \
|
||||
-X POST \
|
||||
-H "Authorization: token $deploytoken" \
|
||||
-H "Content-Type: application/json" \
|
||||
https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases \
|
||||
-d "{\"tag_name\":\"v${CURR_VER}\",\"name\":\"v${CURR_VER}\",\"body\":\"Automatic release from Appveyor from ${APPVEYOR_REPO_COMMIT} :\n\n${APPVEYOR_REPO_COMMIT_MESSAGE}\"}")
|
||||
RELEASE_ID=$(echo $RELEASE_RESULT | jq -r .id)
|
||||
echo "Adding ${CURR_VER}_build-sc.7z to release ${RELEASE_ID}"
|
||||
curl \
|
||||
-X POST \
|
||||
-H "Authorization: token $deploytoken" \
|
||||
-F "attachment=@${CURR_VER}_build-sc.7z" \
|
||||
https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases/$RELEASE_ID/assets
|
||||
fi
|
||||
|
||||
# on build failure
|
||||
on_failure:
|
||||
- sh: echo on_failure
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"name": "service-core-helloworld",
|
||||
"serviceName": "Service-Core HelloWorld App",
|
||||
"description": "Simple Hello world app for service core",
|
||||
"port": 4270,
|
||||
"managePort": 4269,
|
||||
"appRepository": null,
|
||||
"manageRepository": null
|
||||
}
|
10
dev.mjs
Normal file
10
dev.mjs
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { ServiceCore } from 'service-core'
|
||||
import * as index from './index.mjs'
|
||||
|
||||
var core = new ServiceCore('sc-helloworld', import.meta.url)
|
||||
core.setConfig({
|
||||
port: 4270,
|
||||
})
|
||||
core.init(index).then(function() {
|
||||
return core.run()
|
||||
})
|
10
index.mjs
10
index.mjs
|
@ -1,5 +1,5 @@
|
|||
export function start(config, db, log, core, http, port) {
|
||||
return import('./api/server.mjs').then(function(module) {
|
||||
return module.run(config, db, log, core, http, port)
|
||||
})
|
||||
}
|
||||
import { run } from "./api/server.mjs"
|
||||
|
||||
export function start(http, port, ctx) {
|
||||
return run(http, port, ctx)
|
||||
}
|
||||
|
|
10
package.json
10
package.json
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"name": "sc-helloworld",
|
||||
"version": "1.0.2",
|
||||
"version": "2.0.0",
|
||||
"description": "Hello World app for service core",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev": "nodemon --watch api --watch runner.mjs --watch index.mjs runner.mjs | bunyan",
|
||||
"start": "node dev.mjs | bunyan",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
|
@ -17,11 +17,7 @@
|
|||
"url": "https://github.com/TheThing/sc-helloworld/issues"
|
||||
},
|
||||
"homepage": "https://github.com/TheThing/sc-helloworld#readme",
|
||||
"dependencies": {
|
||||
"node-static": "^0.7.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bunyan-lite": "^1.0.1",
|
||||
"nodemon": "^2.0.4"
|
||||
"service-core": "^3.0.0-beta.8"
|
||||
}
|
||||
}
|
||||
|
|
10
runner.mjs
10
runner.mjs
|
@ -1,10 +0,0 @@
|
|||
import ServiceCore from 'service-core'
|
||||
import * as server from './index.mjs'
|
||||
|
||||
const serviceCore = new ServiceCore('sc-manager', import.meta.url)
|
||||
|
||||
serviceCore.init(server)
|
||||
.then(function() {})
|
||||
.catch(function(err) {
|
||||
serviceCore.log.error(err, 'Unknown error starting server')
|
||||
})
|
Loading…
Reference in a new issue