Skip to content

Commit 39ce388

Browse files
EshtiakAlamCopilot
andcommitted
- Enhance publish workflow: add validation for GitHub Release and tag checks
Co-authored-by: Copilot <copilot@github.com>
1 parent 7e9c365 commit 39ce388

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,42 @@ jobs:
2121
persist-credentials: false
2222

2323
- name: Validate tag format
24+
env:
25+
TAG: ${{ github.ref_name }}
2426
run: |
25-
TAG="${{ github.ref_name }}"
2627
VERSION="${TAG#v}"
2728
if ! [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
2829
echo "Error: Invalid version format '$VERSION'. Expected format: x.y.z"
2930
exit 1
3031
fi
3132
echo "Releasing version: $VERSION (from tag: $TAG)"
3233
34+
- name: Verify GitHub Release exists
35+
env:
36+
GH_TOKEN: ${{ github.token }}
37+
TAG: ${{ github.ref_name }}
38+
run: |
39+
if ! gh release view "$TAG" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
40+
echo "Error: No GitHub Release found for tag '$TAG'."
41+
echo "Create a release via GitHub UI instead of pushing tags manually."
42+
exit 1
43+
fi
44+
45+
- name: Verify tag is on master
46+
env:
47+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
48+
run: |
49+
git fetch origin "$DEFAULT_BRANCH" --quiet
50+
if ! git merge-base --is-ancestor "$GITHUB_SHA" "origin/$DEFAULT_BRANCH"; then
51+
echo "Error: Tag commit $GITHUB_SHA is not reachable from origin/$DEFAULT_BRANCH."
52+
echo "Only tags on the $DEFAULT_BRANCH branch can be published."
53+
exit 1
54+
fi
55+
3356
- name: Set up Python
3457
uses: actions/setup-python@v5
3558
with:
36-
python-version: '3.x'
59+
python-version: "3.x"
3760

3861
- name: Install build dependencies
3962
run: pip install build twine setuptools-scm

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
# optimizely-platform [![Build Status](https://travis-ci.org/optimizely/optimizely-platform.svg?branch=master)](https://travis-ci.org/optimizely/optimizely-platform)
1+
# optimizely-platform
22

33
A Python package providing modules needed to build add-ons that run natively in the Optimizely platform.
44

5-
TODO(jon): Add link to documentation once it's up.
5+
## Releasing
6+
7+
1. Merge your changes to `master`.
8+
2. [Create a GitHub Release](../../releases/new) with a tag in the format `vX.Y.Z` (e.g. `v1.2.3`).
9+
10+
The `publish.yaml` workflow builds and publishes to Google Artifact Registry. It will reject tags that aren't strict semver, lack a GitHub Release, or aren't on `master`.

0 commit comments

Comments
 (0)