Skip to content

Commit 5994736

Browse files
Inf2 97 ecloud prod environment (#76)
1 parent f66f41c commit 5994736

File tree

2 files changed

+49
-47
lines changed

2 files changed

+49
-47
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# CODEOWNERS - Workflow Protection
22
# Protect all workflows
3-
/.github/workflows/ @anupsv @vineetguptadev @shrimalmadhur @solimander @Chris-Moller @taekyunggg
3+
/.github/workflows/ @anupsv @vineetguptadev @solimander @Chris-Moller

.github/workflows/release-prod.yml

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
name: Release Production
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
dev_tag:
7-
description: 'Dev tag to promote (e.g. v1.0.0-dev)'
8-
required: true
9-
type: string
4+
push:
5+
tags:
6+
- "v*"
7+
- "!v*-dev*" # Exclude all dev tags
108

119
permissions:
1210
contents: write
@@ -18,72 +16,78 @@ env:
1816
jobs:
1917
build-and-publish:
2018
runs-on: ubuntu-latest
19+
environment:
20+
name: production
21+
url: https://www.npmjs.com/package/@layr-labs/ecloud-cli
2122
steps:
22-
- name: Enforce dev tag format
23-
run: |
24-
DEV_TAG="${{ inputs.dev_tag }}"
25-
if [[ ! "$DEV_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-dev ]]; then
26-
echo "Version '$DEV_TAG' does not match required pattern v<major>.<minor>.<patch>-dev*"
27-
exit 1
28-
fi
29-
echo "DEV_TAG=$DEV_TAG" >> $GITHUB_ENV
30-
3123
- name: Checkout
3224
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3325
with:
34-
ref: ${{ inputs.dev_tag }}
3526
fetch-depth: 0
3627

28+
- name: Ensure tag is on default branch
29+
run: |
30+
TAG="${{ github.ref_name }}"
31+
DEFAULT_BRANCH="${{ github.event.repository.default_branch }}"
32+
git fetch origin "$DEFAULT_BRANCH"
33+
TAG_COMMIT=$(git rev-parse "$TAG")
34+
if ! git merge-base --is-ancestor "$TAG_COMMIT" "origin/$DEFAULT_BRANCH"; then
35+
echo "ERROR: Tag $TAG points to a commit not on $DEFAULT_BRANCH"
36+
echo "Tag commit: $TAG_COMMIT"
37+
exit 1
38+
fi
39+
3740
- name: Set version from tag
3841
run: |
39-
# Derive production tag (strip -dev* suffix)
40-
VERSION="${DEV_TAG%%-dev*}"
42+
VERSION="${{ github.ref_name }}"
4143
PACKAGE_VERSION="${VERSION#v}"
44+
BASE_VERSION="${VERSION%%-*}"
4245
echo "VERSION=$VERSION" >> $GITHUB_ENV
4346
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
47+
echo "BASE_VERSION=$BASE_VERSION" >> $GITHUB_ENV
4448
echo "Building production version: $PACKAGE_VERSION"
4549
4650
- name: Verify dev tag and get commit
4751
run: |
48-
echo "Looking for dev tag: ${{ env.DEV_TAG }}"
49-
50-
if ! git rev-parse "${{ env.DEV_TAG }}" >/dev/null 2>&1; then
51-
echo "ERROR: Dev tag '${{ env.DEV_TAG }}' does not exist"
52-
echo ""
53-
echo "Available dev tags:"
52+
DEV_TAGS=$(git tag -l "${{ env.BASE_VERSION }}-dev*" | head -10)
53+
if [ -z "$DEV_TAGS" ]; then
54+
echo "ERROR: No dev tag found for version ${{ env.BASE_VERSION }}"
5455
git tag -l "*-dev*" | tail -10
5556
exit 1
5657
fi
5758
58-
DEV_COMMIT=$(git rev-list -n 1 "${{ env.DEV_TAG }}")
59-
echo "DEV_COMMIT=$DEV_COMMIT" >> $GITHUB_ENV
60-
echo "Dev tag ${{ env.DEV_TAG }} points to commit: $DEV_COMMIT"
59+
PROD_COMMIT=$(git rev-list -n 1 "${{ github.ref_name }}")
60+
for DEV_TAG in $DEV_TAGS; do
61+
DEV_COMMIT=$(git rev-list -n 1 "$DEV_TAG")
62+
if [ "$DEV_COMMIT" = "$PROD_COMMIT" ]; then
63+
echo "DEV_COMMIT=$DEV_COMMIT" >> $GITHUB_ENV
64+
echo "DEV_TAG=$DEV_TAG" >> $GITHUB_ENV
65+
exit 0
66+
fi
67+
done
68+
69+
echo "ERROR: No dev tag points to the same commit as production tag ${{ github.ref_name }}"
70+
echo "Production commit: $PROD_COMMIT"
71+
for DEV_TAG in $DEV_TAGS; do
72+
DEV_COMMIT=$(git rev-list -n 1 "$DEV_TAG")
73+
echo " $DEV_TAG: $DEV_COMMIT"
74+
done
75+
exit 1
6176
6277
- name: Verify production tag exists
6378
run: |
6479
if ! git rev-parse "${{ env.VERSION }}" >/dev/null 2>&1; then
6580
echo "ERROR: Production tag '${{ env.VERSION }}' does not exist"
66-
echo ""
67-
echo "Please create the production tag first:"
68-
echo " git tag ${{ env.VERSION }}"
69-
echo " git push origin ${{ env.VERSION }}"
7081
exit 1
7182
fi
72-
7383
PROD_COMMIT=$(git rev-list -n 1 "${{ env.VERSION }}")
74-
echo "Production tag ${{ env.VERSION }} points to commit: $PROD_COMMIT"
75-
7684
if [ "$PROD_COMMIT" != "${{ env.DEV_COMMIT }}" ]; then
7785
echo "ERROR: Production tag and dev tag point to different commits"
78-
echo " Production tag commit: $PROD_COMMIT"
79-
echo " Dev tag commit: ${{ env.DEV_COMMIT }}"
80-
echo ""
81-
echo "Both tags must point to the same commit"
86+
echo "Production: $PROD_COMMIT"
87+
echo "Dev: ${{ env.DEV_COMMIT }}"
8288
exit 1
8389
fi
8490
85-
echo "Verified: Both tags point to the same commit"
86-
8791
- name: Setup pnpm
8892
uses: pnpm/action-setup@v4
8993
with:
@@ -119,7 +123,9 @@ jobs:
119123
pnpm run build
120124
121125
- name: Get short sha
122-
run: echo "SHORT_SHA=${DEV_COMMIT::7}" >> $GITHUB_ENV
126+
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
127+
env:
128+
GITHUB_SHA: ${{ github.sha }}
123129

124130
- name: Generate SDK VERSION file
125131
working-directory: ./packages/sdk
@@ -140,7 +146,6 @@ jobs:
140146
- name: Update SDK package.json for publishing
141147
working-directory: ./packages/sdk
142148
run: |
143-
# Update version (keep default package name)
144149
npm pkg set version="${{ env.PACKAGE_VERSION }}"
145150
146151
- name: Publish SDK to npm (prod)
@@ -153,9 +158,7 @@ jobs:
153158
- name: Update CLI package.json for publishing
154159
working-directory: ./packages/cli
155160
run: |
156-
# Update version (keep default package name)
157161
npm pkg set version="${{ env.PACKAGE_VERSION }}"
158-
# Update SDK dependency to match published version
159162
npm pkg set "dependencies.@layr-labs/ecloud-sdk"="${{ env.PACKAGE_VERSION }}"
160163
cat package.json | grep -A 2 '"name"'
161164
cat package.json | grep -A 1 '"@layr-labs/ecloud-sdk"'
@@ -172,6 +175,5 @@ jobs:
172175
echo "Production release published successfully!"
173176
echo "SDK Package: @layr-labs/ecloud-sdk@${{ env.PACKAGE_VERSION }} (tag: latest)"
174177
echo "CLI Package: @layr-labs/ecloud-cli@${{ env.PACKAGE_VERSION }} (tag: latest)"
175-
echo "Tag: ${{ env.VERSION }}"
176-
echo "Promoted from: ${{ env.DEV_TAG }}"
178+
echo "Verified dev testing completed with matching commit from ${{ env.DEV_TAG }}"
177179
echo "Install with: npm install -g @layr-labs/ecloud-cli@latest"

0 commit comments

Comments
 (0)