ci: update
[rarfile.git] / .github / workflows / release.yml
blobca13a43e504dcba0b5fe8e95a5fce37df46d601d
2 # This runs when version tag is pushed
5 name: REL
7 on:
8   push:
9     tags: ["v[0-9]*"]
11 jobs:
12   sdist:
13     name: "Build source package"
14     runs-on: ubuntu-latest
15     steps:
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"}
25   publish:
26     name: "Publish"
27     runs-on: ubuntu-latest
28     needs: [sdist]
29     steps:
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
36       - name: "Get files"
37         uses: actions/download-artifact@v3
38         with: {name: "dist", path: "dist"}
40       - name: "Install pandoc"
41         run: |
42           sudo -nH apt-get -u -y install pandoc
43           pandoc --version
45       - name: "Prepare"
46         run: |
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"
55           case "${VERSION}" in
56             *[ab]*|*rc*) PRERELEASE="true";;
57             *dev*) PRERELEASE="true"; DRAFT="true";;
58           esac
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
67           mkdir -p tmp
68           make -s shownote > tmp/note.md
69           cat tmp/note.md
70           ls -l dist
72       - name: "Create Github release"
73         env:
74           GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
75         run: |
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"
83         id: pypi_upload
84         env:
85           PYPI_TOKEN: ${{secrets.PYPI_TOKEN}}
86           PYPI_TEST_TOKEN: ${{secrets.PYPI_TEST_TOKEN}}
87         run: |
88           ls -l dist
89           if test "${DRAFT}" = "false"; then
90             python -m twine upload -u __token__ -p ${PYPI_TOKEN} \
91               --repository pypi --disable-progress-bar dist/*
92           else
93             python -m twine upload -u __token__ -p ${PYPI_TEST_TOKEN} \
94               --repository testpypi --disable-progress-bar dist/*
95           fi