diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3b9065f..bc9a294 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,6 +5,16 @@ version: 2 updates: + + - package-ecosystem: "github-actions" + directory: "/" + open-pull-requests-limit: 2 + schedule: + interval: "monthly" + commit-message: + prefix: "github actions " + include: scope + - package-ecosystem: "pip" directory: "/" # Location of package manifests schedule: diff --git a/.github/workflows/merge-release.yml b/.github/workflows/merge-release.yml index b6cbb56..1e2c7cd 100644 --- a/.github/workflows/merge-release.yml +++ b/.github/workflows/merge-release.yml @@ -1,4 +1,4 @@ -name: merge-release +name: create-release on: push: branches: @@ -6,84 +6,9 @@ on: jobs: - test-publish: - runs-on: ubuntu-latest - if: github.repository == 'NHSDigital/mesh-client' && github.actor != 'dependabot[bot]' - steps: - - name: checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: print branch info - run: | - git branch - echo "GITHUB_HEAD_REF=${GITHUB_HEAD_REF}" - echo "GITHUB_BASE_REF=${GITHUB_BASE_REF}" - git log --oneline -n 10 - - - name: clean - run: | - git clean -fdx - find . -type f | xargs chmod g+w - - - name: merge into base_branch - if: ${{ github.event_name == 'pull_request' }} - run: | - echo base branch "${{ github.base_ref }}" - echo pr branch "${{ github.head_ref }}" - git checkout "${{ github.base_ref }}" - git checkout -b "merging-${{ github.event.number }}" - git merge --ff-only "${{ github.event.pull_request.head.sha }}" - - - name: setup python - uses: actions/setup-python@v3 - with: - python-version: "3.8" - - - name: setup poetry - uses: abatilo/actions-poetry@v2 - with: - poetry-version: 1.5.1 - - - name: add poetry plugins - run: | - poetry self add "poetry-dynamic-versioning[plugin]" - - - name: build dist - run: | - RELEASE_VERSION="$(poetry version patch | rev | cut -d' ' -f1 | rev)" - echo "${RELEASE_VERSION}" - echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV - if [[ "${RELEASE_VERSION}" == "0.0.0" ]]; then - echo "${RELEASE_VERSION} = 0.0.0" - exit 1 - fi - git tag "${RELEASE_VERSION}" - RELEASE_VERSION="${RELEASE_VERSION}" make dist - ls -l dist - - - name: test publish - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.TEST_PYPI_TOKEN }} - repository-url: https://test.pypi.org/legacy/ - - - name: install and test - run: | - python3 -m pip install requests - python3 -m pip install --index-url https://test.pypi.org/simple/ "mesh-client==${RELEASE_VERSION}" - INSTALLED_VERSION="$(python3 -c 'import mesh_client; print(mesh_client.__version__)')" - if [[ "${INSTALLED_VERSION}" != "${RELEASE_VERSION}" ]]; then - echo "${INSTALLED_VERSION} != ${RELEASE_VERSION}" - exit 1 - fi - release: runs-on: ubuntu-latest if: github.repository == 'NHSDigital/mesh-client' && github.actor != 'dependabot[bot]' - needs: - - test-publish steps: - name: checkout uses: actions/checkout@v3 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 0b89022..9f7cbb3 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -259,3 +259,81 @@ jobs: version="v$(poetry version patch | rev | cut -d' ' -f1 | rev)" echo "RELEASE_VERSION=$version" >> $GITHUB_ENV echo "${version}" + + + publish: + runs-on: ubuntu-latest + if: github.repository == 'NHSDigital/mesh-client' && github.actor != 'dependabot[bot]' + needs: + - coverage + - lint + - tox + steps: + - name: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: print branch info + run: | + git branch + echo "GITHUB_HEAD_REF=${GITHUB_HEAD_REF}" + echo "GITHUB_BASE_REF=${GITHUB_BASE_REF}" + git log --oneline -n 10 + + - name: clean + run: | + git clean -fdx + find . -type f | xargs chmod g+w + + - name: merge into base_branch + if: ${{ github.event_name == 'pull_request' }} + run: | + echo base branch "${{ github.base_ref }}" + echo pr branch "${{ github.head_ref }}" + git checkout "${{ github.base_ref }}" + git checkout -b "merging-${{ github.event.number }}" + git merge --ff-only "${{ github.event.pull_request.head.sha }}" + + - name: setup python + uses: actions/setup-python@v3 + with: + python-version: "3.8" + + - name: setup poetry + uses: abatilo/actions-poetry@v2 + with: + poetry-version: 1.5.1 + + - name: add poetry plugins + run: | + poetry self add "poetry-dynamic-versioning[plugin]" + + - name: build dist + run: | + RELEASE_VERSION="$(poetry version prepatch | rev | cut -d' ' -f1 | rev | sed -E 's/0+$//' )$(date '+%Y%m%d%H%M%S')" + echo "${RELEASE_VERSION}" + echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV + if [[ "${RELEASE_VERSION}" == "0.0.0" ]]; then + echo "${RELEASE_VERSION} = 0.0.0" + exit 1 + fi + RELEASE_VERSION="${RELEASE_VERSION}" make dist + ls -l dist + + - name: test publish + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.TEST_PYPI_TOKEN }} + repository-url: https://test.pypi.org/legacy/ + + - name: install and test + run: | + poetry export -f requirements.txt -o requirements.txt + python3 -m pip install -r requirements.txt + python3 -m pip install --index-url https://test.pypi.org/simple/ "mesh-client==${RELEASE_VERSION}" + INSTALLED_VERSION="$(python3 -c 'import mesh_client; print(mesh_client.__version__)')" + if [[ "${INSTALLED_VERSION}" != "${RELEASE_VERSION}" ]]; then + echo "${INSTALLED_VERSION} != ${RELEASE_VERSION}" + exit 1 + fi \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 8a438a4..2284f10 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1199,4 +1199,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = ">=3.7" -content-hash = "da609647213be41340739c4acba3b89a5e86ec60f5ded343d16e9f1061087bc5" +content-hash = "96630b5009c1a33c6a70455e4ef69b12f42fbe9f63b3a219959f91d35784ff9c" diff --git a/pyproject.toml b/pyproject.toml index 090a2f5..9544a04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,6 +28,7 @@ classifiers = [ # core dependencies python = ">=3.7" requests = ">=2.26.0" +urllib3 = ">=2.0.2" [tool.poetry.group.dev.dependencies] diff --git a/setup.py b/setup.py index ab20eca..a10dd1c 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ from os.path import dirname, join import toml # type: ignore[import] -from setuptools import setup # type: ignore[import] +from setuptools import setup, sic # type: ignore[import] with open(join(dirname(__file__), "pyproject.toml")) as f: pyproject = toml.loads(f.read()) @@ -21,7 +21,7 @@ setup( name=poetry_cfg["name"], - version=os.environ.get("RELEASE_VERSION", poetry_cfg["version"]), + version=sic(os.environ.get("RELEASE_VERSION", poetry_cfg["version"])), description=poetry_cfg["description"], url=poetry_cfg["repository"], long_description=long_description,