|
| 1 | +name: Create release, build and upload release assets |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - '[0-9]+.[0-9]+.[0-9]+' |
| 6 | + |
| 7 | +jobs: |
| 8 | + check-version: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v2 |
| 12 | + - name: check-version |
| 13 | + run: | |
| 14 | + version=$(echo "${{ github.ref }}" | cut -d/ -f2) |
| 15 | + grep ${version} VERSION.txt || exit 1 |
| 16 | + create-release: |
| 17 | + needs: check-version |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v2 |
| 21 | + - name: Create release |
| 22 | + id: create_release |
| 23 | + uses: actions/create-release@v1 |
| 24 | + env: |
| 25 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 26 | + with: |
| 27 | + tag_name: ${{ github.ref }} |
| 28 | + release_name: Release ${{ github.ref }} |
| 29 | + draft: false |
| 30 | + prerelease: false |
| 31 | + - name: Create upload_url artifact |
| 32 | + run: | |
| 33 | + echo "${{ steps.create_release.outputs.upload_url }}" > upload_url.txt |
| 34 | + - name: Upload upload_url artifact |
| 35 | + uses: actions/upload-artifact@v2 |
| 36 | + with: |
| 37 | + name: upload_url.txt |
| 38 | + path: upload_url.txt |
| 39 | + build-and-upload-deb-asset: |
| 40 | + needs: create-release |
| 41 | + runs-on: ubuntu-latest |
| 42 | + container: |
| 43 | + image: debian:buster |
| 44 | + steps: |
| 45 | + - name: Install build dependencies |
| 46 | + run: | |
| 47 | + apt update |
| 48 | + export DEBIAN_FRONTEND=noninteractive |
| 49 | + apt -y install python3-stdeb dh-python |
| 50 | + # https://bugs.launchpad.net/bugs/1916551 |
| 51 | + sed -i -e "s/python-all/python3-all/g" /usr/lib/python3/dist-packages/stdeb/util.py |
| 52 | + - uses: actions/checkout@v2 |
| 53 | + - name: Download upload_url artifact |
| 54 | + uses: actions/download-artifact@v2 |
| 55 | + with: |
| 56 | + name: upload_url.txt |
| 57 | + - name: Get upload_url |
| 58 | + run: | |
| 59 | + export upload_url=$(cat upload_url.txt) |
| 60 | + rm upload_url.txt |
| 61 | + echo "upload_url=${upload_url}" >> $GITHUB_ENV |
| 62 | + - name: Build deb package |
| 63 | + run: | |
| 64 | + python3 setup.py --command-packages=stdeb.command bdist_deb |
| 65 | + - name: Get version |
| 66 | + run: echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV |
| 67 | + - name: Upload deb |
| 68 | + uses: actions/upload-release-asset@v1 |
| 69 | + env: |
| 70 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + with: |
| 72 | + upload_url: ${{ env.upload_url }} |
| 73 | + asset_name: ${{ format('python3-openvpn-monitor_{0}-1_all.deb', env.version) }} |
| 74 | + asset_path: ${{ format('deb_dist/python3-openvpn-monitor_{0}-1_all.deb', env.version) }} |
| 75 | + asset_content_type: application/vnd.debian.binary-package |
| 76 | + build-and-upload-rpm-asset: |
| 77 | + needs: create-release |
| 78 | + runs-on: ubuntu-latest |
| 79 | + container: |
| 80 | + image: centos:8 |
| 81 | + steps: |
| 82 | + - name: Install build dependencies |
| 83 | + run: | |
| 84 | + dnf -y install rpm-build python3 python3-setuptools git |
| 85 | + - uses: actions/checkout@v2 |
| 86 | + - name: Download upload_url artifact |
| 87 | + uses: actions/download-artifact@v2 |
| 88 | + with: |
| 89 | + name: upload_url.txt |
| 90 | + - name: Get upload_url |
| 91 | + run: | |
| 92 | + export upload_url=$(cat upload_url.txt) |
| 93 | + rm upload_url.txt |
| 94 | + echo "upload_url=${upload_url}" >> $GITHUB_ENV |
| 95 | + - name: Build rpm packages |
| 96 | + run: | |
| 97 | + python3 setup.py bdist_rpm |
| 98 | + - name: Get version |
| 99 | + run: echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV |
| 100 | + - name: Upload rpm |
| 101 | + uses: actions/upload-release-asset@v1 |
| 102 | + env: |
| 103 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 104 | + with: |
| 105 | + upload_url: ${{ env.upload_url }} |
| 106 | + asset_name: ${{ format('python3-openvpn-monitor-{0}-1.noarch.rpm', env.version) }} |
| 107 | + asset_path: ${{ format('dist/openvpn-monitor-{0}-1.noarch.rpm', env.version) }} |
| 108 | + asset_content_type: application/x-rpm |
| 109 | + upload-package-to-pypi: |
| 110 | + needs: create-release |
| 111 | + runs-on: ubuntu-latest |
| 112 | + steps: |
| 113 | + - uses: actions/checkout@v2 |
| 114 | + - name: Set up python |
| 115 | + uses: actions/setup-python@v2 |
| 116 | + with: |
| 117 | + python-version: '3.x' |
| 118 | + - name: Install dependencies |
| 119 | + run: | |
| 120 | + python -m pip install --upgrade pip |
| 121 | + pip install setuptools wheel twine |
| 122 | + - name: Build and publish |
| 123 | + env: |
| 124 | + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
| 125 | + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
| 126 | + run: | |
| 127 | + python setup.py sdist bdist_wheel |
| 128 | + twine upload dist/* |
0 commit comments