name: 📱 Mobile Release on: workflow_dispatch: inputs: app: description: '📱 Mobile App' 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 Mobile Release runs-on: ubuntu-latest permissions: contents: write steps: - name: 📥 Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: � Make scripts executable run: | chmod +x .github/scripts/*.sh echo "✅ Scripts are now executable" - name: 📖 Extract version from pubspec.yaml 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 pubspec.yaml 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} mobile app ${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" else APP_DISPLAY="Client Mobile" 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 }}"