Skip to content

Release

Release #22

Workflow file for this run

name: Release
on:
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: eddmann/garmin-connect-mcp
jobs:
build-and-release:
name: Build and Release
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Extract version from changelog
id: version
run: |
VERSION=$(sed -n 's/^## \[\([^]]*\)\].*/\1/p' CHANGELOG.md | head -1)
if [[ -z "$VERSION" ]]; then
echo "No release version found in CHANGELOG.md" >&2
exit 1
fi
MAJOR_MINOR=$(echo "$VERSION" | sed -E 's/^([0-9]+)\.([0-9]+).*/\1.\2/')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "major_minor=$MAJOR_MINOR" >> "$GITHUB_OUTPUT"
- name: Extract changelog
id: changelog
run: |
CONTENT=$(awk '
/^## \[/ {
if (found) exit
found=1
next
}
found && /^\[[^]]+\]:/ { exit }
found { print }
' CHANGELOG.md)
echo "content<<EOF" >> "$GITHUB_OUTPUT"
echo "$CONTENT" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Update pyproject version
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
python - <<'PY'
import os
import re
from pathlib import Path
version = os.environ["VERSION"]
path = Path("pyproject.toml")
text = path.read_text()
updated, count = re.subn(
r'(?m)^version = "[^"]+"$',
f'version = "{version}"',
text,
count=1,
)
if count != 1:
raise SystemExit("Could not find pyproject.toml version")
path.write_text(updated)
PY
grep '^version = ' pyproject.toml
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install dependencies
run: make deps
- name: Run release checks
run: make can-release
- name: Build package
run: make package/check
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.major_minor }}
labels: |
org.opencontainers.image.title=garmin-connect-mcp
org.opencontainers.image.version=${{ steps.version.outputs.version }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: v${{ steps.version.outputs.version }}
name: garmin-connect-mcp v${{ steps.version.outputs.version }}
body: ${{ steps.changelog.outputs.content }}
files: dist/*
draft: false
prerelease: false