Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/build-artifacts.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Build customer artifact

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
inputs:
ref:
Expand All @@ -28,7 +26,7 @@ permissions:
contents: read

concurrency:
group: customer-artifact-${{ github.event.pull_request.number || inputs.ref || github.ref }}
group: customer-artifact-${{ inputs.ref || github.ref }}
cancel-in-progress: true

env:
Expand All @@ -47,7 +45,7 @@ jobs:
- name: Check out requested source
uses: actions/checkout@v7
with:
ref: ${{ inputs.ref || github.event.pull_request.head.sha || github.sha }}
ref: ${{ inputs.ref || github.sha }}
fetch-depth: 0

- name: Set up Python
Expand All @@ -68,7 +66,7 @@ jobs:
id: metadata
env:
ARTIFACT_LABEL: ${{ inputs.artifact_label }}
SOURCE_REF: ${{ inputs.ref || github.head_ref || github.ref_name }}
SOURCE_REF: ${{ inputs.ref || github.ref_name }}
run: |
python - <<'PY'
import os
Expand Down
106 changes: 4 additions & 102 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,14 @@
name: Build Docker image

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- .github/workflows/build-docker.yml
- docker/**
- src/**
- .dockerignore
- LICENSE
- README.md
- pyproject.toml
- uv.lock
push:
branches: [main]
paths:
- .github/workflows/build-docker.yml
- docker/**
- src/**
- .dockerignore
- LICENSE
- README.md
- pyproject.toml
- uv.lock
release:
types: [published]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: docker-${{ github.event.release.tag_name || github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name != 'release' }}
group: docker-${{ github.ref }}
cancel-in-progress: true

env:
IMAGE_NAME: powercontext-server
Expand All @@ -55,8 +31,6 @@ jobs:

- name: Resolve image metadata
id: metadata
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
python - <<'PY'
import os
Expand All @@ -68,26 +42,6 @@ jobs:
project = tomllib.loads(Path("pyproject.toml").read_text())
package_version = project["project"]["version"]
source_sha = subprocess.check_output(["git", "rev-parse", "HEAD"], text=True).strip()
release_tag = os.environ.get("RELEASE_TAG", "")

if release_tag:
release_version = release_tag.removeprefix("v")
if not re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?", release_version):
raise SystemExit("Release tag must use vX.Y.Z or X.Y.Z semantic versioning")
package_version = release_version

pyproject_path = Path("pyproject.toml")
pyproject_text = pyproject_path.read_text()
updated = re.sub(
r'^version = ".*"$',
f'version = "{release_version}"',
pyproject_text,
count=1,
flags=re.MULTILINE,
)
if updated == pyproject_text:
raise SystemExit("Could not update the project version for the Release image")
pyproject_path.write_text(updated)

safe_version = re.sub(r"[^A-Za-z0-9_.-]+", "-", package_version).strip("-.")
if not safe_version:
Expand All @@ -102,7 +56,6 @@ jobs:
PY

- name: Build Docker image archives
if: github.event_name != 'release'
env:
IMAGE_TAG: ${{ steps.metadata.outputs.image_tag }}
run: |
Expand All @@ -123,7 +76,6 @@ jobs:
done

- name: Smoke test Linux amd64 image
if: github.event_name != 'release'
env:
IMAGE_TAG: ${{ steps.metadata.outputs.image_tag }}
run: |
Expand Down Expand Up @@ -154,7 +106,6 @@ jobs:
exit 1

- name: Upload Docker image archives
if: github.event_name != 'release'
uses: actions/upload-artifact@v7
with:
name: ${{ steps.metadata.outputs.artifact_name }}
Expand All @@ -163,64 +114,15 @@ jobs:
if-no-files-found: error
retention-days: 30

- name: Validate Docker Hub configuration
if: github.event_name == 'release'
env:
DOCKER_PUSH_BASE: ${{ vars.DOCKER_PUSH_BASE }}
run: |
if [ -z "$DOCKER_PUSH_BASE" ]; then
echo "Repository variable DOCKER_PUSH_BASE is required for Release publishing" >&2
exit 1
fi

- name: Resolve Release image tags
if: github.event_name == 'release'
id: release-tags
uses: docker/metadata-action@v5
with:
images: ${{ vars.DOCKER_PUSH_BASE }}/powercontext-server
tags: |
type=semver,pattern={{version}},value=${{ github.event.release.tag_name }}
type=raw,value=latest,enable=${{ github.event.release.prerelease == false }}

- name: Log in to Docker Hub
if: github.event_name == 'release'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Release image
if: github.event_name == 'release'
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.release-tags.outputs.tags }}
labels: ${{ steps.release-tags.outputs.labels }}
cache-from: type=gha,scope=docker-release
cache-to: type=gha,mode=max,scope=docker-release

- name: Summarize build
env:
ARTIFACT_NAME: ${{ steps.metadata.outputs.artifact_name }}
IMAGE_TAGS: ${{ steps.release-tags.outputs.tags }}
SOURCE_SHA: ${{ steps.metadata.outputs.source_sha }}
run: |
{
echo "## Docker image"
echo
echo "- Source SHA: \`$SOURCE_SHA\`"
if [ "$GITHUB_EVENT_NAME" = "release" ]; then
echo "- Published tags:"
while IFS= read -r tag; do
echo " - \`$tag\`"
done <<< "$IMAGE_TAGS"
echo "- Platforms: \`linux/amd64\`, \`linux/arm64\`"
else
echo "- Artifact: \`$ARTIFACT_NAME\`"
echo "- Retention: 30 days"
fi
echo "- Artifact: \`$ARTIFACT_NAME\`"
echo "- Retention: 30 days"
} >> "$GITHUB_STEP_SUMMARY"
2 changes: 1 addition & 1 deletion .github/workflows/e2e-harness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: E2E harness
on:
push:
branches:
- main
- master
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Main
on:
push:
branches:
- main
- master
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

Expand Down
82 changes: 0 additions & 82 deletions .github/workflows/on-release-main.yml

This file was deleted.

Loading
Loading