Skip to content

Commit

Permalink
Merge branch 'MajsoulPaipuCrawler' into doc
Browse files Browse the repository at this point in the history
  • Loading branch information
zyr17 committed Jun 9, 2020
2 parents ad08736 + a8a9a2b commit 873249c
Show file tree
Hide file tree
Showing 10 changed files with 358 additions and 7 deletions.
33 changes: 33 additions & 0 deletions .github/asset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const fs = require('fs');

console.log(process.argv);

let github_event = JSON.parse(fs.readFileSync(process.argv[3]).toString());

let token = process.argv[2];
let id = github_event.release.id;
let repo = process.argv[4];
let filename = process.argv[5];
let filetype = process.argv[6] || 'application/octet-stream';
let length = fs.statSync(filename).size;

let cmd = 'curl -v -X POST'
+ ' -H "Authorization: token ' + token + '"'
+ ' -H "Content-Length: ' + length + '"'
+ ' -H "Content-Type: ' + filetype + '"'
+ ' --upload-file ' + filename
+ ' https://uploads.github.com/repos/' + repo + '/releases/' + id + '/assets?name=' + filename;

console.log(cmd.replace(token, 'b2c736a8de4c71f45429acc0775671d9b5e452c3'));

var exec = require('child_process').exec;

exec(cmd, function(error, stdout, stderr) {
if(error){
console.error(error);
}
else{
console.log("curl success, stdout:\n" + stdout);
}
});

56 changes: 56 additions & 0 deletions .github/tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const fs = require('fs');

let alltext = fs.readFileSync(__dirname + '/doc/release-notes.txt').toString();
let packagefile = JSON.parse(fs.readFileSync(__dirname + '/package.json').toString());
alltext = alltext.replace(/\r/g, '');
let text = '';
let package_version = 'v' + packagefile.version;
let version = '';
for (let i = 0; i < alltext.length; i ++ ){
if (alltext[i] == '\n' && version.length == 0)
version = 'v' + alltext.slice(0, i);
if (alltext[i] == '\n' && alltext[i + 1] == '\n'){
text = alltext.slice(0, i);
break;
}
}

if (package_version != version){
console.error('version differ!', package_version, version);
process.exit(1);
}

version = package_version;

let result = {
"tag_name": version,
"target_commitish": "master",
"name": version,
"body": text,
"draft": false,
"prerelease": false
};

result = JSON.stringify(result);

let token = process.argv[2];
let repo = process.argv[3];

let cmd = 'curl -X POST -H "Authorization: token ' + token + '"'
+ ' --data ' + "'" + result + "'"
+ ' https://api.github.com/repos/' + repo + '/releases';

console.log(cmd.replace(token, 'b2c736a8de4c71f45429acc0775671d9b5e452c3'));

var exec = require('child_process').exec;

exec(cmd, function(error, stdout, stderr) {
if(error){
console.error(error);
process.exit(1);
}
else{
console.log("curl success, stdout:\n" + stdout);
}
});

57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: master CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: windows-latest

