diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 586db8cb7..0621cf750 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -276,12 +276,13 @@ jobs: python3 -m pip install --upgrade pip python3 -m pip install setuptools python3 -m pip install wheel + python3 -m pip install build # install synapseclient - python3 setup.py install + python3 -m pip install . # create distribution - python3 setup.py sdist bdist_wheel + python3 -m build SDIST_PACKAGE_NAME="synapseclient-${{env.VERSION}}.tar.gz" BDIST_PACKAGE_NAME="synapseclient-${{env.VERSION}}-py3-none-any.whl" @@ -332,12 +333,11 @@ jobs: # re-download the built package to the appropriate pypi server. # we upload prereleases to test.pypi.org and releases to pypi.org. - deploy-test: + deploy: needs: package - if: 'github.event.release.prerelease' runs-on: ubuntu-latest environment: - url: 'https://test.pypi.org/p/synapseclient' + url: ${{ github.event.release.prerelease == 'true' && 'https://test.pypi.org/p/synapseclient' || 'https://pypi.org/p/synapseclient' }} name: pypi permissions: id-token: write @@ -354,122 +354,68 @@ jobs: name: ${{ needs.package.outputs.bdist-package-name }} path: dist - name: deploy-to-test-pypi + if: 'github.event.release.prerelease' uses: pypa/gh-action-pypi-publish@release/v1 with: repository-url: https://test.pypi.org/legacy/ - - deploy-prod: - needs: package - if: '!github.event.release.prerelease' - runs-on: ubuntu-latest - environment: - url: 'https://pypi.org/p/synapseclient' - name: pypi - permissions: - id-token: write - steps: - - name: download-sdist - uses: actions/download-artifact@v2 - with: - name: ${{ needs.package.outputs.sdist-package-name }} - path: dist - - - name: download-bdist - uses: actions/download-artifact@v2 - with: - name: ${{ needs.package.outputs.bdist-package-name }} - path: dist - name: deploy-to-prod-pypi + if: '!github.event.release.prerelease' uses: pypa/gh-action-pypi-publish@release/v1 - # - name: deploy-to-pypi - # shell: bash - # run: | - # python3 -m pip install twine - # if [[ "${{ github.event.release.prerelease}}" == "false" ]]; then - # # production deploy to prod pypi server + # on each of our matrix platforms, download the newly uploaded package from pypi and confirm its version + check-deploy: + needs: deploy - # PYPI_NAME="pypi" - # PYPI_URL="https://pypi.org" - # PYPI_REPO="https://upload.pypi.org/legacy/" - # PYPI_USERNAME="${{ secrets.PYPI_PROD_USERNAME }}" - # PYPI_PASSWORD="${{ secrets.PYPI_PROD_PASSWORD }}" - # else - # # staging deploy to test pypi server - - # PYPI_NAME=testpypi - # PYPI_URL="https://test.pypi.org" - # PYPI_REPO=https://test.pypi.org/legacy/ - # PYPI_USERNAME="${{ secrets.PYPI_TEST_USERNAME }}" - # PYPI_PASSWORD="${{ secrets.PYPI_TEST_PASSWORD }}" - # PYPI_INDEX_URL="https://test.pypi.org/simple/" - # fi + strategy: + matrix: + os: [ubuntu-20.04, macos-11, windows-2019] - # # create .pypirc file - # echo "[distutils]" > ~/.pypirc - # echo "index-servers=$PYPI_NAME" >> ~/.pypirc - # echo >> ~/.pypirc - # echo "[$PYPI_NAME]" >> ~/.pypirc - # echo "repository: $PYPI_REPO" >> ~/.pypirc - # echo "username:$PYPI_USERNAME" >> ~/.pypirc - # echo "password:$PYPI_PASSWORD" >> ~/.pypirc + # python versions should be consistent with the strategy matrix and the runs-integration-tests versions + python: [3.8, '3.9', '3.10', '3.11'] - # twine upload --repository $PYPI_NAME dist/* + runs-on: ${{ matrix.os }} - # on each of our matrix platforms, download the newly uploaded package from pypi and confirm its version - # check-deploy: - # needs: deploy + steps: + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} - # strategy: - # matrix: - # os: [ubuntu-20.04, macos-11, windows-2019] + - name: check-pypi + shell: bash + run: | + if [[ "${{ github.event.release.prerelease}}" == "false" ]]; then + PYPI_INDEX_URL="https://pypi.org/simple/" + else + PYPI_INDEX_URL="https://test.pypi.org/simple/" + fi - # # python versions should be consistent with the strategy matrix and the runs-integration-tests versions - # python: [3.8, '3.9', '3.10', '3.11'] + RELEASE_TAG="${{ github.event.release.tag_name }}" + if [[ $RELEASE_TAG =~ ^v?([[:digit:]\.]+)(-rc)? ]]; then + VERSION="${BASH_REMATCH[1]}" + if [[ "${{ github.event.release.prerelease}}" == "true" ]]; then + VERSION="$VERSION.$GITHUB_RUN_NUMBER" + fi + else + echo "Unrecognized release tag" + exit 1 + fi - # runs-on: ${{ matrix.os }} + # it can take some time for the packages to become available in pypi after uploading + for i in 5 10 20 40; do + if pip3 install --index-url $PYPI_INDEX_URL --extra-index-url https://pypi.org/simple "synapseclient==$VERSION"; then + ACTUAL_VERSION=$(synapse --version) - # steps: - # - uses: actions/setup-python@v4 - # with: - # python-version: ${{ matrix.python }} - - # - name: check-pypi - # shell: bash - # run: | - # if [[ "${{ github.event.release.prerelease}}" == "false" ]]; then - # PYPI_INDEX_URL="https://pypi.org/simple/" - # else - # PYPI_INDEX_URL="https://test.pypi.org/simple/" - # fi - - # RELEASE_TAG="${{ github.event.release.tag_name }}" - # if [[ $RELEASE_TAG =~ ^v?([[:digit:]\.]+)(-rc)? ]]; then - # VERSION="${BASH_REMATCH[1]}" - # if [[ "${{ github.event.release.prerelease}}" == "true" ]]; then - # VERSION="$VERSION.$GITHUB_RUN_NUMBER" - # fi - # else - # echo "Unrecognized release tag" - # exit 1 - # fi - - # # it can take some time for the packages to become available in pypi after uploading - # for i in 5 10 20 40; do - # if pip3 install --index-url $PYPI_INDEX_URL --extra-index-url https://pypi.org/simple "synapseclient==$VERSION"; then - # ACTUAL_VERSION=$(synapse --version) - - # if [ -n "$(echo "$ACTUAL_VERSION" | grep -oF "$VERSION")" ]; then - # echo "Successfully installed version $VERSION" - # exit 0 - # else - # echo "Expected version $VERSION, found $ACTUAL_VERSION instead" - # exit 1 - # fi - # fi - - # sleep $i - # done - - # echo "Failed to install expected version $VERSION" - # exit 1 + if [ -n "$(echo "$ACTUAL_VERSION" | grep -oF "$VERSION")" ]; then + echo "Successfully installed version $VERSION" + exit 0 + else + echo "Expected version $VERSION, found $ACTUAL_VERSION instead" + exit 1 + fi + fi + + sleep $i + done + + echo "Failed to install expected version $VERSION" + exit 1