Skip to content

Commit

Permalink
Add proper gitlab CI support back in. CI will auto-increment build nu…
Browse files Browse the repository at this point in the history
…mbers and determine the branch name that goes in the manifest file
  • Loading branch information
fryguy1013 committed Jun 29, 2020
1 parent a037d44 commit 0d7cf4d
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 15 deletions.
37 changes: 24 additions & 13 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
image: node:latest

stages:
- build
- test
- build
- test

cache:
paths:
- node_modules/
before_script:
- apt-get update
- apt-get install zip

install_dependencies:
stage: build
script:
- npm install
artifacts:
cache:
paths:
- node_modules/
- node_modules/

build:
stage: build
script:
- export
- npm ci
- node updatebuildno.js --buildno=$CI_PIPELINE_IID --branch=$CI_COMMIT_BRANCH --gitlabpath=$CI_PROJECT_PATH
- npm run build
- mv dist pf2e
- zip pf2e.zip -r pf2e
artifacts:
paths:
- pf2e.zip
- system.json


testing_testing:
stage: test
script: npm test
stage: test
script: npm test
4 changes: 2 additions & 2 deletions system.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,6 @@
"gridDistance": 5,
"gridUnits": "ft",
"url": "https://gitlab.com/hooking/foundry-vtt---pathfinder-2e",
"manifest": "https://gitlab.com/hooking/foundry-vtt---pathfinder-2e/raw/master/system.json",
"download": "https://gitlab.com/hooking/foundry-vtt---pathfinder-2e/uploads/c573d59e29530ed6cd02f0ab618801b9/pf2e-v1.7.0.zip"
"manifest": "https://gitlab.com/hooking/foundry-vtt---pathfinder-2e/-/jobs/artifacts/release/raw/system.json?job=build",
"download": "https://gitlab.com/hooking/foundry-vtt---pathfinder-2e/-/jobs/artifacts/release/raw/pf2e.zip?job=build"
}
30 changes: 30 additions & 0 deletions updatebuildno.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const yargs = require('yargs');
const fs = require('fs');

const argv = yargs
.option('buildno', {
type: 'number',
description: 'specifies the build number to be updated (CI_PIPELINE_IID)'
})
.option('branch', {
'type': 'string',
description: 'specifies the branch (CI_COMMIT_BRANCH)'
})
.option('gitlabpath', {
type: 'string',
description: 'The path on gitlab where this branch is stored (CI_PROJECT_PATH)'
})
.demandOption(['branch', 'buildno'])
.argv;

const systemRaw = fs.readFileSync('system.json');
let system = JSON.parse(systemRaw);

system.version = `${system.version}.${argv.buildno}`;
system.url = `https://gitlab.com/${argv.gitlabpath}`;
system.manifest = `https://gitlab.com/${argv.gitlabpath}/-/jobs/artifacts/${argv.branch}/raw/system.json?job=build`;
system.download = `https://gitlab.com/${argv.gitlabpath}/-/jobs/artifacts/${argv.branch}/raw/pf2e.zip?job=build`;

fs.writeFileSync('system.json', JSON.stringify(system, null, 2));

console.log(system.manifest);

0 comments on commit 0d7cf4d

Please sign in to comment.