refactor(ci): enhance hotfix workflow and rename workflow files
🔄 Hotfix Workflow Enhancements: - Accept tags from any environment (dev/stage/prod), not just production - Changed input parameter: 'production_tag' → 'tag' - Updated validation to show all available tags (not just prod) - Made terminology more generic throughout - Show 20 most recent tags instead of 10 for better visibility 📝 File Renames: - .github/workflows/mobile-hotfix.yml → hotfix-branch-creation.yml - .github/workflows/mobile-release.yml → product-release.yml Benefits: ✅ Hotfix workflow now works with dev/stage/prod tags ✅ More flexible for various hotfix scenarios ✅ Clearer, more descriptive workflow file names ✅ Consistent with product-agnostic terminology
This commit is contained in:
145
.github/workflows/product-release.yml
vendored
Normal file
145
.github/workflows/product-release.yml
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
name: <EFBFBD> Product Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
app:
|
||||
description: '📦 Product'
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- worker
|
||||
- client
|
||||
environment:
|
||||
description: '🌍 Environment'
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- dev
|
||||
- stage
|
||||
- prod
|
||||
create_github_release:
|
||||
description: '📦 Create GitHub Release'
|
||||
required: true
|
||||
type: boolean
|
||||
default: true
|
||||
prerelease:
|
||||
description: '🔖 Mark as Pre-release'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
jobs:
|
||||
validate-and-create-release:
|
||||
name: 🚀 Create Product Release
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: 📥 Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: <EFBFBD> Make scripts executable
|
||||
run: |
|
||||
chmod +x .github/scripts/*.sh
|
||||
echo "✅ Scripts are now executable"
|
||||
|
||||
- name: 📖 Extract version from version file
|
||||
id: version
|
||||
run: |
|
||||
VERSION=$(.github/scripts/extract-version.sh "${{ github.event.inputs.app }}")
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
echo "📌 Extracted version: ${VERSION}"
|
||||
|
||||
- name: 🏷️ Generate tag name
|
||||
id: tag
|
||||
run: |
|
||||
TAG_NAME=$(.github/scripts/generate-tag-name.sh \
|
||||
"${{ github.event.inputs.app }}" \
|
||||
"${{ github.event.inputs.environment }}" \
|
||||
"${{ steps.version.outputs.version }}")
|
||||
echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT
|
||||
echo "🎯 Tag to create: ${TAG_NAME}"
|
||||
|
||||
- name: 🔍 Check if tag already exists
|
||||
run: |
|
||||
TAG_NAME="${{ steps.tag.outputs.tag_name }}"
|
||||
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
|
||||
echo "❌ Error: Tag $TAG_NAME already exists"
|
||||
echo "💡 Tip: Update the version in the version file before creating a new release"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ Tag does not exist, proceeding..."
|
||||
|
||||
- name: 📋 Extract release notes from CHANGELOG
|
||||
id: release_notes
|
||||
run: |
|
||||
.github/scripts/extract-release-notes.sh \
|
||||
"${{ github.event.inputs.app }}" \
|
||||
"${{ steps.version.outputs.version }}" \
|
||||
"${{ github.event.inputs.environment }}" \
|
||||
"${{ steps.tag.outputs.tag_name }}" \
|
||||
"/tmp/release_notes.md"
|
||||
echo "notes_file=/tmp/release_notes.md" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: 🏷️ Create Git Tag
|
||||
run: |
|
||||
TAG_NAME="${{ steps.tag.outputs.tag_name }}"
|
||||
APP="${{ github.event.inputs.app }}"
|
||||
ENV="${{ github.event.inputs.environment }}"
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
git tag -a "$TAG_NAME" -m "🚀 Release ${APP} product ${VERSION} to ${ENV}"
|
||||
git push origin "$TAG_NAME"
|
||||
|
||||
echo "✅ Tag created and pushed: $TAG_NAME"
|
||||
|
||||
- name: 📦 Create GitHub Release
|
||||
if: ${{ github.event.inputs.create_github_release == 'true' }}
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
TAG_NAME="${{ steps.tag.outputs.tag_name }}"
|
||||
APP="${{ github.event.inputs.app }}"
|
||||
ENV="${{ github.event.inputs.environment }}"
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
|
||||
# Generate release title
|
||||
if [ "$APP" = "worker" ]; then
|
||||
APP_DISPLAY="Worker Mobile Application"
|
||||
else
|
||||
APP_DISPLAY="Client Mobile Application"
|
||||
fi
|
||||
|
||||
ENV_UPPER=$(echo "$ENV" | tr '[:lower:]' '[:upper:]')
|
||||
RELEASE_NAME="Krow With Us - ${APP_DISPLAY} - ${ENV_UPPER} - v${VERSION}"
|
||||
|
||||
echo "📦 Creating GitHub Release: $RELEASE_NAME"
|
||||
|
||||
# Create release
|
||||
if [ "${{ github.event.inputs.prerelease }}" = "true" ]; then
|
||||
gh release create "$TAG_NAME" \
|
||||
--title "$RELEASE_NAME" \
|
||||
--notes-file "${{ steps.release_notes.outputs.notes_file }}" \
|
||||
--prerelease
|
||||
echo "🔖 Pre-release created successfully"
|
||||
else
|
||||
gh release create "$TAG_NAME" \
|
||||
--title "$RELEASE_NAME" \
|
||||
--notes-file "${{ steps.release_notes.outputs.notes_file }}"
|
||||
echo "✅ Release created successfully"
|
||||
fi
|
||||
|
||||
- name: 📊 Generate Release Summary
|
||||
run: |
|
||||
.github/scripts/create-release-summary.sh \
|
||||
"${{ github.event.inputs.app }}" \
|
||||
"${{ github.event.inputs.environment }}" \
|
||||
"${{ steps.version.outputs.version }}" \
|
||||
"${{ steps.tag.outputs.tag_name }}"
|
||||
Reference in New Issue
Block a user