-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
94 lines (86 loc) · 3.42 KB
/
Taskfile.yml
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
version: "3"
dotenv: [".env"]
vars:
POETRY_CONFIG_PATH:
sh: echo '~/.poetry/bin/poetry'
PYTHON3_SHE_BANG:
sh: echo '#!/usr/bin/env python3'
PYTHON_VERSION:
sh: echo "$(python --version 2>&1)"
PYTHON3_VERSION:
sh: echo "$(python3 --version 2>&1)"
IS_PYTHON3_DEFAULT:
sh: echo '{{ (hasPrefix "Python 3" .PYTHON_VERSION) }}'
SKIP_INSTALL_PYTHON3:
sh: echo '{{ (hasPrefix "Python 3" .PYTHON_VERSION) | ternary "true" (hasPrefix "Python 3" .PYTHON3_VERSION) }}'
SKIP_INSTALL_POETRY:
sh: test -n "$(poetry --version)" && echo "true" || echo "false"
OUTPUT_DIRECTORY:
sh: echo "dist"
BINARY_FILE_NAME:
sh: echo "bintweetapps"
includes:
file: ./Taskfile_{{OS}}.yml
tasks:
install-poetry:
cmds:
- task: file:install-python
- curl -sSL https://install.python-poetry.org/ | python3 -
- export PATH="$HOME/.poetry/bin:$PATH"
- source $HOME/.poetry/env
- task: file:poetry-use-python3-as-default
#- echo {{.SKIP_INSTALL_PYTHON3}}
#- echo "install poetry in progress....."
status:
- ( [[ {{ .SKIP_INSTALL_POETRY }} = "true" ]] )
run:
desc: Run the python program via poetry.
summary: It is mostly used during development or performing debugging.
deps: [install-poetry]
cmds:
- poetry --version
- poetry install
- poetry env info
- poetry env list
- poetry config --list
- |
poetry run python3 src/bintweet \
$CONSUMER_KEY \
$CONSUMER_SECRET \
$ACCESS_TOKEN \
$ACCESS_TOKEN_SECRET \
$BEARER_TOKEN
compile:
desc: Compile the python program into a single executable file.
summary: |
* The binary file (.exe) is for Windows while (.bin) is for Linux.
* The output binary file is located inside [{{.BINARY_FILE_NAME}}] folder.
deps: [install-poetry]
cmds:
- poetry install
- |
poetry run python3 -m nuitka \
--follow-imports \
--plugin-enable=pylint-warnings \
-o {{.BINARY_FILE_NAME}} \
--output-dir={{.OUTPUT_DIRECTORY}} \
--remove-output \
src/bintweet/__main__.py
- mv {{.BINARY_FILE_NAME}} dist/
- echo "Binary file is located at [{{.OUTPUT_DIRECTORY}}/{{.BINARY_FILE_NAME}}]."
- echo "To run the binary file, type command [task run-binary]."
run-binary:
desc: Run the single executable file as a result of calling [task compile].
cmds:
- |
./{{.OUTPUT_DIRECTORY}}/{{.BINARY_FILE_NAME}} \
$CONSUMER_KEY \
$CONSUMER_SECRET \
$ACCESS_TOKEN \
$ACCESS_TOKEN_SECRET \
$BEARER_TOKEN
preconditions:
- sh: test -f "{{.OUTPUT_DIRECTORY}}/{{.BINARY_FILE_NAME}}"
msg: |
[{{.BINARY_FILE_NAME}}] executable file does not exist in [{{.OUTPUT_DIRECTORY}}] folder.
Please run `task compile` to generate a single executable file.