~nhanb/pytaku

ref: 0.5.2 pytaku/.builds/debian.yml -rw-r--r-- 2.7 KiB
cb2a6245Bùi Thành Nhân migrate to new debian 11 server 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
image: debian/bullseye

secrets:
  # PyPI token for pytaku:
  - 8c42b8a6-d1b7-4af7-82f2-b8f1b6e085e2
  # ssh key for pytaku.imnhan.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-pip
  - python3-apsw
  - python3-venv
  - esbuild

tasks:
  - setup: |
      pip3 install pipx
      python3 -m pipx install poetry==1.1.6
      #cd pytaku
      #poetry install --no-dev

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

  - build: |
      cd pytaku
      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 "pytaku.imnhan.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBpDNzSaWLPXnb2XaGNgvlNnEcVbdrUUWHfBcuzJ1DyDU2fa+f1ojSFddfNMBrSRpU0GAPfpDoky6en866WH4gw=" >> ~/.ssh/known_hosts

      # Clean up old stuff just in case
      ssh -i ~/.ssh/2d6e3246-5adc-41c2-bebe-01dacda9d0c8 pytaku@pytaku.imnhan.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@pytaku.imnhan.com:/home/pytaku/
      # Install & restart serivces
      ssh -i ~/.ssh/2d6e3246-5adc-41c2-bebe-01dacda9d0c8 pytaku@pytaku.imnhan.com "
        pip3 install --user --force-reinstall pytaku*.whl &&
        cd ~/pytaku &&
        ~/.local/bin/pytaku-migrate &&
        rm -r static &&
        cp -r ~/.local/lib/python3.9/site-packages/pytaku/static ./ &&
        sudo systemctl restart pytaku 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