Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
77 changes: 1 addition & 76 deletions .github/workflows/merge-release.yml
Original file line number Diff line number Diff line change
@@ -1,89 +1,14 @@
name: merge-release
name: create-release
on:
push:
branches:
- release

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
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ classifiers = [
# core dependencies
python = ">=3.7"
requests = ">=2.26.0"
urllib3 = ">=2.0.2"


[tool.poetry.group.dev.dependencies]
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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,
Expand Down