File: release.yml

package info (click to toggle)
python-rarfile 4.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,308 kB
  • sloc: python: 4,180; makefile: 201; sh: 88; awk: 14
file content (96 lines) | stat: -rw-r--r-- 3,084 bytes parent folder | download | duplicates (2)
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
#
# This runs when version tag is pushed
#

name: REL

on:
  push:
    tags: ["v[0-9]*"]

jobs:
  sdist:
    name: "Build source package"
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with: {python-version: "3.11"}
      - run: python3 -m pip install -r etc/requirements.build.txt --disable-pip-version-check
      - run: python3 setup.py sdist
      - run: python3 setup.py bdist_wheel
      - uses: actions/upload-artifact@v4
        with: {name: "dist", path: "dist"}

  publish:
    name: "Publish"
    runs-on: ubuntu-latest
    needs: [sdist]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with: {python-version: "3.11"}

      - run: python3 -m pip install -r etc/requirements.build.txt --disable-pip-version-check

      - name: "Get files"
        uses: actions/download-artifact@v4
        with: {name: "dist", path: "dist"}

      - name: "Install pandoc"
        run: |
          sudo -nH apt-get -u -y install pandoc
          pandoc --version

      - name: "Prepare"
        run: |
          PACKAGE=$(python3 setup.py --name)
          VERSION=$(python3 setup.py --version)
          TGZ="${PACKAGE}-${VERSION}.tar.gz"

          # default - gh:release, pypi
          # PRERELEASE -  gh:prerelease, pypi
          # DRAFT - gh:draft,prerelease, testpypi
          PRERELEASE="false"; DRAFT="false"
          case "${VERSION}" in
            *[ab]*|*rc*) PRERELEASE="true";;
            *dev*) PRERELEASE="true"; DRAFT="true";;
          esac

          test "${{github.ref}}" = "refs/tags/v${VERSION}" || { echo "ERR: tag mismatch"; exit 1; }
          test -f "dist/${TGZ}" || { echo "ERR: sdist failed"; exit 1; }
          echo "PACKAGE=${PACKAGE}" >> $GITHUB_ENV
          echo "VERSION=${VERSION}" >> $GITHUB_ENV
          echo "TGZ=${TGZ}" >> $GITHUB_ENV
          echo "PRERELEASE=${PRERELEASE}" >> $GITHUB_ENV
          echo "DRAFT=${DRAFT}" >> $GITHUB_ENV
          mkdir -p tmp
          make -s shownote > tmp/note.md
          cat tmp/note.md
          ls -l dist

      - name: "Create Github release"
        env:
          GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
        run: |
          title="${PACKAGE} v${VERSION}"
          ghf="--notes-file=./tmp/note.md"
          if test "${DRAFT}" = "true"; then ghf="${ghf} --draft"; fi
          if test "${PRERELEASE}" = "true"; then ghf="${ghf} --prerelease"; fi
          gh release create "v${VERSION}" "dist/${TGZ}" --title="${title}" ${ghf}

      - name: "Upload to PYPI"
        id: pypi_upload
        env:
          PYPI_TOKEN: ${{secrets.PYPI_TOKEN}}
          PYPI_TEST_TOKEN: ${{secrets.PYPI_TEST_TOKEN}}
        run: |
          ls -l dist
          if test "${DRAFT}" = "false"; then
            python -m twine upload -u __token__ -p ${PYPI_TOKEN} \
              --repository pypi --disable-progress-bar dist/*
          else
            python -m twine upload -u __token__ -p ${PYPI_TEST_TOKEN} \
              --repository testpypi --disable-progress-bar dist/*
          fi