-
Notifications
You must be signed in to change notification settings - Fork 9
/
Release
executable file
·61 lines (51 loc) · 3.01 KB
/
Release
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# Get timestamp and version for release
current_time=`date -u "+%Y-%m-%d %H:%M:%S"`
current_timestamp=$[10#$(date -d "$current_time" -u +%s)]
echo now time utc is: $current_time
echo now time utc second is: $current_timestamp
package_library_version=`cat ./json_config/version.txt`
package_kicad_version=`cat ./json_config/kicad_version.txt`
echo current library version is: $package_library_version
echo current kicad_version version is: $package_kicad_version
installed_size=`du -sb ./`
installed_size=${installed_size%%./*}
installed_size=${installed_size//[[:blank:]]/}
# Modify metadata.json file
version_string=" \"version\": \"$package_library_version\",\n"
kicad_version_string=" \"kicad_version\": \"$package_kicad_version\"\n"
status_string=" \"status\": \"stable\",\n"
package_status_string=${version_string}${status_string}${kicad_version_string}
target_string="\"versions\": ["
sed -i "s/\"versions\": \[/&\n {\n${package_status_string} }/" metadata.json
zip -r -q PackageLIB.zip resources/ symbols/ footprints/ 3dmodels/ metadata.json
# Modify packages.json file
package_size=`wc -c ./PackageLIB.zip`
package_size=${package_size%% ./*}
packagelib_sha256=`sha256sum ./PackageLIB.zip`
packagelib_sha256=${packagelib_sha256%% *}
download_sha_string=" \"download_sha256\": \"$packagelib_sha256\",\n"
download_size_string=" \"download_size\": $package_size,\n"
installed_size_string=" \"install_size\": $installed_size,\n"
downloadurl_string=" \"download_url\": \"https:\/\/github.com\/PackageLAN\/PackageLIB\/releases\/download\/version$package_library_version\/PackageLIB.zip\",\n"
version_string=" \"version\": \"$package_library_version\"\n"
kicad_version_string=" \"kicad_version\": \"$package_kicad_version\",\n"
status_string=" \"status\": \"stable\",\n"
package_descryp_string=${download_sha_string}${download_size_string}${downloadurl_string}${installed_size_string}
package_status_string=${kicad_version_string}${status_string}${version_string}
echo package size is: ${package_size} B
echo installed size is: ${installed_size} B
sed -i "s/\"versions\": \[/&\n {\n${package_descryp_string}${package_status_string} },/" ./json_config/packages.json
# Modify repository.json file
resources_sha256=`sha256sum ./json_config/resources.zip`
resources_sha256=${resources_sha256%% *}
packages_sha256=`sha256sum ./json_config/packages.json`
packages_sha256=${packages_sha256%% *}
echo resources: $resources_sha256
echo packages: $packages_sha256
rm ./json_config/repository.json
cp ./json_config/repository.tmp ./json_config/repository.json
sed -i "s/PACKAGESSHA256/${packages_sha256}/g" ./json_config/repository.json
sed -i "s/RESOURCESSHA256/${resources_sha256}/g" ./json_config/repository.json
sed -i "s/UTCTIMENOW/${current_time}/g" ./json_config/repository.json
sed -i "s/UTCTIMESTAMP/${current_timestamp}/g" ./json_config/repository.json