Skip to content

Commit 4bf280c

Browse files
authored
ci: update workflow triggers and release publishing (#1209)
1 parent 1499162 commit 4bf280c

6 files changed

Lines changed: 112 additions & 191 deletions

File tree

.github/workflows/build-artifacts.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Build customer artifact
22

33
on:
4-
pull_request:
5-
types: [opened, synchronize, reopened, ready_for_review]
64
workflow_dispatch:
75
inputs:
86
ref:
@@ -28,7 +26,7 @@ permissions:
2826
contents: read
2927

3028
concurrency:
31-
group: customer-artifact-${{ github.event.pull_request.number || inputs.ref || github.ref }}
29+
group: customer-artifact-${{ inputs.ref || github.ref }}
3230
cancel-in-progress: true
3331

3432
env:
@@ -47,7 +45,7 @@ jobs:
4745
- name: Check out requested source
4846
uses: actions/checkout@v7
4947
with:
50-
ref: ${{ inputs.ref || github.event.pull_request.head.sha || github.sha }}
48+
ref: ${{ inputs.ref || github.sha }}
5149
fetch-depth: 0
5250

5351
- name: Set up Python
@@ -68,7 +66,7 @@ jobs:
6866
id: metadata
6967
env:
7068
ARTIFACT_LABEL: ${{ inputs.artifact_label }}
71-
SOURCE_REF: ${{ inputs.ref || github.head_ref || github.ref_name }}
69+
SOURCE_REF: ${{ inputs.ref || github.ref_name }}
7270
run: |
7371
python - <<'PY'
7472
import os

.github/workflows/build-docker.yml

Lines changed: 4 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,14 @@
11
name: Build Docker image
22

33
on:
4-
pull_request:
5-
types: [opened, synchronize, reopened, ready_for_review]
6-
paths:
7-
- .github/workflows/build-docker.yml
8-
- docker/**
9-
- src/**
10-
- .dockerignore
11-
- LICENSE
12-
- README.md
13-
- pyproject.toml
14-
- uv.lock
15-
push:
16-
branches: [main]
17-
paths:
18-
- .github/workflows/build-docker.yml
19-
- docker/**
20-
- src/**
21-
- .dockerignore
22-
- LICENSE
23-
- README.md
24-
- pyproject.toml
25-
- uv.lock
26-
release:
27-
types: [published]
284
workflow_dispatch:
295

306
permissions:
317
contents: read
328

339
concurrency:
34-
group: docker-${{ github.event.release.tag_name || github.head_ref || github.ref }}
35-
cancel-in-progress: ${{ github.event_name != 'release' }}
10+
group: docker-${{ github.ref }}
11+
cancel-in-progress: true
3612

3713
env:
3814
IMAGE_NAME: powercontext-server
@@ -55,8 +31,6 @@ jobs:
5531

5632
- name: Resolve image metadata
5733
id: metadata
58-
env:
59-
RELEASE_TAG: ${{ github.event.release.tag_name }}
6034
run: |
6135
python - <<'PY'
6236
import os
@@ -68,26 +42,6 @@ jobs:
6842
project = tomllib.loads(Path("pyproject.toml").read_text())
6943
package_version = project["project"]["version"]
7044
source_sha = subprocess.check_output(["git", "rev-parse", "HEAD"], text=True).strip()
71-
release_tag = os.environ.get("RELEASE_TAG", "")
72-
73-
if release_tag:
74-
release_version = release_tag.removeprefix("v")
75-
if not re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?", release_version):
76-
raise SystemExit("Release tag must use vX.Y.Z or X.Y.Z semantic versioning")
77-
package_version = release_version
78-
79-
pyproject_path = Path("pyproject.toml")
80-
pyproject_text = pyproject_path.read_text()
81-
updated = re.sub(
82-
r'^version = ".*"$',
83-
f'version = "{release_version}"',
84-
pyproject_text,
85-
count=1,
86-
flags=re.MULTILINE,
87-
)
88-
if updated == pyproject_text:
89-
raise SystemExit("Could not update the project version for the Release image")
90-
pyproject_path.write_text(updated)
9145
9246
safe_version = re.sub(r"[^A-Za-z0-9_.-]+", "-", package_version).strip("-.")
9347
if not safe_version:
@@ -102,7 +56,6 @@ jobs:
10256
PY
10357
10458
- name: Build Docker image archives
105-
if: github.event_name != 'release'
10659
env:
10760
IMAGE_TAG: ${{ steps.metadata.outputs.image_tag }}
10861
run: |
@@ -123,7 +76,6 @@ jobs:
12376
done
12477
12578
- name: Smoke test Linux amd64 image
126-
if: github.event_name != 'release'
12779
env:
12880
IMAGE_TAG: ${{ steps.metadata.outputs.image_tag }}
12981
run: |
@@ -154,7 +106,6 @@ jobs:
154106
exit 1
155107
156108
- name: Upload Docker image archives
157-
if: github.event_name != 'release'
158109
uses: actions/upload-artifact@v7
159110
with:
160111
name: ${{ steps.metadata.outputs.artifact_name }}
@@ -163,64 +114,15 @@ jobs:
163114
if-no-files-found: error
164115
retention-days: 30
165116

166-
- name: Validate Docker Hub configuration
167-
if: github.event_name == 'release'
168-
env:
169-
DOCKER_PUSH_BASE: ${{ vars.DOCKER_PUSH_BASE }}
170-
run: |
171-
if [ -z "$DOCKER_PUSH_BASE" ]; then
172-
echo "Repository variable DOCKER_PUSH_BASE is required for Release publishing" >&2
173-
exit 1
174-
fi
175-
176-
- name: Resolve Release image tags
177-
if: github.event_name == 'release'
178-
id: release-tags
179-
uses: docker/metadata-action@v5
180-
with:
181-
images: ${{ vars.DOCKER_PUSH_BASE }}/powercontext-server
182-
tags: |
183-
type=semver,pattern={{version}},value=${{ github.event.release.tag_name }}
184-
type=raw,value=latest,enable=${{ github.event.release.prerelease == false }}
185-
186-
- name: Log in to Docker Hub
187-
if: github.event_name == 'release'
188-
uses: docker/login-action@v3
189-
with:
190-
username: ${{ secrets.DOCKER_USERNAME }}
191-
password: ${{ secrets.DOCKER_PASSWORD }}
192-
193-
- name: Build and push Release image
194-
if: github.event_name == 'release'
195-
uses: docker/build-push-action@v6
196-
with:
197-
context: .
198-
file: docker/Dockerfile
199-
platforms: linux/amd64,linux/arm64
200-
push: true
201-
tags: ${{ steps.release-tags.outputs.tags }}
202-
labels: ${{ steps.release-tags.outputs.labels }}
203-
cache-from: type=gha,scope=docker-release
204-
cache-to: type=gha,mode=max,scope=docker-release
205-
206117
- name: Summarize build
207118
env:
208119
ARTIFACT_NAME: ${{ steps.metadata.outputs.artifact_name }}
209-
IMAGE_TAGS: ${{ steps.release-tags.outputs.tags }}
210120
SOURCE_SHA: ${{ steps.metadata.outputs.source_sha }}
211121
run: |
212122
{
213123
echo "## Docker image"
214124
echo
215125
echo "- Source SHA: \`$SOURCE_SHA\`"
216-
if [ "$GITHUB_EVENT_NAME" = "release" ]; then
217-
echo "- Published tags:"
218-
while IFS= read -r tag; do
219-
echo " - \`$tag\`"
220-
done <<< "$IMAGE_TAGS"
221-
echo "- Platforms: \`linux/amd64\`, \`linux/arm64\`"
222-
else
223-
echo "- Artifact: \`$ARTIFACT_NAME\`"
224-
echo "- Retention: 30 days"
225-
fi
126+
echo "- Artifact: \`$ARTIFACT_NAME\`"
127+
echo "- Retention: 30 days"
226128
} >> "$GITHUB_STEP_SUMMARY"

.github/workflows/e2e-harness.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: E2E harness
33
on:
44
push:
55
branches:
6-
- main
6+
- master
77
pull_request:
88
types: [opened, synchronize, reopened, ready_for_review]
99
workflow_dispatch:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Main
33
on:
44
push:
55
branches:
6-
- main
6+
- master
77
pull_request:
88
types: [opened, synchronize, reopened, ready_for_review]
99

.github/workflows/on-release-main.yml

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)