Skip to content

Commit 00e79f5

Browse files
fix(INF2-ecloud-pipeline): added manual approval for prod pipeline (#64)
1 parent 8bb620e commit 00e79f5

File tree

2 files changed

+60
-56
lines changed

2 files changed

+60
-56
lines changed

.github/CODEOWNERS

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

.github/workflows/release-prod.yml

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

33
on:
4-
push:
5-
tags:
6-
- "v*"
7-
- "!v*-dev*" # Exclude all dev tags
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
810

911
permissions:
1012
contents: write
@@ -17,68 +19,70 @@ jobs:
1719
build-and-publish:
1820
runs-on: ubuntu-latest
1921
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+
2031
- name: Checkout
2132
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2233
with:
34+
ref: ${{ inputs.dev_tag }}
2335
fetch-depth: 0
2436

2537
- name: Set version from tag
2638
run: |
27-
VERSION="${{ github.ref_name }}"
28-
# Clean leading v from provided version
39+
# Derive production tag (strip -dev* suffix)
40+
VERSION="${DEV_TAG%%-dev*}"
2941
PACKAGE_VERSION="${VERSION#v}"
30-
# Extract base semantic version (x.y.z) - strip everything after first hyphen
31-
BASE_VERSION="${VERSION%%-*}"
3242
echo "VERSION=$VERSION" >> $GITHUB_ENV
3343
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
34-
echo "BASE_VERSION=$BASE_VERSION" >> $GITHUB_ENV
3544
echo "Building production version: $PACKAGE_VERSION"
36-
echo "Will verify dev tag exists for base version: $BASE_VERSION"
3745
38-
- name: Verify dev testing occurred
46+
- name: Verify dev tag and get commit
3947
run: |
40-
echo "Looking for dev tag with base version: ${{ env.BASE_VERSION }}"
48+
echo "Looking for dev tag: ${{ env.DEV_TAG }}"
4149
42-
# Check if any dev tag exists for this semantic version (e.g., v0.1.0-dev*)
43-
DEV_TAGS=$(git tag -l "${{ env.BASE_VERSION }}-dev*" | head -10)
44-
if [ -z "$DEV_TAGS" ]; then
45-
echo "ERROR: No dev tag found for version ${{ env.BASE_VERSION }}"
50+
if ! git rev-parse "${{ env.DEV_TAG }}" >/dev/null 2>&1; then
51+
echo "ERROR: Dev tag '${{ env.DEV_TAG }}' does not exist"
4652
echo ""
4753
echo "Available dev tags:"
48-
git tag -l "*-dev*" | head -10 || echo "No dev tags found"
54+
git tag -l "*-dev*" | tail -10
55+
exit 1
56+
fi
57+
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"
61+
62+
- name: Verify production tag exists
63+
run: |
64+
if ! git rev-parse "${{ env.VERSION }}" >/dev/null 2>&1; then
65+
echo "ERROR: Production tag '${{ env.VERSION }}' does not exist"
4966
echo ""
50-
echo "Must test in dev first: git tag ${{ env.BASE_VERSION }}-dev"
67+
echo "Please create the production tag first:"
68+
echo " git tag ${{ env.VERSION }}"
69+
echo " git push origin ${{ env.VERSION }}"
5170
exit 1
5271
fi
5372
54-
echo "✅ Found dev tags for ${{ env.BASE_VERSION }}:"
55-
echo "$DEV_TAGS"
56-
57-
# Verify dev and prod tags point to same commit
58-
PROD_COMMIT=$(git rev-list -n 1 "${{ github.ref_name }}")
59-
echo "Production tag ${{ github.ref_name }} points to commit: $PROD_COMMIT"
60-
61-
for DEV_TAG in $DEV_TAGS; do
62-
DEV_COMMIT=$(git rev-list -n 1 "$DEV_TAG")
63-
echo "Dev tag $DEV_TAG points to commit: $DEV_COMMIT"
64-
65-
if [ "$DEV_COMMIT" = "$PROD_COMMIT" ]; then
66-
echo "✅ Dev tag $DEV_TAG verified - same commit as production tag"
67-
echo "VERIFIED_DEV_TAG=$DEV_TAG" >> $GITHUB_ENV
68-
exit 0
69-
fi
70-
done
71-
72-
echo "ERROR: No dev tag points to the same commit as production tag ${{ github.ref_name }}"
73-
echo "Production commit: $PROD_COMMIT"
74-
echo "Dev tags and their commits:"
75-
for DEV_TAG in $DEV_TAGS; do
76-
DEV_COMMIT=$(git rev-list -n 1 "$DEV_TAG")
77-
echo " $DEV_TAG: $DEV_COMMIT"
78-
done
79-
echo ""
80-
echo "Create a dev tag on the same commit: git tag ${{ env.BASE_VERSION }}-dev $PROD_COMMIT"
81-
exit 1
73+
PROD_COMMIT=$(git rev-list -n 1 "${{ env.VERSION }}")
74+
echo "Production tag ${{ env.VERSION }} points to commit: $PROD_COMMIT"
75+
76+
if [ "$PROD_COMMIT" != "${{ env.DEV_COMMIT }}" ]; then
77+
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"
82+
exit 1
83+
fi
84+
85+
echo "Verified: Both tags point to the same commit"
8286
8387
- name: Setup pnpm
8488
uses: pnpm/action-setup@v4
@@ -115,9 +119,7 @@ jobs:
115119
pnpm run build
116120
117121
- name: Get short sha
118-
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
119-
env:
120-
GITHUB_SHA: ${{ github.sha }}
122+
run: echo "SHORT_SHA=${DEV_COMMIT::7}" >> $GITHUB_ENV
121123

122124
- name: Generate SDK VERSION file
123125
working-directory: ./packages/sdk
@@ -155,7 +157,6 @@ jobs:
155157
npm pkg set version="${{ env.PACKAGE_VERSION }}"
156158
# Update SDK dependency to match published version
157159
npm pkg set "dependencies.@layr-labs/ecloud-sdk"="${{ env.PACKAGE_VERSION }}"
158-
# Verify changes
159160
cat package.json | grep -A 2 '"name"'
160161
cat package.json | grep -A 1 '"@layr-labs/ecloud-sdk"'
161162
@@ -168,9 +169,9 @@ jobs:
168169
169170
- name: Summary
170171
run: |
171-
echo "🚀 Production release published successfully!"
172-
echo "📦 SDK Package: @layr-labs/ecloud-sdk@${{ env.PACKAGE_VERSION }} (tag: latest)"
173-
echo "📦 CLI Package: @layr-labs/ecloud-cli@${{ env.PACKAGE_VERSION }} (tag: latest)"
174-
echo "🏷️ Tag: latest"
175-
echo "🔒 Verified dev testing completed with matching commit from ${{ env.VERIFIED_DEV_TAG }}"
176-
echo "🔗 Install with: npm install -g @layr-labs/ecloud-cli@latest"
172+
echo "Production release published successfully!"
173+
echo "SDK Package: @layr-labs/ecloud-sdk@${{ env.PACKAGE_VERSION }} (tag: latest)"
174+
echo "CLI Package: @layr-labs/ecloud-cli@${{ env.PACKAGE_VERSION }} (tag: latest)"
175+
echo "Tag: ${{ env.VERSION }}"
176+
echo "Promoted from: ${{ env.DEV_TAG }}"
177+
echo "Install with: npm install -g @layr-labs/ecloud-cli@latest"

0 commit comments

Comments
 (0)