strategy:
matrix:
node-version: [10.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm
run: |
npm ci
npm run-script package-win
- name: cmake
run: |
git submodule update --init --recursive
mkdir bin
mkdir bin/release
cd bin/release
cmake ../.. -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles"
make -j
- name: collect
run: |
cp -r dist/MajsoulPaipuCrawler-win32-x64 result
cp bin/release/PaipuAnalyzer.exe result/
mkdir result/data
cp config.json result/
cp PAADData.json result/
cp doc/README.txt result/
cp doc/release-notes.txt result/
cp -r i18n/ result/
mv result MajsoulPaipuAnalyzer-win-x64
- name: archive
run: 7z a MajsoulPaipuAnalyzer-win-x64.7z MajsoulPaipuAnalyzer-win-x64 -m0=LZMA2 -mmt
- uses: actions/upload-artifact@v2
with:
name: MajsoulPaipuAnalyzer-win-x64.7z
path: MajsoulPaipuAnalyzer-win-x64.7z
# - name: check GITHUB_EVENT_PATH
# run: echo $env:GITHUB_EVENT_PATH; echo `cat $env:GITHUB_EVENT_PATH`
59 changes: 59 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Linux CI

on:
release:
types: [published]

jobs:
build:
if: "!github.event.release.prerelease"
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm
run: |
npm ci
npm run-script package-linux
- name: cmake
run: |
git submodule update --init --recursive
mkdir bin
mkdir bin/release
cd bin/release
cmake ../.. -DCMAKE_BUILD_TYPE=Release
make -j
- name: collect
run: |
cp -r dist/MajsoulPaipuCrawler-linux-x64 result
cp bin/release/PaipuAnalyzer result/
mkdir result/data
cp config.json result/
cp PAADData.json result/
cp doc/README.txt result/
cp doc/release-notes.txt result/
cp -r i18n/ result/
mv result MajsoulPaipuAnalyzer-linux-x64
- name: archive
run: 7z a MajsoulPaipuAnalyzer-linux-x64.7z MajsoulPaipuAnalyzer-linux-x64 -m0=LZMA2 -mmt
# - uses: actions/upload-artifact@v2
# with:
# name: MajsoulPaipuAnalyzer-linux-x64.7z
# path: MajsoulPaipuAnalyzer-linux-x64.7z
# - name: fake artifact
# run: mv result.html MajsoulPaipuAnalyzer-linux-x64.7z
- name: Upload to release
run: |
cp .github/asset.js .
node asset.js ${{ secrets.ACCESS_TOKEN }} $GITHUB_EVENT_PATH $GITHUB_REPOSITORY MajsoulPaipuAnalyzer-linux-x64.7z application/octet_stream
55 changes: 55 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: MacOS CI

on:
release:
types: [published]

jobs:
build:
if: "!github.event.release.prerelease"
runs-on: macOS-latest

strategy:
matrix:
node-version: [10.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm
run: |
npm ci
npm run-script package-darwin
- name: cmake
run: |
git submodule update --init --recursive
mkdir bin
mkdir bin/release
cd bin/release
cmake ../.. -DCMAKE_BUILD_TYPE=Release
make -j
- name: collect
run: |
cp -r dist/MajsoulPaipuCrawler-darwin-x64 result
cp bin/release/PaipuAnalyzer result/
mkdir result/data
cp config.json result/
cp PAADData.json result/
cp doc/README.txt result/
cp doc/release-notes.txt result/
cp -r i18n/ result/
mv result MajsoulPaipuAnalyzer-macos-x64
- name: archive
run: |
brew install p7zip
7z a MajsoulPaipuAnalyzer-macos-x64.7z MajsoulPaipuAnalyzer-macos-x64 -m0=LZMA2 -mmt
- name: Upload to release
run: |
cp .github/asset.js .
node asset.js ${{ secrets.ACCESS_TOKEN }} $GITHUB_EVENT_PATH $GITHUB_REPOSITORY MajsoulPaipuAnalyzer-macos-x64.7z application/octet_stream
31 changes: 31 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: New Tag

on:
push:
tags:
- '*'

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
# - name: check GITHUB_EVENT_PATH
# run: echo $GITHUB_EVENT_PATH; echo `cat $GITHUB_EVENT_PATH`
- name: update tag
run: |
cp .github/tag.js .
node tag.js ${{ secrets.ACCESS_TOKEN }} $GITHUB_REPOSITORY
55 changes: 55 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Windows CI

on:
release:
types: [ published ]

jobs:
build:
if: "!github.event.release.prerelease"
runs-on: windows-latest

strategy:
matrix:
node-version: [10.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm
run: |
npm ci
npm run-script package-win
- name: cmake
run: |
git submodule update --init --recursive
mkdir bin
mkdir bin/release
cd bin/release
cmake ../.. -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles"
make -j
- name: collect
run: |
cp -r dist/MajsoulPaipuCrawler-win32-x64 result
cp bin/release/PaipuAnalyzer.exe result/
mkdir result/data
cp config.json result/
cp PAADData.json result/
cp doc/README.txt result/
cp doc/release-notes.txt result/
cp -r i18n/ result/
mv result MajsoulPaipuAnalyzer-win-x64
- name: archive
run: 7z a MajsoulPaipuAnalyzer-win-x64.7z MajsoulPaipuAnalyzer-win-x64 -m0=LZMA2 -mmt
- name: Upload to release
run: |
echo $GITHUB_EVENT_PATH $GITHUB_REPOSITORY
echo $env:GITHUB_EVENT_PATH $env:GITHUB_REPOSITORY
cp .github/asset.js .
node asset.js ${{ secrets.ACCESS_TOKEN }} $env:GITHUB_EVENT_PATH $env:GITHUB_REPOSITORY MajsoulPaipuAnalyzer-win-x64.7z application/octet_stream
6 changes: 3 additions & 3 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const request = require('request');
const { version, repository } = require('../package.json');

const defaultconfig = {
DefaultURL: 'https://www.majsoul.com/1/',
PaipuMinVersion: '0.3.0',
ConfigMinVersion: '0.3.0'
DefaultURL: 'https://game.maj-soul.com/1/',
PaipuMinVersion: '0.4.4',
ConfigMinVersion: '0.4.5'
};
var config = undefined;
const configfilename = 'config.json';
Expand Down
Loading

0 comments on commit 873249c

Please sign in to comment.