From 5ef8b0a8c3d5d42bcf8b0ea7a58f2bc4d32288c7 Mon Sep 17 00:00:00 2001 From: Nina Bernick Date: Fri, 26 Jul 2024 11:20:20 -0700 Subject: [PATCH 1/9] add tags to docker image with release-please --- .github/workflows/build-and-push.yml | 15 ++++++++++++++- .github/workflows/conventional-commits.yml | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/conventional-commits.yml diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 7577789..825d810 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -4,6 +4,8 @@ on: push: branches: - main + - ninabernick/semver + workflow_dispatch: jobs: build-and-push: @@ -37,6 +39,16 @@ jobs: - name: Build with Poetry run: make build-wheel + + - name: Release Please Action + id: release + uses: google-github-actions/release-please-action@v4 + with: + release-type: simple + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Print version + run: echo "Calculated version is ${{ steps.release.outputs.version }}" - name: Build and push Docker image uses: docker/build-push-action@v2 @@ -44,4 +56,5 @@ jobs: context: . push: true tags: | - ghcr.io/${{ github.repository }}:latest + ghcr.io/${{ github.repository }}-test:latest + ghcr.io/${{ github.repository }}-test:${{ steps.release.outputs.version }} diff --git a/.github/workflows/conventional-commits.yml b/.github/workflows/conventional-commits.yml new file mode 100644 index 0000000..6ecc0d4 --- /dev/null +++ b/.github/workflows/conventional-commits.yml @@ -0,0 +1,15 @@ +name: Ensure all PRs have conventional commit titles +on: + pull_request: + types: + - edited + - opened + - synchronize + - reopened + +jobs: + conventional_commit_title: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: chanzuckerberg/github-actions/.github/actions/conventional-commits@main \ No newline at end of file From 0b0de7a8ccd4d0b905e1d757431871302e6fd0d9 Mon Sep 17 00:00:00 2001 From: Nina Bernick Date: Fri, 26 Jul 2024 11:27:22 -0700 Subject: [PATCH 2/9] conditionally set docker tag -- testing only --- .github/workflows/build-and-push.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 825d810..4dc34c3 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -47,8 +47,14 @@ jobs: release-type: simple token: ${{ secrets.GITHUB_TOKEN }} - - name: Print version - run: echo "Calculated version is ${{ steps.release.outputs.version }}" + - name: Determine Docker tag + id: docker_tag + run: | + if [ "${{ github.ref }}" == "refs/heads/main" ]; then + echo "::set-output name=tag::${{ steps.release.outputs.version }}" + else + echo "::set-output name=tag::latest" + fi - name: Build and push Docker image uses: docker/build-push-action@v2 @@ -56,5 +62,4 @@ jobs: context: . push: true tags: | - ghcr.io/${{ github.repository }}-test:latest - ghcr.io/${{ github.repository }}-test:${{ steps.release.outputs.version }} + ghcr.io/${{ github.repository }}-test:${{ steps.docker_tag.outputs.version }} From 81ead99412c545cf22bdceeb21abf3d2b7a4c9c4 Mon Sep 17 00:00:00 2001 From: Nina Bernick Date: Fri, 26 Jul 2024 11:34:53 -0700 Subject: [PATCH 3/9] update env store of tag --- .github/workflows/build-and-push.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 4dc34c3..65e39b3 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -51,9 +51,9 @@ jobs: id: docker_tag run: | if [ "${{ github.ref }}" == "refs/heads/main" ]; then - echo "::set-output name=tag::${{ steps.release.outputs.version }}" + echo "tag=${{ steps.release.outputs.version }}" >> $GITHUB_ENV else - echo "::set-output name=tag::latest" + echo "tag=latest" >> $GITHUB_ENV fi - name: Build and push Docker image @@ -62,4 +62,4 @@ jobs: context: . push: true tags: | - ghcr.io/${{ github.repository }}-test:${{ steps.docker_tag.outputs.version }} + ghcr.io/${{ github.repository }}-test:${{ env.tag }} From 361f841f5de376e37dfcdd89136c3d0d5f4b3852 Mon Sep 17 00:00:00 2001 From: Nina Bernick Date: Fri, 26 Jul 2024 11:46:09 -0700 Subject: [PATCH 4/9] upgrade docker build and push --- .github/workflows/build-and-push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 65e39b3..5bf71b0 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -42,7 +42,7 @@ jobs: - name: Release Please Action id: release - uses: google-github-actions/release-please-action@v4 + uses: googleapis/release-please-action@v4 with: release-type: simple token: ${{ secrets.GITHUB_TOKEN }} @@ -57,7 +57,7 @@ jobs: fi - name: Build and push Docker image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v6 with: context: . push: true From ac0c183b29ffcb58d350086ffef552a241df2cc1 Mon Sep 17 00:00:00 2001 From: Nina Bernick Date: Fri, 26 Jul 2024 11:53:20 -0700 Subject: [PATCH 5/9] remove testing code --- .github/workflows/build-and-push.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 5bf71b0..27b330b 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - ninabernick/semver workflow_dispatch: jobs: @@ -47,14 +46,6 @@ jobs: release-type: simple token: ${{ secrets.GITHUB_TOKEN }} - - name: Determine Docker tag - id: docker_tag - run: | - if [ "${{ github.ref }}" == "refs/heads/main" ]; then - echo "tag=${{ steps.release.outputs.version }}" >> $GITHUB_ENV - else - echo "tag=latest" >> $GITHUB_ENV - fi - name: Build and push Docker image uses: docker/build-push-action@v6 @@ -62,4 +53,5 @@ jobs: context: . push: true tags: | - ghcr.io/${{ github.repository }}-test:${{ env.tag }} + ghcr.io/${{ github.repository }}:${{ steps.release.outputs.version }} + ghcr.io/${{ github.repository }}:latest From 3437059a841de98de1c753f61cbf0ecb011e06c6 Mon Sep 17 00:00:00 2001 From: Nina Bernick Date: Wed, 31 Jul 2024 13:13:20 -0700 Subject: [PATCH 6/9] build and push on release --- .github/workflows/build-and-push.yml | 16 ++++------------ .github/workflows/release-please.yml | 23 +++++++++++++++++++++++ Dockerfile | 4 ++-- pyproject.toml | 9 ++++++--- 4 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/release-please.yml diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 27b330b..a43946f 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -1,9 +1,9 @@ name: Build and push docker image on: - push: - branches: - - main + release: + types: + - published workflow_dispatch: jobs: @@ -38,14 +38,6 @@ jobs: - name: Build with Poetry run: make build-wheel - - - name: Release Please Action - id: release - uses: googleapis/release-please-action@v4 - with: - release-type: simple - token: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Docker image uses: docker/build-push-action@v6 @@ -53,5 +45,5 @@ jobs: context: . push: true tags: | - ghcr.io/${{ github.repository }}:${{ steps.release.outputs.version }} + ghcr.io/${{ github.repository }}:${{ github.event.release.tag_name }} ghcr.io/${{ github.repository }}:latest diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..e3f03ff --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,23 @@ +name: Release Please + +on: + push: + branches: + - main + - ninabernick/semver + +jobs: + release: + name: Run release-please + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run release-please + uses: google-github-actions/release-please-action@v3 + with: + release-type: python + token: ${{ secrets.GITHUB_TOKEN }} + bump-minor-pre-major: true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 12ac4c3..85e1459 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,8 @@ RUN apt update && \ COPY requirements.txt . RUN pip install -r requirements.txt -COPY dist/platformics-0.1.0-py3-none-any.whl /tmp/platformics-0.1.0-py3-none-any.whl -RUN cd /tmp/ && pip install platformics-0.1.0-py3-none-any.whl && rm -rf /tmp/*.whl +COPY dist /tmp/dist +RUN cd /tmp/dist && pip install *.whl && rm -rf /tmp/*.whl RUN mkdir -p /app WORKDIR /app diff --git a/pyproject.toml b/pyproject.toml index b6bb969..02bcc1f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "platformics" -version = "0.1.0" +version = "0.0.0" # placeholder version description = "Platformics bio entities framework" authors = ["CZI Infectious Disease Team "] license = "MIT License" @@ -51,8 +51,11 @@ sqlalchemy_utils = "^0.41.1" strawberry-graphql = "^0.217.0" [build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" +requires = ["poetry-core", "poetry-dynamic-versioning>=1.0.0,<2.0.0"] +build-backend = "poetry_dynamic_versioning.backend" + +[tool.poetry-dynamic-versioning] +enable = true [tool.black] line-length = 120 From 46ac7c5565a0f403232a52af24c22ac2f6babf83 Mon Sep 17 00:00:00 2001 From: Nina Bernick Date: Wed, 31 Jul 2024 13:19:37 -0700 Subject: [PATCH 7/9] remove testing code --- .github/workflows/release-please.yml | 1 - pyproject.toml | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index e3f03ff..f61cc89 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - ninabernick/semver jobs: release: diff --git a/pyproject.toml b/pyproject.toml index 02bcc1f..54b18d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,7 @@ [tool.poetry] name = "platformics" -version = "0.0.0" # placeholder version +# placeholder version that will be replace by poetry-dynamic-versioning +version = "0.0.0" description = "Platformics bio entities framework" authors = ["CZI Infectious Disease Team "] license = "MIT License" @@ -52,6 +53,7 @@ strawberry-graphql = "^0.217.0" [build-system] requires = ["poetry-core", "poetry-dynamic-versioning>=1.0.0,<2.0.0"] +# a wrapper for poetry.core.masonry.api build-backend = "poetry_dynamic_versioning.backend" [tool.poetry-dynamic-versioning] From cdb4f4335672908f74b6febb1e63e58b44ab93ec Mon Sep 17 00:00:00 2001 From: Nina Bernick Date: Wed, 31 Jul 2024 13:22:19 -0700 Subject: [PATCH 8/9] add doc --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index bb36e2d..18f3d23 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ The libraries and tools that make Platformics work: ## Roadmap - [ ] Plugin hooks to add business logic to generated GQL resolvers - [ ] Support arbitrary class inheritance hierarchies +- [ ] Package and publish to PyPI ## How to set up your own platformics API 1. Copy the test_app boilerplate code to your own repository. @@ -43,6 +44,9 @@ The libraries and tools that make Platformics work: 4. Browse to http://localhost:9009/graphql to interact with your api! 5. Run `make token` to generate an authorization token that you can use to interact with the API. The `make` target copies the necessary headers to the system clipboard. Paste the token into the `headers` section at the bottom of the GraphQL explorer API +## Versioning platformics +Right now, platformics is used in downstream applications by using the platformics image as the base Docker image. To select a version of platformics, add the appropriate version tags to the docker image. + ## Iterating on your schema 1. Make changes to `schema/schema.yml` 2. Run `make codegen` to re-run code gen and restart the API service From 3fb4ec54a7dd9f95431a801b964e533bda44fc88 Mon Sep 17 00:00:00 2001 From: Nina Bernick Date: Wed, 31 Jul 2024 14:36:45 -0700 Subject: [PATCH 9/9] install plugin in gh workflow: --- .github/workflows/build-and-push.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index a43946f..0dab73b 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -21,6 +21,7 @@ jobs: - name: install poetry run: | python -m pip install --no-cache-dir poetry==1.8 supervisor + poetry self add "poetry-dynamic-versioning[plugin]" - name: set up docker run: |