Skip to content

Commit 74dea7e

Browse files
authored
Merge pull request #1 from optimizely/shihab/EC3-2437-move-to-artifact-reg
[EC3-2437] Move optimizely-platform to Artifact Registry
2 parents a9c079a + 39ce388 commit 74dea7e

3 files changed

Lines changed: 91 additions & 7 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Release and Publish to Google Artifact Registry
2+
3+
permissions:
4+
id-token: write
5+
contents: read
6+
7+
on:
8+
push:
9+
tags:
10+
- "v*.*.*"
11+
12+
jobs:
13+
publish-gar:
14+
name: Build and Publish to GAR
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
persist-credentials: false
22+
23+
- name: Validate tag format
24+
env:
25+
TAG: ${{ github.ref_name }}
26+
run: |
27+
VERSION="${TAG#v}"
28+
if ! [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
29+
echo "Error: Invalid version format '$VERSION'. Expected format: x.y.z"
30+
exit 1
31+
fi
32+
echo "Releasing version: $VERSION (from tag: $TAG)"
33+
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+
56+
- name: Set up Python
57+
uses: actions/setup-python@v5
58+
with:
59+
python-version: "3.x"
60+
61+
- name: Install build dependencies
62+
run: pip install build twine setuptools-scm
63+
64+
- name: Authenticate to Google Cloud
65+
id: auth
66+
uses: google-github-actions/auth@v3
67+
with:
68+
token_format: "access_token"
69+
workload_identity_provider: "projects/668763687485/locations/global/workloadIdentityPools/github/providers/github"
70+
service_account: "github-experimentation@optimizely-iac.iam.gserviceaccount.com"
71+
72+
- name: Build and Publish
73+
run: |
74+
python -m build
75+
python -m twine upload \
76+
--repository-url https://us-east1-python.pkg.dev/artifact-registry-e3ca/private-python/ \
77+
--username oauth2accesstoken \
78+
--password ${{ steps.auth.outputs.access_token }} \
79+
dist/*

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`.

setup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
from setuptools import setup
22
from setuptools import find_packages
3-
4-
3+
4+
55
setup(
66
name='optimizely-platform',
7-
version='0.0.7',
7+
use_scm_version=True,
8+
setup_requires=['setuptools-scm'],
89
description='Package providing modules needed to build add-ons that run natively in the Optimizely platform.',
910
author='Jon Gaulding, Tyler Jones, Peng-Wen Chen, Ali Rizvi',
1011
author_email='developers@optimizely.com',
1112
license='MIT',
1213
url='https://github.com/optimizely/optimizely-platform',
13-
download_url='https://github.com/optimizely/optimizely-platform/tarball/0.0.7',
14-
keywords = ['optimizely', 'platform', 'integration', 'add-on'],
14+
keywords=['optimizely', 'platform', 'integration', 'add-on'],
1515
classifiers=[
1616
'Development Status :: 4 - Beta',
1717
'Environment :: Web Environment',

0 commit comments

Comments
 (0)