mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
Workflow chores: publish Flutter builds & bump alpha versions (#599)
* Add debug mobile artifacts to GitHub releases - Modify flutter-build.yml to trigger on version tags (v*) and support workflow_call for use by other workflows - Add mobile job to publish.yml that calls flutter-build workflow - Add release job that creates GitHub release with debug APK and unsigned iOS build when a version tag is pushed - Auto-detect debug vs release APK and name appropriately - Mark alpha/beta/rc versions as pre-releases * Add automatic alpha version bump after release When an alpha tag (e.g., v0.6.7-alpha.3) is published and the Docker image is built, automatically bump the alpha number in version.rb (e.g., alpha.3 -> alpha.4) and push to main branch. * Fix APK copying to include both debug and release builds Change if/elif to separate if statements so both app-debug.apk and app-release.apk are copied to release assets when both exist. * Rename artifact names in publish workflow Signed-off-by: Juan José Mata <juanjo.mata@gmail.com> * Revert rename of artifact names Signed-off-by: Juan José Mata <juanjo.mata@gmail.com> * Enhance version bump process in publish.yml Refactor version bump script to ensure version file exists and improve error handling. Signed-off-by: Juan José Mata <juanjo.mata@gmail.com> --------- Signed-off-by: Juan José Mata <juanjo.mata@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
3
.github/workflows/flutter-build.yml
vendored
3
.github/workflows/flutter-build.yml
vendored
@@ -4,6 +4,8 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- 'v*'
|
||||
paths:
|
||||
- 'mobile/lib/**'
|
||||
- 'mobile/android/**'
|
||||
@@ -17,6 +19,7 @@ on:
|
||||
- 'mobile/ios/**'
|
||||
- 'mobile/pubspec.yaml'
|
||||
- '.github/workflows/flutter-build.yml'
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
|
||||
157
.github/workflows/publish.yml
vendored
157
.github/workflows/publish.yml
vendored
@@ -39,7 +39,8 @@ env:
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
@@ -239,3 +240,157 @@ jobs:
|
||||
echo "Push failed (attempt $attempts). Retrying in ${delay} seconds..."
|
||||
sleep ${delay}
|
||||
done
|
||||
|
||||
mobile:
|
||||
name: Build Mobile Apps
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
uses: ./.github/workflows/flutter-build.yml
|
||||
secrets: inherit
|
||||
|
||||
release:
|
||||
name: Create GitHub Release
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
needs: [merge, mobile]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Download Android APK artifact
|
||||
uses: actions/download-artifact@v4.3.0
|
||||
with:
|
||||
name: app-release-apk
|
||||
path: ${{ runner.temp }}/mobile-artifacts
|
||||
|
||||
- name: Download iOS build artifact
|
||||
uses: actions/download-artifact@v4.3.0
|
||||
with:
|
||||
name: ios-build-unsigned
|
||||
path: ${{ runner.temp }}/ios-build
|
||||
|
||||
- name: Prepare release assets
|
||||
run: |
|
||||
mkdir -p ${{ runner.temp }}/release-assets
|
||||
|
||||
# Copy debug APK if it exists
|
||||
if [ -f "${{ runner.temp }}/mobile-artifacts/app-debug.apk" ]; then
|
||||
cp "${{ runner.temp }}/mobile-artifacts/app-debug.apk" "${{ runner.temp }}/release-assets/sure-${{ github.ref_name }}-debug.apk"
|
||||
echo "✓ Debug APK prepared"
|
||||
fi
|
||||
|
||||
# Copy release APK if it exists
|
||||
if [ -f "${{ runner.temp }}/mobile-artifacts/app-release.apk" ]; then
|
||||
cp "${{ runner.temp }}/mobile-artifacts/app-release.apk" "${{ runner.temp }}/release-assets/sure-${{ github.ref_name }}.apk"
|
||||
echo "✓ Release APK prepared"
|
||||
fi
|
||||
|
||||
# Create iOS app archive (zip the .app bundle)
|
||||
if [ -d "${{ runner.temp }}/ios-build/Runner.app" ]; then
|
||||
cd "${{ runner.temp }}/ios-build"
|
||||
zip -r "${{ runner.temp }}/release-assets/sure-${{ github.ref_name }}-ios-unsigned.zip" Runner.app
|
||||
echo "✓ iOS build archive prepared"
|
||||
fi
|
||||
|
||||
# Copy iOS build info
|
||||
if [ -f "${{ runner.temp }}/ios-build/ios-build-info.txt" ]; then
|
||||
cp "${{ runner.temp }}/ios-build/ios-build-info.txt" "${{ runner.temp }}/release-assets/"
|
||||
fi
|
||||
|
||||
echo "Release assets:"
|
||||
ls -la "${{ runner.temp }}/release-assets/"
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ github.ref_name }}
|
||||
name: ${{ github.ref_name }}
|
||||
draft: false
|
||||
prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc') }}
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
${{ runner.temp }}/release-assets/*
|
||||
body: |
|
||||
## Mobile Debug Builds
|
||||
|
||||
This release includes debug builds of the mobile applications:
|
||||
|
||||
- **Android APK**: Debug build for testing on Android devices
|
||||
- **iOS Build**: Unsigned iOS build (requires code signing for installation)
|
||||
|
||||
> **Note**: These are debug builds intended for testing purposes. For production use, please build from source with proper signing credentials.
|
||||
|
||||
bump-alpha-version:
|
||||
name: Bump Alpha Version
|
||||
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref_name, 'alpha')
|
||||
needs: [merge]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Check out main branch
|
||||
uses: actions/checkout@v4.2.0
|
||||
with:
|
||||
ref: main
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Bump alpha version
|
||||
run: |
|
||||
VERSION_FILE="config/initializers/version.rb"
|
||||
|
||||
# Ensure version file exists
|
||||
if [ ! -f "$VERSION_FILE" ]; then
|
||||
echo "ERROR: Version file not found: $VERSION_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract current version
|
||||
CURRENT_VERSION=$(grep -oP '"\K[0-9]+\.[0-9]+\.[0-9]+-alpha\.[0-9]+' "$VERSION_FILE")
|
||||
if [ -z "$CURRENT_VERSION" ]; then
|
||||
echo "ERROR: Could not extract version from $VERSION_FILE"
|
||||
exit 1
|
||||
fi
|
||||
echo "Current version: $CURRENT_VERSION"
|
||||
|
||||
# Extract the alpha number and increment it
|
||||
ALPHA_NUM=$(echo "$CURRENT_VERSION" | grep -oP 'alpha\.\K[0-9]+')
|
||||
if [ -z "$ALPHA_NUM" ]; then
|
||||
echo "ERROR: Could not extract alpha number from $CURRENT_VERSION"
|
||||
exit 1
|
||||
fi
|
||||
NEW_ALPHA_NUM=$((ALPHA_NUM + 1))
|
||||
|
||||
# Create new version string
|
||||
BASE_VERSION=$(echo "$CURRENT_VERSION" | grep -oP '^[0-9]+\.[0-9]+\.[0-9]+')
|
||||
if [ -z "$BASE_VERSION" ]; then
|
||||
echo "ERROR: Could not extract base version from $CURRENT_VERSION"
|
||||
exit 1
|
||||
fi
|
||||
NEW_VERSION="${BASE_VERSION}-alpha.${NEW_ALPHA_NUM}"
|
||||
echo "New version: $NEW_VERSION"
|
||||
|
||||
- name: Commit and push version bump
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
git add config/initializers/version.rb
|
||||
git commit -m "Bump version to next alpha after ${{ github.ref_name }} release"
|
||||
|
||||
# Push with retry logic
|
||||
attempts=0
|
||||
until git push origin main; do
|
||||
attempts=$((attempts + 1))
|
||||
if [[ $attempts -ge 4 ]]; then
|
||||
echo "ERROR: Failed to push after 4 attempts." >&2
|
||||
exit 1
|
||||
fi
|
||||
delay=$((2 ** attempts))
|
||||
echo "Push failed (attempt $attempts). Retrying in ${delay} seconds..."
|
||||
sleep ${delay}
|
||||
git pull --rebase origin main
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user