99ca93d6 Andy McCall 1 month ago ↶
1
2
3
4
5
6
7
8
9
10
11
12
13
14
set -euo pipefail
15
16
PKG = oh
17
BIN = oh
18
DEB_NAME = oh
19
SUMMARY = " OxygenHub from the command line"
20
DESCRIPTION = " oh talks to an OxygenHub (such as https://oxygenhub.io): issues,
21
proposals and their reviews, releases, Flow runs and checks, from the
22
terminal. It works alongside oxy, the Oxygen version control client."
23
HOMEPAGE = " https://oxygenhub.io/andymccall/oxygenhub"
24
MAINTAINER = " Andy McCall <[email protected] >"
25
DOCS = ( README.md LICENSE docs/oh.md)
26
27
cd " $ ( dirname " $ 0 " ) /.."
28
VERSION = " $ { 1 :- $ ( cargo metadata -- no-deps -- format-version 1 | python3 - c " import json,sys; print(next(p['version'] for p in json.load(sys.stdin)['packages'] if p['name']=='$ PKG '))" ) } "
29
VERSION = " $ { VERSION# v } "
30
OUT = " target/dist/$ VERSION "
31
rm - rf " $ OUT " && mkdir - p " $ OUT "
32
export PATH = " $ HOME /.local/opt/zig:$ PATH "
33
34
export CARGO_PROFILE_RELEASE_DEBUG = 0 CARGO_PROFILE_RELEASE_STRIP = true CARGO_INCREMENTAL = 0
35
36
export OXY_BUILD = " v$ VERSION "
37
38
39
PLATFORMS = (
40
" x86_64-unknown-linux-gnu.2.28|linux-x86_64|zig|amd64"
41
" aarch64-unknown-linux-gnu.2.28|linux-arm64|zig|arm64"
42
" x86_64-apple-darwin|macos-x86_64|zig|"
43
" aarch64-apple-darwin|macos-arm64|zig|"
44
" x86_64-pc-windows-gnu|windows-x86_64|cargo|"
45
)
46
47
for p in " $ { PLATFORMS[ @ ] } " ; do
48
IFS = ' |' read - r target platform tool deb < < < " $ p "
49
triple = " $ { target%% .2.* } "
50
echo " == $ platform ($ target )"
51
if [ " $ tool " = zig ] ; then
52
cargo zigbuild - q -- release -- locked -- target " $ target " - p " $ PKG "
53
else
54
cargo build - q -- release -- locked -- target " $ target " - p " $ PKG "
55
fi
56
exe = " $ BIN "
57
[[ " $ triple " == * windows* ]] && exe = " $ BIN .exe"
58
built = " target/$ triple /release/$ exe "
59
name = " $ BIN -$ VERSION -$ platform "
60
stage = " $ OUT /stage/$ name "
61
mkdir - p " $ stage "
62
cp " $ built " " $ stage /"
63
cp " $ { DOCS[ @ ] } " " $ stage /"
64
if [[ " $ triple " == * windows* ]] ; then
65
( cd " $ OUT /stage" && zip - qr " ../$ name .zip" " $ name " )
66
else
67
tar - C " $ OUT /stage" - czf " $ OUT /$ name .tar.gz" " $ name "
68
fi
69
if [ - n " $ deb " ] ; then
70
root = " $ OUT /stage/deb-$ deb "
71
mkdir - p " $ root /DEBIAN" " $ root /usr/bin" " $ root /usr/share/doc/$ DEB_NAME "
72
install - m 0755 " $ built " " $ root /usr/bin/$ BIN "
73
cp README.md docs/oh.md " $ root /usr/share/doc/$ DEB_NAME /"
74
cp LICENSE " $ root /usr/share/doc/$ DEB_NAME /copyright"
75
cat > " $ root /DEBIAN/control" << EOF
76
Package: $ DEB_NAME
77
Version: $ VERSION
78
Architecture: $ deb
79
Maintainer: $ MAINTAINER
80
Depends: libc6 (>= 2.28)
81
Section: vcs
82
Priority: optional
83
Homepage: $ HOMEPAGE
84
Installed-Size: $ ( du - sk " $ root /usr" | cut - f1)
85
Description: $ SUMMARY
86
$ DESCRIPTION
87
EOF
88
dpkg-deb -- build -- root-owner-group - Zxz " $ root " " $ OUT /$ { DEB_NAME } _$ { VERSION } _$ deb .deb" > /dev/null
89
fi
90
done
91
92
rm - rf " $ OUT /stage"
93
( cd " $ OUT " && sha256sum -- * .tar.gz * .zip * .deb > SHA256SUMS )
94
echo " == $ OUT "
95
ls - l " $ OUT "