-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
175 lines (144 loc) · 7.78 KB
/
justfile
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
target:=`rustc -vV | sed -n 's|host: ||p'`
os_family:=os_family()
archive_type:=if os_family == "windows" { "zip" } else { "tarball" }
package_type:="none"
os:=os()
arch:=arch()
version:=`toml get Cargo.toml package.version --raw`
archive_name:="upnotify-" + version + "-" + target
msg:="Unknown error"
binary_name:=if os_family == "windows" { "upnotify.exe" } else { "upnotify "}
notes:="release"
extra_packages:=""
default: build
die:
@echo "Error: {{msg}}"
assert-darwin-host:
@{{ if os == "macos" { "true" } else { "just msg=\"Not a darwin host\" die" } }}
clean:
rm -rf target dist
build:
cargo build --release --target {{target}}
build-all: build-mac-m1 build-mac-x86 build-linux-amd64 build-linux-arm64
build-windows:
just target=x86_64-pc-windows-msvc build
just target=aarch64-pc-windows-msvc build
build-mac-m1:
just target=aarch64-apple-darwin assert-darwin-host archive
build-mac-x86:
just target=x86_64-apple-darwin assert-darwin-host archive
build-linux-amd64:
docker run --rm --platform linux/amd64 --user "$(id -u)":"$(id -g)" -v "$PWD":/usr/src/myapp -w /usr/src/myapp \
rust:1.70.0 sh -c "cargo install just toml-cli && just archive"
build-linux-arm64:
docker run --rm --platform linux/arm64 --user "$(id -u)":"$(id -g)" -v "$PWD":/usr/src/myapp -w /usr/src/myapp \
rust:1.70.0 sh -c "cargo install just toml-cli && just archive"
archive-tarball:
mkdir -p dist/{{target}}
tar czf dist/{{target}}/{{archive_name}}.tar.gz -C target/{{target}}/release/ {{binary_name}}
archive-zip:
mkdir -p dist/{{target}}
zip dist/{{target}}/{{archive_name}}.zip target/{{target}}/release/{{binary_name}}
archive: build
just target={{target}} archive-{{archive_type}}
archive-windows:
just target=aarch64-pc-windows-msvc archive
just target=x86_64-pc-windows-msvc archive
archive-all:
just target=aarch64-apple-darwin archive-tarball
just target=x86_64-apple-darwin archive-tarball
just target=aarch64-unknown-linux-gnu archive-tarball
just target=x86_64-unknown-linux-gnu archive-tarball
just target=aarch64-pc-windows-msvc binary_name=upnotify.exe archive-zip
just target=x86_64-pc-windows-msvc binary_name=upnotify.exe archive-zip
package:
#!/usr/bin/env bash
mkdir -p dist/{{target}}
source build/{{target}}.env
nfpm package -p {{package_type}} \
-f <(VERSION={{version}} BIND_FILE=/usr/bin/upnotify envsubst < build/nfpm.yaml.tmpl) --target dist/{{target}}/
package-termux:
#!/usr/bin/env bash
mkdir -p dist/{{target}}
mkdir -p dist/tmp/
source build/{{target}}.env
nfpm package -p {{package_type}} \
-f <(VERSION={{version}} BIND_FILE=/data/data/com.termux/files envsubst < build/nfpm.yaml.tmpl) \
--target dist/tmp/
export DEBARCH="{{if target =~ '^x86_64' { "amd64" } else { "arm64" } }}"
mv dist/tmp/upnotify_{{version}}_${DEBARCH}.deb dist/{{target}}/upnotify_{{version}}_${DEBARCH}.termux.deb
rmdir dist/tmp
linux-packages:
just target=x86_64-unknown-linux-gnu package_type=deb package
just target=x86_64-unknown-linux-gnu package_type=rpm package
just target=x86_64-unknown-linux-gnu package_type=deb package-termux
just target=aarch64-unknown-linux-gnu package_type=deb package
just target=aarch64-unknown-linux-gnu package_type=rpm package
just target=aarch64-unknown-linux-gnu package_type=deb package-termux
create-release: clobber-release
gh release create {{version}} --notes "{{notes}}"
clobber-release:
gh release delete {{version}} -y || true
upload-to-release:
gh release view {{version}} || just msg="Release does not exist" die
gh release upload {{version}} \
dist/aarch64-apple-darwin/upnotify-{{version}}-aarch64-apple-darwin.tar.gz \
dist/x86_64-apple-darwin/upnotify-{{version}}-x86_64-apple-darwin.tar.gz \
dist/aarch64-unknown-linux-gnu/upnotify-{{version}}-aarch64-unknown-linux-gnu.tar.gz \
dist/aarch64-unknown-linux-gnu/upnotify-{{version}}-1.aarch64.rpm \
dist/aarch64-unknown-linux-gnu/upnotify_{{version}}_arm64.deb \
dist/aarch64-unknown-linux-gnu/upnotify_{{version}}_arm64.termux.deb \
dist/x86_64-unknown-linux-gnu/upnotify-{{version}}-x86_64-unknown-linux-gnu.tar.gz \
dist/x86_64-unknown-linux-gnu/upnotify-{{version}}-1.x86_64.rpm \
dist/x86_64-unknown-linux-gnu/upnotify_{{version}}_amd64.deb \
dist/x86_64-unknown-linux-gnu/upnotify_{{version}}_amd64.termux.deb \
{{extra_packages}} \
--clobber
upload-to-release-ci:
just extra_packages="dist/x86_64-pc-windows-msvc/upnotify-{{version}}-x86_64-pc-windows-msvc.zip \
dist/aarch64-pc-windows-msvc/upnotify-{{version}}-aarch64-pc-windows-msvc.zip" upload-to-release
homebrew-program:
#!/usr/bin/env bash
export VERSION={{version}}
export X86_DARWIN_RELEASE_URL=$(gh release view {{version}} --json assets --jq \
'.assets[] | select(.name=="upnotify-{{version}}-x86_64-apple-darwin.tar.gz") | .url')
export X86_DARWIN_RELEASE_SHA=$(shasum -a 256 \
dist/x86_64-apple-darwin/upnotify-{{version}}-x86_64-apple-darwin.tar.gz | awk '{print $1}')
export ARM64_DARWIN_RELEASE_URL=$(gh release view {{version}} --json assets --jq \
'.assets[] | select(.name=="upnotify-{{version}}-aarch64-apple-darwin.tar.gz") | .url')
export ARM64_DARWIN_RELEASE_SHA=$(shasum -a 256 \
dist/aarch64-apple-darwin/upnotify-{{version}}-aarch64-apple-darwin.tar.gz | awk '{print $1}')
export X86_LINUX_RELEASE_URL=$(gh release view {{version}} --json assets --jq \
'.assets[] | select(.name=="upnotify-{{version}}-x86_64-unknown-linux-gnu.tar.gz") | .url')
export X86_LINUX_RELEASE_SHA=$(shasum -a 256 \
dist/x86_64-unknown-linux-gnu/upnotify-{{version}}-x86_64-unknown-linux-gnu.tar.gz | awk '{print $1}')
export ARM64_LINUX_RELEASE_URL=$(gh release view {{version}} --json assets --jq \
'.assets[] | select(.name=="upnotify-{{version}}-aarch64-unknown-linux-gnu.tar.gz") | .url')
export ARM64_LINUX_RELEASE_SHA=$(shasum -a 256 \
dist/aarch64-unknown-linux-gnu/upnotify-{{version}}-aarch64-unknown-linux-gnu.tar.gz | awk '{print $1}')
envsubst < build/program.rb.tmpl > dist/program.rb
homebrew-update: homebrew-program
#!/usr/bin/env bash
git clone git@github.com:scottmmjackson/homebrew-sj dist/tap
cd dist/tap
git checkout -b upnotify-{{version}}
cp ../program.rb Formula/upnotify.rb
git add Formula/upnotify.rb
git commit -m "Added formula for upnotify {{version}}"
git push origin HEAD --force # force push because this could be a second run
gh pr create --title "Added formula for upnotify {{version}}" --body "Added formula for upnotify {{version}}"
do-release-build: build-all
do-release-package-preflight:
@stat dist/aarch64-apple-darwin/upnotify-{{version}}-aarch64-apple-darwin.tar.gz > /dev/null
@stat dist/x86_64-apple-darwin/upnotify-{{version}}-x86_64-apple-darwin.tar.gz > /dev/null
@stat dist/aarch64-unknown-linux-gnu/upnotify-{{version}}-aarch64-unknown-linux-gnu.tar.gz > /dev/null
@stat dist/x86_64-unknown-linux-gnu/upnotify-{{version}}-x86_64-unknown-linux-gnu.tar.gz > /dev/null
# For linux packages
@stat target/x86_64-unknown-linux-gnu/release/upnotify > /dev/null
@stat target/aarch64-unknown-linux-gnu/release/upnotify > /dev/null
do-release-package-preflight-ci: do-release-package-preflight
@stat dist/x86_64-pc-windows-msvc/upnotify-{{version}}-x86_64-pc-windows-msvc.zip > /dev/null
@stat dist/aarch64-pc-windows-msvc/upnotify-{{version}}-aarch64-pc-windows-msvc.zip > /dev/null
do-release-package: do-release-package-preflight linux-packages create-release upload-to-release homebrew-update
do-release-package-ci: do-release-package-preflight-ci linux-packages create-release upload-to-release-ci homebrew-update
do-release: do-release-build do-release-package