From f35f43f2ff5f471142e912c0951b570cf6266050 Mon Sep 17 00:00:00 2001 From: mirecl Date: Wed, 6 Apr 2022 16:09:40 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8B=20Add=20CD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yaml | 166 +++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..aa1a9f7 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,166 @@ +name: Releases + +on: + workflow_dispatch: + inputs: + repository: + type: choice + description: Python repository + options: + - test + - prod + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + defaults: + run: + shell: bash + + steps: + #---------------------------------------------- + # Check-out repo + #---------------------------------------------- + - name: Check out repository + uses: actions/checkout@v2 + #---------------------------------------------- + # Install python + #---------------------------------------------- + - name: Set up python + id: setup-python + uses: actions/setup-python@v2 + with: + python-version: 3.6 + #---------------------------------------------- + # Configure poetry + #---------------------------------------------- + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + #---------------------------------------------- + # Install dependencies + #---------------------------------------------- + - name: Install dependencies + run: poetry install --no-interaction --no-dev + #---------------------------------------------- + # Build + #---------------------------------------------- + - name: Build + run: poetry build + #---------------------------------------------- + # Upload wheels artifact + #---------------------------------------------- + - name: Upload wheels artifact + uses: actions/upload-artifact@v2 + with: + name: pprof + path: dist + + publish_repo: + name: Uploading to PyPi + if: github.event.inputs.repository == 'prod' + runs-on: ubuntu-latest + needs: [build] + steps: + #---------------------------------------------- + # Check-out repo + #---------------------------------------------- + - name: Check out repository + uses: actions/checkout@v3 + #---------------------------------------------- + # Download wheels artifact + #---------------------------------------------- + - name: Download wheels artifact + uses: actions/download-artifact@v2 + with: + name: pprof + path: dist + #---------------------------------------------- + # Install python + #---------------------------------------------- + - name: Set up python + id: setup-python + uses: actions/setup-python@v2 + with: + python-version: 3.6 + #---------------------------------------------- + # Install poetry + #---------------------------------------------- + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + #---------------------------------------------- + # Configure poetry + #---------------------------------------------- + - name: Configure Poetry + env: + PYPI_TOKEN: ${{ secrets.CD_PYPI }} + run: | + poetry config pypi-token.pypi $PYPI_TOKEN + #---------------------------------------------- + # Publish + #---------------------------------------------- + - name: Publish + run: | + poetry publish + + publish_test_repo: + name: Uploading to Test PyPi + if: github.event.inputs.repository == 'test' + runs-on: ubuntu-latest + needs: [build] + steps: + #---------------------------------------------- + # Check-out repo + #---------------------------------------------- + - name: Check out repository + uses: actions/checkout@v3 + #---------------------------------------------- + # Download wheels artifact + #---------------------------------------------- + - name: Download wheels artifact + uses: actions/download-artifact@v2 + with: + name: pprof + path: dist + #---------------------------------------------- + # Install python + #---------------------------------------------- + - name: Set up python + id: setup-python + uses: actions/setup-python@v2 + with: + python-version: 3.6 + #---------------------------------------------- + # Install poetry + #---------------------------------------------- + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + #---------------------------------------------- + # Configure poetry + #---------------------------------------------- + - name: Configure Poetry + env: + PYPI_TOKEN: ${{ secrets.CD_TEST_PYPI }} + run: | + poetry config repositories.testpypi https://test.pypi.org/legacy/ + poetry config pypi-token.testpypi $PYPI_TOKEN + #---------------------------------------------- + # Publish + #---------------------------------------------- + - name: Publish + run: | + poetry publish -r testpypi + \ No newline at end of file