Skip to content

Commit bf29c5e

Browse files
committed
ci: add semantic release
1 parent d412396 commit bf29c5e

File tree

10 files changed

+4008
-1
lines changed

10 files changed

+4008
-1
lines changed

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
name: Release
3+
4+
on:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
release:
11+
name: Release
12+
runs-on: windows-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
with:
17+
submodules: true
18+
19+
- name: Add msbuild to PATH
20+
uses: microsoft/setup-msbuild@v1.1
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v1
24+
with:
25+
node-version: 14
26+
27+
- name: Install dependencies
28+
run: yarn install
29+
30+
- name: Release
31+
env:
32+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
33+
run: yarn semantic-release
34+
35+
36+

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
packages
22
build
33
**/obj
4-
.vs
4+
.vs
5+
node_modules

.releaserc.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"branches": ["master"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
[
7+
"@semantic-release/github",
8+
{
9+
"assets": ["*.rmskin"]
10+
}
11+
],
12+
[
13+
"@semantic-release/git",
14+
{
15+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
16+
"assets": ["RMSKIN.ini", "OpenHardwareMonitor/AssemblyInfo.cs", "package.json", "OpenHardwareMonitor/OpenHardwareMonitor.csproj"]
17+
}
18+
],
19+
[
20+
"@semantic-release/exec",
21+
{
22+
"prepareCmd": "powershell scripts\\prepare_release.ps1 ${nextRelease.version}"
23+
}
24+
]
25+
]
26+
}

RMSKIN.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[rmskin]
2+
Name=OpenHardwareMonitor
3+
Author=abichinger
4+
Version=2.0.0
5+
MinimumRainmeter=4.5.4.3550
6+
MinimumWindows=5.1

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"devDependencies": {
3+
"@semantic-release/exec": "^6.0.2",
4+
"@semantic-release/git": "^10.0.1",
5+
"archiver": "^5.3.0",
6+
"ini": "^2.0.0",
7+
"jspack": "^0.0.4",
8+
"semantic-release": "^18.0.1"
9+
}
10+
}

scripts/append_footer.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import struct
2+
import sys
3+
import os
4+
from shutil import copyfile
5+
6+
print(sys.argv)
7+
8+
src_path = sys.argv[1]
9+
dst_path = sys.argv[2]
10+
11+
file_size = os.path.getsize(src_path)
12+
13+
key = "RMSKIN\x00"
14+
key = key.encode('utf')
15+
16+
bytes = struct.pack('qB7s', file_size, 0, key)
17+
18+
print(len(bytes), bytes)
19+
hex_str = [hex(b) for b in bytes]
20+
print(hex_str)
21+
22+
copyfile(src_path, dst_path)
23+
24+
with open(dst_path, "ab") as f:
25+
f.write(bytes)

scripts/gen_rmskin.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const jspack = require('jspack').jspack;
2+
const chr = (n) => String.fromCharCode(n)
3+
const fs = require('fs')
4+
const archiver = require('archiver')
5+
6+
let rmskinPath = process.argv[2]
7+
8+
//create zip
9+
let rmskin = archiver('zip')
10+
let rmskinOutput = fs.createWriteStream(rmskinPath)
11+
12+
rmskinOutput.on('close', function() {
13+
console.log(rmskin.pointer() + ' total bytes');
14+
15+
//prepare footer
16+
let rmskinStats = fs.statSync(rmskinPath)
17+
18+
let key = 'RMSKIN\x00'
19+
let fileSize = rmskinStats.size
20+
let flags = chr(0)
21+
22+
console.log('file size:',fileSize)
23+
24+
let bytes = jspack.Pack('<lxxxxB7s', [fileSize, flags, key])
25+
let footer = Buffer.from(bytes)
26+
console.log(footer.length, footer)
27+
28+
fs.appendFileSync(rmskinPath, footer)
29+
});
30+
31+
rmskin.pipe(rmskinOutput)
32+
33+
rmskin.file('./RMSKIN.ini', {name: 'RMSKIN.ini'})
34+
rmskin.directory('./Skins/', 'Skins/OHM')
35+
rmskin.file('build/x32/Release/OpenHardwareMonitor.dll', {name: 'Plugins/32bit/OpenHardwareMonitor.dll'})
36+
rmskin.file('build/x64/Release/OpenHardwareMonitor.dll', {name: 'Plugins/64bit/OpenHardwareMonitor.dll'})
37+
38+
rmskin.finalize()

scripts/prepare_release.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
$ErrorActionPreference = "Stop"
2+
$nextRelease = $args[0]
3+
4+
node .\scripts\update_version.js $nextRelease
5+
if ($LASTEXITCODE -ne 0) { throw "Exit code is $LASTEXITCODE" }
6+
7+
msbuild.exe -target:Build -p:"Configuration=Release;Platform=x86" .\OpenHardwareMonitor\
8+
if ($LASTEXITCODE -ne 0) { throw "Exit code is $LASTEXITCODE" }
9+
10+
msbuild.exe -target:Build -p:"Configuration=Release;Platform=x64" .\OpenHardwareMonitor\
11+
if ($LASTEXITCODE -ne 0) { throw "Exit code is $LASTEXITCODE" }
12+
13+
node .\scripts\gen_rmskin.js OpenHardwareMonitor_$nextRelease.rmskin
14+
if ($LASTEXITCODE -ne 0) { throw "Exit code is $LASTEXITCODE" }

scripts/update_version.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const ini = require('ini')
2+
const fs = require('fs')
3+
4+
nextRelease = process.argv[2]
5+
rmskinINI = './RMSKIN.ini'
6+
asseblyInfo = "./OpenHardwareMonitor/AssemblyInfo.cs"
7+
csprojPath = "./OpenHardwareMonitor/OpenHardwareMonitor.csproj"
8+
9+
// update RMSKIN.ini version
10+
var config = ini.parse(fs.readFileSync(rmskinINI, 'utf-8'))
11+
config.rmskin.Version = nextRelease
12+
fs.writeFileSync(rmskinINI, ini.stringify(config))
13+
14+
// update AsseblyInfo.cs
15+
var info = fs.readFileSync(asseblyInfo, 'utf-8')
16+
info = info.replace(/AssemblyVersion\(".*"\)/gi, `AssemblyVersion("${nextRelease}")`)
17+
fs.writeFileSync(asseblyInfo, info)
18+
19+
// update OpenHardwareMonitor.csproj
20+
var csproj = fs.readFileSync(csprojPath, 'utf-8')
21+
csproj = csproj.replace(/<ApplicationVersion>.*<\/ApplicationVersion>/gi, `<ApplicationVersion>${nextRelease}</ApplicationVersion>`)
22+
fs.writeFileSync(csprojPath, csproj)
23+

0 commit comments

Comments
 (0)