This repository has been archived by the owner on Feb 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
publi.sh
68 lines (54 loc) · 1.44 KB
/
publi.sh
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
#!/usr/bin/env bash
# Abort on error
set -e
mkdir -p ~/.config/rebar3
# What we really want to do here is provide the unencrypted api_key directly.
# That would avoid the faff below with the local password.
# If https://github.com/erlang/rebar3/pull/2182 gets merged we can delete this nonsense.
echo '#{<<"hexpm">> => #{username => <<"'$HEXPM_USER'">>, read_key => <<"'$HEXPM_API_KEY'">>, write_key => '$HEXPM_WRITE_KEY'}}.' > ~/.config/rebar3/hex.config
# Debug info - might come in handy.
rebar3 --version
# Ordinarily the way to do this would probably be to use a heredoc. Something like:
#
# ```
# rebar3 hex publish <<EOF
# y
# $LOCAL_PASSWORD
# $LOCAL_PASSWORD
# ```
#
# However there's something funny around (I think) prompts and spawning processes going on,
# where rebar3 will crash if we send it the local password too quickly.
#
pipe=pipe_name
mkfifo $pipe
publish () {
# We do this so that we don't send a premature EOF. Otherwise we kill Erlang.
exec 3>$pipe
# Tell rebar3 yes, we want to publish.
echo y > $pipe
# the mark of a quality piece of code.
sleep 1s
# Give our local password
echo $HEXPM_LOCAL_PASSWORD > $pipe
# revenge of the sleep
sleep 1m
}
docs () {
exec 3>$pipe
sleep 1s
echo $HEXPM_LOCAL_PASSWORD > $pipe
sleep 1m
}
# Publish
publish &
rebar3 hex publish < $pipe
exec 3>&-
# Docs
docs &
rebar3 hex docs < $pipe
exec 3>&-
# Why is this necessary
sleep 1s
# Tidy up
rm $pipe