Skip to content

Commit 08db22e

Browse files
Fix release workflow GHCR tags and sync versioning (#12)
1 parent 812352a commit 08db22e

File tree

7 files changed

+50
-14
lines changed

7 files changed

+50
-14
lines changed

.github/workflows/release-and-publish.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
workflow_dispatch: {}
88

99
permissions:
10-
contents: read
10+
contents: write
1111
packages: write
1212

1313
jobs:
@@ -34,10 +34,26 @@ jobs:
3434
username: ${{ github.actor }}
3535
password: ${{ secrets.GITHUB_TOKEN }}
3636

37-
- name: Determine tag name
38-
id: tag
37+
- name: Resolve release version and image repository
38+
id: version
3939
run: |
40-
echo "ref_name=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
40+
CRATE_VERSION=$(sed -nE 's/^version = "([^"]+)"/\1/p' Cargo.toml | head -n1)
41+
if [ -z "${CRATE_VERSION}" ]; then
42+
echo "::error::Could not determine crate version from Cargo.toml"
43+
exit 1
44+
fi
45+
46+
RELEASE_TAG="v${CRATE_VERSION}"
47+
IMAGE_REPO="ghcr.io/${GITHUB_REPOSITORY,,}"
48+
49+
echo "crate_version=${CRATE_VERSION}" >> "$GITHUB_OUTPUT"
50+
echo "release_tag=${RELEASE_TAG}" >> "$GITHUB_OUTPUT"
51+
echo "image_repo=${IMAGE_REPO}" >> "$GITHUB_OUTPUT"
52+
53+
if [ "${GITHUB_REF_TYPE}" = "tag" ] && [ "${GITHUB_REF_NAME}" != "${RELEASE_TAG}" ]; then
54+
echo "::error::Tag ${GITHUB_REF_NAME} does not match Cargo.toml version ${CRATE_VERSION} (expected ${RELEASE_TAG})"
55+
exit 1
56+
fi
4157
4258
- name: Build and push multi-arch Docker image
4359
uses: docker/build-push-action@v6
@@ -47,16 +63,18 @@ jobs:
4763
push: true
4864
platforms: linux/amd64,linux/arm64
4965
tags: |
50-
ghcr.io/${{ github.repository_owner }}/rust-cargo-docs-rag-mcp:${{ steps.tag.outputs.ref_name }}
51-
ghcr.io/${{ github.repository_owner }}/rust-cargo-docs-rag-mcp:latest
66+
${{ steps.version.outputs.image_repo }}:${{ steps.version.outputs.release_tag }}
67+
${{ steps.version.outputs.image_repo }}:${{ steps.version.outputs.crate_version }}
68+
${{ steps.version.outputs.image_repo }}:latest
5269
cache-from: type=gha
5370
cache-to: type=gha,mode=max
5471

5572
- name: Create GitHub release
5673
id: create_release
5774
uses: softprops/action-gh-release@v1
5875
with:
59-
tag_name: ${{ steps.tag.outputs.ref_name }}
76+
tag_name: ${{ steps.version.outputs.release_tag }}
77+
target_commitish: ${{ github.sha }}
6078
env:
6179
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6280

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rust-cargo-docs-rag-mcp"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
edition = "2021"
55
description = "Rust Documentation MCP Server for LLM crate assistance"
66
authors = ["Brian Horakh <brianh@promptexecution.com>",

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ Repository requirements:
7373

7474
Prebuilt images are published to GitHub Container Registry (GHCR) on release tags.
7575

76-
Pull the image (replace OWNER with the GH org or username that owns the repo; tags look like v0.3.0):
76+
Pull the image (replace OWNER with the GH org or username that owns the repo; tags look like v0.3.1):
7777
```bash
7878
docker pull ghcr.io/promptexecution/rust-cargo-docs-rag-mcp:latest
7979
# or a specific version:
80-
docker pull ghcr.io/promptexecution/rust-cargo-docs-rag-mcp:v0.3.0
80+
docker pull ghcr.io/promptexecution/rust-cargo-docs-rag-mcp:v0.3.1
8181
```
8282

8383
Run the container in HTTP mode (default):

cog.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pre_bump_hooks = [
1414
]
1515

1616
post_bump_hooks = [
17-
"git add Cargo.toml Cargo.lock CHANGELOG.md"
17+
"git add Cargo.toml Cargo.lock server.json CHANGELOG.md"
1818
]
1919

2020
[[packages]]

scripts/set-version.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,21 @@ if not updated:
5050
5151
path.write_text("\n".join(out_lines) + "\n")
5252
PY
53+
54+
# Update server.json version and OCI package tag
55+
python3 - "$version" <<'PY'
56+
import json, pathlib, sys
57+
version = sys.argv[1]
58+
path = pathlib.Path("server.json")
59+
data = json.loads(path.read_text())
60+
data["version"] = version
61+
62+
for pkg in data.get("packages", []):
63+
if pkg.get("registryType") != "oci":
64+
continue
65+
ident = pkg.get("identifier")
66+
if isinstance(ident, str) and ":" in ident:
67+
pkg["identifier"] = f"{ident.rsplit(':', 1)[0]}:{version}"
68+
69+
path.write_text(json.dumps(data, indent=2) + "\n")
70+
PY

server.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
"url": "https://github.com/promptexecution/rust-cargo-docs-rag-mcp",
99
"source": "github"
1010
},
11-
"version": "0.3.0",
11+
"version": "0.3.1",
1212
"packages": [
1313
{
1414
"registryType": "oci",
15-
"identifier": "ghcr.io/promptexecution/rust-cargo-docs-rag-mcp:0.3.0",
15+
"identifier": "ghcr.io/promptexecution/rust-cargo-docs-rag-mcp:0.3.1",
1616
"runtimeHint": "docker",
1717
"transport": {
1818
"type": "stdio"

0 commit comments

Comments
 (0)