2 # This runs when version tag is pushed
13 name: "Build source package"
14 runs-on: ubuntu-latest
16 - uses: actions/checkout@v4
17 - uses: actions/setup-python@v4
18 with: {python-version: "3.11"}
19 - run: python3 -m pip install -r etc/requirements.build.txt --disable-pip-version-check
20 - run: python3 setup.py sdist
21 - run: python3 setup.py bdist_wheel
22 - uses: actions/upload-artifact@v3
23 with: {name: "dist", path: "dist"}
27 runs-on: ubuntu-latest
30 - uses: actions/checkout@v4
31 - uses: actions/setup-python@v4
32 with: {python-version: "3.11"}
34 - run: python3 -m pip install -r etc/requirements.build.txt --disable-pip-version-check
37 uses: actions/download-artifact@v3
38 with: {name: "dist", path: "dist"}
40 - name: "Install pandoc"
42 sudo -nH apt-get -u -y install pandoc
47 PACKAGE=$(python3 setup.py --name)
48 VERSION=$(python3 setup.py --version)
49 TGZ="${PACKAGE}-${VERSION}.tar.gz"
51 # default - gh:release, pypi
52 # PRERELEASE - gh:prerelease, pypi
53 # DRAFT - gh:draft,prerelease, testpypi
54 PRERELEASE="false"; DRAFT="false"
56 *[ab]*|*rc*) PRERELEASE="true";;
57 *dev*) PRERELEASE="true"; DRAFT="true";;
60 test "${{github.ref}}" = "refs/tags/v${VERSION}" || { echo "ERR: tag mismatch"; exit 1; }
61 test -f "dist/${TGZ}" || { echo "ERR: sdist failed"; exit 1; }
62 echo "PACKAGE=${PACKAGE}" >> $GITHUB_ENV
63 echo "VERSION=${VERSION}" >> $GITHUB_ENV
64 echo "TGZ=${TGZ}" >> $GITHUB_ENV
65 echo "PRERELEASE=${PRERELEASE}" >> $GITHUB_ENV
66 echo "DRAFT=${DRAFT}" >> $GITHUB_ENV
68 make -s shownote > tmp/note.md
72 - name: "Create Github release"
74 GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
76 title="${PACKAGE} v${VERSION}"
77 ghf="--notes-file=./tmp/note.md"
78 if test "${DRAFT}" = "true"; then ghf="${ghf} --draft"; fi
79 if test "${PRERELEASE}" = "true"; then ghf="${ghf} --prerelease"; fi
80 gh release create "v${VERSION}" "dist/${TGZ}" --title="${title}" ${ghf}
82 - name: "Upload to PYPI"
85 PYPI_TOKEN: ${{secrets.PYPI_TOKEN}}
86 PYPI_TEST_TOKEN: ${{secrets.PYPI_TEST_TOKEN}}
89 if test "${DRAFT}" = "false"; then
90 python -m twine upload -u __token__ -p ${PYPI_TOKEN} \
91 --repository pypi --disable-progress-bar dist/*
93 python -m twine upload -u __token__ -p ${PYPI_TEST_TOKEN} \
94 --repository testpypi --disable-progress-bar dist/*