From 429add9000d72911eecfd7af3541c7b4571ee558 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 12 Sep 2021 21:17:56 +1000 Subject: [PATCH 1/9] Updates for docker workflows: - check_version_number script now handles stable and development codes --- .../{docker_build.yaml => docker_latest.yaml} | 3 ++ .github/workflows/docker_stable.yaml | 42 +++++++++++++++++++ .../{docker_publish.yaml => docker_tag.yaml} | 2 +- ci/check_version_number.py | 38 +++++++++++++++-- 4 files changed, 80 insertions(+), 5 deletions(-) rename .github/workflows/{docker_build.yaml => docker_latest.yaml} (90%) create mode 100644 .github/workflows/docker_stable.yaml rename .github/workflows/{docker_publish.yaml => docker_tag.yaml} (91%) diff --git a/.github/workflows/docker_build.yaml b/.github/workflows/docker_latest.yaml similarity index 90% rename from .github/workflows/docker_build.yaml rename to .github/workflows/docker_latest.yaml index ec8bdf7306..355afa5b87 100644 --- a/.github/workflows/docker_build.yaml +++ b/.github/workflows/docker_latest.yaml @@ -15,6 +15,9 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v2 + - name: Check version number + run: | + python3 ci/check_version_number.py --dev - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx diff --git a/.github/workflows/docker_stable.yaml b/.github/workflows/docker_stable.yaml new file mode 100644 index 0000000000..3d435e40da --- /dev/null +++ b/.github/workflows/docker_stable.yaml @@ -0,0 +1,42 @@ +# Build and push latest docker image on push to master branch + +name: Docker Build + +on: + push: + branches: + - 'stable' + +jobs: + + docker: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + - name: Check version number + run: | + python3 ci/check_version_number.py --release + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to Dockerhub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and Push + uses: docker/build-push-action@v2 + with: + context: ./docker + platforms: linux/amd64,linux/arm64,linux/arm/v7 + push: true + target: production + build-args: + branch: stable + repository: inventree/inventree + tags: inventree/inventree:stable + - name: Image Digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/docker_publish.yaml b/.github/workflows/docker_tag.yaml similarity index 91% rename from .github/workflows/docker_publish.yaml rename to .github/workflows/docker_tag.yaml index 1bb3f05f9c..b3b0c53d12 100644 --- a/.github/workflows/docker_publish.yaml +++ b/.github/workflows/docker_tag.yaml @@ -15,7 +15,7 @@ jobs: uses: actions/checkout@v2 - name: Check Release tag run: | - python3 ci/check_version_number.py ${{ github.event.release.tag_name }} + python3 ci/check_version_number.py --release --tag ${{ github.event.release.tag_name }} - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx diff --git a/ci/check_version_number.py b/ci/check_version_number.py index 55a42e2484..9b4d9f1a31 100644 --- a/ci/check_version_number.py +++ b/ci/check_version_number.py @@ -27,12 +27,42 @@ if __name__ == '__main__': version = results[0] parser = argparse.ArgumentParser() - parser.add_argument('tag', help='Version tag', action='store') + parser.add_argument('-t', '--tag', help='Compare against specified version tag', action='store') + parser.add_argument('-r', '--release', help='Check that this is a release version', action='store_true') + parser.add_argument('-d', '--dev', help='Check that this is a development version', action='store_true') args = parser.parse_args() - if not args.tag == version: - print(f"Release tag '{args.tag}' does not match INVENTREE_SW_VERSION '{version}'") - sys.exit(1) + if args.dev: + """ + Check that the current verrsion number matches the "development" format + e.g. "0.5 dev" + """ + + pattern = "^\d+(\.\d+)+ dev$" + + result = re.match(pattern, version) + + if result is None: + print(f"Version number '{version}' does not match required pattern for development branch") + sys.exit(1) + + elif args.release: + """ + Check that the current version number matches the "release" format + e.g. "0.5.1" + """ + + pattern = "^\d+(\.\d+)+$" + + result = re.match(pattern, version) + + if result is None: + print(f"Version number '{version}' does not match required pattern for stable branch") + + if args.tag: + if not args.tag == version: + print(f"Release tag '{args.tag}' does not match INVENTREE_SW_VERSION '{version}'") + sys.exit(1) sys.exit(0) \ No newline at end of file From 5ee004eabde3ef8bae3a7756c164162ff7fe0095 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 12 Sep 2021 21:36:14 +1000 Subject: [PATCH 2/9] Add workflow to check version number --- .github/workflows/version.yaml | 24 ++++++++++++++++++++++++ ci/check_version_number.py | 19 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 .github/workflows/version.yaml diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml new file mode 100644 index 0000000000..63a3fd4900 --- /dev/null +++ b/.github/workflows/version.yaml @@ -0,0 +1,24 @@ +# Check that the version number format matches the current branch + +name: Version Numbering + +on: + push: + branches-ignore: + - l10* + + pull_request: + branches-ignore: + - l10* + +jobs: + + check: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + - name: Check version number + run: | + python3 ci/check_version_number.py --branch ${GITHUB_REF##*/} \ No newline at end of file diff --git a/ci/check_version_number.py b/ci/check_version_number.py index 9b4d9f1a31..060dfb0654 100644 --- a/ci/check_version_number.py +++ b/ci/check_version_number.py @@ -30,9 +30,27 @@ if __name__ == '__main__': parser.add_argument('-t', '--tag', help='Compare against specified version tag', action='store') parser.add_argument('-r', '--release', help='Check that this is a release version', action='store_true') parser.add_argument('-d', '--dev', help='Check that this is a development version', action='store_true') + parser.add_argument('-b', '--branch', help='Check against a particular branch', action='store') args = parser.parse_args() + if args.branch: + """ + Version number requirement depends on format of branch + + 'master': development branch + 'stable': release branch + """ + + print(f"Checking version number for branch '{args.branch}'") + + if args.branch == 'master': + print("Development branch") + args.dev = True + elif args.branch == 'stable': + print("Stable release branch") + args.release = True + if args.dev: """ Check that the current verrsion number matches the "development" format @@ -59,6 +77,7 @@ if __name__ == '__main__': if result is None: print(f"Version number '{version}' does not match required pattern for stable branch") + sys.exit(1) if args.tag: if not args.tag == version: From fd192b65bf97cf68d9ca1459c8eea8ee848168d6 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 12 Sep 2021 21:37:30 +1000 Subject: [PATCH 3/9] workflow fix --- .github/workflows/version.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml index 63a3fd4900..c45b319fb9 100644 --- a/.github/workflows/version.yaml +++ b/.github/workflows/version.yaml @@ -17,8 +17,8 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout Code - uses: actions/checkout@v2 - - name: Check version number - run: | - python3 ci/check_version_number.py --branch ${GITHUB_REF##*/} \ No newline at end of file + - name: Checkout Code + uses: actions/checkout@v2 + - name: Check version number + run: | + python3 ci/check_version_number.py --branch ${GITHUB_REF##*/} \ No newline at end of file From 5770789ddb7148b348bd7de28f1e3afb9f7710f1 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 12 Sep 2021 21:40:56 +1000 Subject: [PATCH 4/9] more fix --- .github/workflows/version.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml index c45b319fb9..43dca6f8ef 100644 --- a/.github/workflows/version.yaml +++ b/.github/workflows/version.yaml @@ -16,9 +16,9 @@ jobs: check: runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v2 - - name: Check version number - run: | - python3 ci/check_version_number.py --branch ${GITHUB_REF##*/} \ No newline at end of file + steps: + - name: Checkout Code + uses: actions/checkout@v2 + - name: Check version number + run: | + python3 ci/check_version_number.py --branch ${GITHUB_REF##*/} \ No newline at end of file From 6baaf98d7e83322c260ea8373a20f64dbf606c3c Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 12 Sep 2021 21:49:13 +1000 Subject: [PATCH 5/9] fix environment variable --- .github/workflows/version.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml index 43dca6f8ef..c37b26d059 100644 --- a/.github/workflows/version.yaml +++ b/.github/workflows/version.yaml @@ -21,4 +21,4 @@ jobs: uses: actions/checkout@v2 - name: Check version number run: | - python3 ci/check_version_number.py --branch ${GITHUB_REF##*/} \ No newline at end of file + python3 ci/check_version_number.py --branch ${{ GITHUB_REF }} \ No newline at end of file From 06f323fe479f3139c8bdc3487caf146e0a254b9d Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 12 Sep 2021 21:52:02 +1000 Subject: [PATCH 6/9] Use GITHUB_BASE_REF --- .github/workflows/version.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml index c37b26d059..90dba271e7 100644 --- a/.github/workflows/version.yaml +++ b/.github/workflows/version.yaml @@ -3,10 +3,6 @@ name: Version Numbering on: - push: - branches-ignore: - - l10* - pull_request: branches-ignore: - l10* @@ -21,4 +17,4 @@ jobs: uses: actions/checkout@v2 - name: Check version number run: | - python3 ci/check_version_number.py --branch ${{ GITHUB_REF }} \ No newline at end of file + python3 ci/check_version_number.py --branch ${{ GITHUB_BASE_REF }} \ No newline at end of file From 3d4a8bdd22b94647d0c091384ce04711f8e32648 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 12 Sep 2021 21:54:59 +1000 Subject: [PATCH 7/9] env prefix --- .github/workflows/version.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml index 90dba271e7..82ccb05077 100644 --- a/.github/workflows/version.yaml +++ b/.github/workflows/version.yaml @@ -17,4 +17,4 @@ jobs: uses: actions/checkout@v2 - name: Check version number run: | - python3 ci/check_version_number.py --branch ${{ GITHUB_BASE_REF }} \ No newline at end of file + python3 ci/check_version_number.py --branch ${{ env.GITHUB_BASE_REF }} From 08397c5e5f567ea51dd4f661e355b7bf3db683e2 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 12 Sep 2021 22:06:06 +1000 Subject: [PATCH 8/9] different syntax --- .github/workflows/version.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml index 82ccb05077..6e32d9e148 100644 --- a/.github/workflows/version.yaml +++ b/.github/workflows/version.yaml @@ -17,4 +17,4 @@ jobs: uses: actions/checkout@v2 - name: Check version number run: | - python3 ci/check_version_number.py --branch ${{ env.GITHUB_BASE_REF }} + python3 ci/check_version_number.py --branch ${{ github.base_ref }} From 7b21270baf4273eb38bc44f654f7a43faa90ba71 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 12 Sep 2021 22:08:51 +1000 Subject: [PATCH 9/9] Bump version number --- InvenTree/InvenTree/version.py | 2 +- ci/check_version_number.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/InvenTree/InvenTree/version.py b/InvenTree/InvenTree/version.py index 62dd0287ad..307e801121 100644 --- a/InvenTree/InvenTree/version.py +++ b/InvenTree/InvenTree/version.py @@ -8,7 +8,7 @@ import re import common.models -INVENTREE_SW_VERSION = "0.5.0 pre" +INVENTREE_SW_VERSION = "0.5.0 dev" INVENTREE_API_VERSION = 12 diff --git a/ci/check_version_number.py b/ci/check_version_number.py index 060dfb0654..ca2dbd71c7 100644 --- a/ci/check_version_number.py +++ b/ci/check_version_number.py @@ -45,10 +45,10 @@ if __name__ == '__main__': print(f"Checking version number for branch '{args.branch}'") if args.branch == 'master': - print("Development branch") + print("- This is a development branch") args.dev = True elif args.branch == 'stable': - print("Stable release branch") + print("- This is a stable release branch") args.release = True if args.dev: