Skip to content

Commit 32c5bb3

Browse files
authored
ci: add workflow to bump version and build Docker image on PR merge (#3)
1 parent a47df36 commit 32c5bb3

3 files changed

Lines changed: 68 additions & 2 deletions

File tree

.github/workflows/docker.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ on:
77
description: 'Version to label the Docker image under'
88
required: true
99
type: string
10+
workflow_call:
11+
inputs:
12+
version:
13+
required: true
14+
type: string
15+
16+
permissions:
17+
contents: read
18+
packages: write
1019

1120
jobs:
1221
check_authorization:
@@ -25,13 +34,14 @@ jobs:
2534
runs-on: ubuntu-latest
2635
steps:
2736
- name: Log in to GitHub Container Registry
28-
uses: docker/login-action@v2
37+
uses: docker/login-action@v3
2938
with:
3039
registry: ghcr.io
3140
username: ${{ github.actor }}
3241
password: ${{ secrets.GITHUB_TOKEN }}
3342
- name: Build and push
34-
uses: docker/build-push-action@v4
43+
uses: docker/build-push-action@v6
3544
with:
45+
context: .
3646
push: true
3747
tags: ghcr.io/libretexts/molview-lambda-api:${{ inputs.version }}

.github/workflows/version-bump.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Version Bump and Build
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
bump:
13+
if: github.event.pull_request.merged == true
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
ref: main
19+
fetch-depth: 0
20+
token: ${{ secrets.LIBREBOT_ACCESS_TOKEN }}
21+
- name: Configure git as LibreBot
22+
run: |
23+
git config user.name "libretexts-bot"
24+
git config user.email "dev@libretexts.org"
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.x"
29+
- name: Install bump-my-version
30+
run: pip install bump-my-version
31+
- name: Bump minor version
32+
run: bump-my-version bump minor
33+
- name: Capture new version
34+
id: version
35+
run: echo "value=$(bump-my-version show current_version)" >> "$GITHUB_OUTPUT"
36+
build:
37+
needs: bump
38+
uses: ./.github/workflows/docker.yml
39+
with:
40+
version: ${{needs.bump.outputs.version}}
41+
secrets: inherit

pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[project]
2+
name = "molview-lambda-api"
3+
version = "1.10.0"
4+
5+
[tool.bumpversion]
6+
current_version = "1.10.0"
7+
commit = true
8+
tag = true
9+
commit_args = "-m 'chore(release): {new_version} [skip ci]'"
10+
tag_name = "{new_version}"
11+
12+
[[tool.bumpversion.files]]
13+
filename = "pyproject.toml"
14+
search = 'version = "{current_version}"'
15+
replace = 'version = "{new_version}"'

0 commit comments

Comments
 (0)