~nhanb/pytaku

ref: 0.5.0 pytaku/.builds/ubuntu.yml -rw-r--r-- 3.2 KiB
680ded18Bùi Thành Nhân ass 1 year, 2 months ago
                                                                                
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
image: ubuntu/bionic

secrets:
  # PyPI token for pytaku:
  - 8c42b8a6-d1b7-4af7-82f2-b8f1b6e085e2
  # ssh key for dev.pytaku.com:
  - 2d6e3246-5adc-41c2-bebe-01dacda9d0c8
  # ~/pytaku.conf.json:
  - d18b6657-ac13-4413-8349-8ef262142545

environment:
  # Ugly hack to prepend to PATH:
  #   ~/.poetry/bin - for poetry (duh)
  #   ~/.local/bin - for entrypoint scripts that poetry installs
  PATH: /home/build/.poetry/bin:/home/build/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/games

packages:
  - curl
  - python3.7-dev
  - python3.7-venv
  - python3-pip
  - npm

tasks:
  - setup: |
      python3.7 -m pip install pipx
      python3.7 -m pipx install poetry==1.1.6
      cd pytaku
      poetry install --no-dev
      poetry run pip install https://github.com/rogerbinns/apsw/releases/download/3.32.2-r1/apsw-3.32.2-r1.zip \
            --global-option=fetch --global-option=--version --global-option=3.32.2 --global-option=--all \
            --global-option=build --global-option=--enable-all-extensions

  #- test: |
      #cd pytaku
      #mv ~/pytaku.conf.json ./
      #poetry run pytest

  - build: |
      cd pytaku
      npm install -g --prefix ~/.node_modules esbuild
      ~/.node_modules/bin/esbuild \
        src/pytaku/js-src/main.js \
        --bundle --sourcemap --minify \
        --outfile=src/pytaku/static/js/main.min.js
      poetry build

  # Builds.sr.ht doesn't support tag or even branch detection yet:
  # > https://todo.sr.ht/~sircmpwn/builds.sr.ht/170
  # So here I manually check for it:
  - check-master: |
      cd pytaku
      # Stop if not master branch, meaning we're automatically deploying to
      # dev server for every push to master.
      if [ "$(git rev-parse master)" != "$(git rev-parse HEAD)" ]; then \
        complete-build; \
      fi

  - deploy-dev: |
      cd pytaku
      echo "dev.pytaku.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBAQ1jWerB3GUGRhaZZzgpRyCSwo7PRi1cPbokaAwwsAKts1dkXSdCtR9xoTXKdvhASX5xafdzHZqbyFzpc0RleM=" >> ~/.ssh/known_hosts
      # Clean up old stuff just in case
      ssh -i ~/.ssh/2d6e3246-5adc-41c2-bebe-01dacda9d0c8 pytaku@dev.pytaku.com 'rm -f /home/pytaku/pytaku*.whl'
      # Copy wheel & systemd service files over.
      # I'm not installing pytaku from pypi here because it may
      # take a loooong time for the new version to appear.
      scp -i ~/.ssh/2d6e3246-5adc-41c2-bebe-01dacda9d0c8 dist/pytaku*.whl pytaku@dev.pytaku.com:/home/pytaku/
      scp -i ~/.ssh/2d6e3246-5adc-41c2-bebe-01dacda9d0c8 contrib/systemd/*.service pytaku@dev.pytaku.com:/home/pytaku/.config/systemd/user/
      # Install & restart serivces
      ssh -i ~/.ssh/2d6e3246-5adc-41c2-bebe-01dacda9d0c8 pytaku@dev.pytaku.com "
        ~/.local/bin/pip install --user --force-reinstall pytaku*.whl &&
        cd ~/pytaku &&
        ~/.local/bin/pytaku-migrate &&
        rm -r static &&
        cp -r ~/.local/lib/python3.7/site-packages/pytaku/static ./ &&
        systemctl --user daemon-reload &&
        systemctl --user restart pytaku &&
        systemctl --user restart pytaku-scheduler &&
        echo 'All done.'
      "

  - check-tag: |
      # Stop if HEAD is not a tagged commit.
      cd pytaku
      git describe --exact-match HEAD || complete-build

  - publish: |
      cd pytaku
      poetry publish