diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 27ca81553..d612e39d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,125 +6,48 @@ on: - '*.*.*' jobs: - - Linux: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Get tag - id: tag - run: | - echo ::set-output name=tag::${GITHUB_REF#refs/tags/} - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - name: Install and set up Poetry - run: | - curl -fsS -o get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py - python get-poetry.py --preview -y - - name: Build distributions - run: | - source $HOME/.poetry/env - poetry build -vvv - - name: Upload distribution artifacts - uses: actions/upload-artifact@v1 - with: - name: pendulum-dist - path: dist - - MacOS: - runs-on: macos-latest - - steps: - - uses: actions/checkout@v2 - - name: Get tag - id: tag - run: | - echo ::set-output name=tag::${GITHUB_REF#refs/tags/} - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - name: Install and set up Poetry - run: | - curl -fsS -o get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py - python get-poetry.py --preview -y - - name: Build distributions - run: | - source $HOME/.poetry/env - poetry build -vvv - - name: Upload distribution artifacts - uses: actions/upload-artifact@v1 - with: - name: pendulum-dist - path: dist - - Windows: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v2 - - name: Get tag - id: tag - shell: bash - run: | - echo ::set-output name=tag::${GITHUB_REF#refs/tags/} - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - name: Install and setup Poetry - run: | - Invoke-WebRequest https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py -O get-poetry.py - python get-poetry.py --preview -y - - name: Build distributions - run: | - $env:Path += ";$env:Userprofile\.poetry\bin" - poetry build -vvv - - name: Upload distribution artifact - uses: actions/upload-artifact@v1 - with: - name: pendulum-dist - path: dist - Release: - needs: [Linux, MacOS, Windows] runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 + - name: Get tag id: tag - run: | - echo ::set-output name=tag::${GITHUB_REF#refs/tags/} - - name: Download distribution artifact - uses: actions/download-artifact@master + run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/} + + - name: Set up Python 3.9 + uses: actions/setup-python@v2 with: - name: pendulum-dist - path: dist - - name: Install and set up Poetry - run: | - curl -fsS -o get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py - python get-poetry.py --preview -y - - name: Check distributions + python-version: "3.9" + + - name: Install Poetry run: | - ls -la dist - - name: Publish to PyPI - env: - POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} + curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py \ + | python - -y + + - name: Update PATH + run: echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Build project for distribution + run: poetry build + + - name: Check Version + id: check-version run: | - source $HOME/.poetry/env - poetry publish + [[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] \ + || echo ::set-output name=prerelease::true + - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + uses: ncipollo/release-action@v1 with: - tag_name: ${{ steps.tag.outputs.tag }} - release_name: ${{ steps.tag.outputs.tag }} + artifacts: "dist/*" + token: ${{ secrets.GITHUB_TOKEN }} draft: false - prerelease: false + prerelease: steps.check-version.outputs.prerelease == 'true' + + - name: Publish to PyPI + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} + run: poetry publish diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 20c68cafb..e91a4a846 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,15 +6,16 @@ on: branches: [master] jobs: - Tests: + tests: name: ${{ matrix.os }} / ${{ matrix.python-version }} - runs-on: ${{ matrix.os }}-latest + runs-on: "${{ matrix.os }}-latest" continue-on-error: ${{ matrix.experimental }} strategy: matrix: os: [Ubuntu, MacOS, Windows] python-version: [3.6, 3.7, 3.8, 3.9] experimental: [false] + bootstrap-args: [""] include: - os: Ubuntu python-version: pypy3 @@ -22,6 +23,8 @@ jobs: - os: Ubuntu python-version: "3.10.0-alpha - 3.10.0" experimental: true + bootstrap-args: "--git https://github.com/python-poetry/poetry.git" + fail-fast: false steps: - uses: actions/checkout@v2 @@ -30,21 +33,33 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Get full python version + - name: Get full Python version id: full-python-version shell: bash run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") - - name: Install poetry + - name: Bootstrap poetry shell: bash - run: pip install poetry + run: | + curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py \ + | python - -y ${{ matrix.bootstrap-args }} + + - name: Update PATH + if: ${{ matrix.os != 'Windows' }} + shell: bash + run: echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Update Path for Windows + if: ${{ matrix.os == 'Windows' }} + shell: bash + run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH - name: Configure poetry shell: bash run: poetry config virtualenvs.in-project true - name: Set up cache - uses: actions/cache@v1 + uses: actions/cache@v2 id: cache with: path: .venv @@ -53,7 +68,7 @@ jobs: - name: Ensure cache is healthy if: steps.cache.outputs.cache-hit == 'true' shell: bash - run: timeout 10s poetry run pip --version >/dev/null 2>&1 || rm -rf .venv + run: timeout 10s poetry run pip --version || rm -rf .venv - name: Install dependencies shell: bash @@ -61,4 +76,4 @@ jobs: - name: Run pytest shell: bash - run: poetry run pytest -q tests + run: poetry run python -m pytest -p no:sugar -q tests/