From 642f34639080b9f33917b764b81339eb4123129f Mon Sep 17 00:00:00 2001 From: Ethan Turner Date: Thu, 16 Jul 2026 20:07:29 -0700 Subject: [PATCH] ci: add workflow to bump version and build Docker image on PR merge --- .github/workflows/docker.yml | 14 ++++++++-- .github/workflows/version-bump.yml | 41 ++++++++++++++++++++++++++++++ pyproject.toml | 15 +++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/version-bump.yml create mode 100644 pyproject.toml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1b61146..0dc3694 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -7,6 +7,15 @@ on: description: 'Version to label the Docker image under' required: true type: string + workflow_call: + inputs: + version: + required: true + type: string + +permissions: + contents: read + packages: write jobs: check_authorization: @@ -25,13 +34,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Log in to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: + context: . push: true tags: ghcr.io/libretexts/molview-lambda-api:${{ inputs.version }} \ No newline at end of file diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml new file mode 100644 index 0000000..47538ed --- /dev/null +++ b/.github/workflows/version-bump.yml @@ -0,0 +1,41 @@ +name: Version Bump and Build + +on: + pull_request: + types: [closed] + branches: [main] + +permissions: + contents: write + +jobs: + bump: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: main + fetch-depth: 0 + token: ${{ secrets.LIBREBOT_ACCESS_TOKEN }} + - name: Configure git as LibreBot + run: | + git config user.name "libretexts-bot" + git config user.email "dev@libretexts.org" + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + - name: Install bump-my-version + run: pip install bump-my-version + - name: Bump minor version + run: bump-my-version bump minor + - name: Capture new version + id: version + run: echo "value=$(bump-my-version show current_version)" >> "$GITHUB_OUTPUT" + build: + needs: bump + uses: ./.github/workflows/docker.yml + with: + version: ${{needs.bump.outputs.version}} + secrets: inherit \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d936d48 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,15 @@ +[project] +name = "molview-lambda-api" +version = "1.10.0" + +[tool.bumpversion] +current_version = "1.10.0" +commit = true +tag = true +commit_args = "-m 'chore(release): {new_version} [skip ci]'" +tag_name = "{new_version}" + +[[tool.bumpversion.files]] +filename = "pyproject.toml" +search = 'version = "{current_version}"' +replace = 'version = "{new_version}"' \ No newline at end of file