Skip to content

Add agent-first app flow skills for desktop and mobile (#5534) #86

Add agent-first app flow skills for desktop and mobile (#5534)

Add agent-first app flow skills for desktop and mobile (#5534) #86

name: Auto Release Desktop on Main
on:
push:
branches: ["main"]
paths:
- 'desktop/**'
- '!desktop/CHANGELOG.json'
permissions:
contents: write
pull-requests: write
concurrency:
group: desktop-auto-release-main
cancel-in-progress: false
jobs:
tag-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Wait for previous desktop release build
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
if [ -z "${GH_TOKEN:-}" ]; then
echo "PAT_TOKEN is not configured; cannot inspect previous release build status."
exit 1
fi
LATEST=$(git tag -l 'v*-macos' | sort -V | tail -1)
if [ -z "$LATEST" ]; then
echo "No previous macOS tag found."
exit 0
fi
SHA=$(gh api "repos/${{ github.repository }}/git/ref/tags/$LATEST" --jq '.object.sha')
echo "Latest tag: $LATEST ($SHA)"
for i in {1..120}; do
STATUS=$(gh api "repos/${{ github.repository }}/commits/$SHA/check-runs" \
--jq '.check_runs[] | select(.name=="Release OMI Desktop (Swift)") | .status' | head -n1 || true)
CONCLUSION=$(gh api "repos/${{ github.repository }}/commits/$SHA/check-runs" \
--jq '.check_runs[] | select(.name=="Release OMI Desktop (Swift)") | .conclusion' | head -n1 || true)
if [ -z "$STATUS" ]; then
echo "No Codemagic release check found for $LATEST yet; continuing."
exit 0
fi
echo "Previous release build status: $STATUS (${CONCLUSION:-n/a})"
if [ "$STATUS" = "completed" ]; then
exit 0
fi
sleep 60
done
echo "Timed out waiting for previous desktop release build to finish."
exit 1
- name: Compute next version and consolidate changelog
id: version
run: |
# Get latest desktop release tag
LATEST=$(git tag -l 'v*-macos' | sort -V | tail -1)
if [ -z "$LATEST" ]; then
VERSION="0.0.1"
else
# Strip v prefix and +build-macos suffix e.g. v0.11.11+11011-macos -> 0.11.11
VER=$(echo "$LATEST" | sed -E 's/^v([0-9.]+)\+[0-9]+-macos$/\1/')
MAJOR=$(echo "$VER" | cut -d. -f1)
MINOR=$(echo "$VER" | cut -d. -f2)
PATCH=$(echo "$VER" | cut -d. -f3)
PATCH=$((${PATCH:-0} + 1))
VERSION="$MAJOR.$MINOR.$PATCH"
fi
# Build number: 0.11.12 -> 11012 (each component * 1000, summed)
BUILD_NUMBER=$(echo "$VERSION" | tr '.' '\n' | awk '{s=s*1000+$1}END{print s}')
RELEASE_TAG="v${VERSION}+${BUILD_NUMBER}-macos"
echo "Latest tag : ${LATEST:-none}"
echo "New version: $VERSION"
echo "New tag : $RELEASE_TAG"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "release_tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
# Consolidate unreleased changelog entries into a versioned release
TODAY=$(date -u +%Y-%m-%d)
python3 -c "
import json, sys
with open('desktop/CHANGELOG.json', 'r') as f:
data = json.load(f)
unreleased = data.get('unreleased', [])
if not unreleased:
unreleased = ['Bug fixes and improvements']
new_release = {
'version': '$VERSION',
'date': '$TODAY',
'changes': unreleased
}
data.setdefault('releases', []).insert(0, new_release)
data['unreleased'] = []
with open('desktop/CHANGELOG.json', 'w') as f:
json.dump(data, f, indent=2)
f.write('\n')
print(f'Consolidated {len(unreleased)} changelog entries for v$VERSION')
"
- name: Commit changelog and create tag
run: |
VERSION="${{ steps.version.outputs.version }}"
RELEASE_TAG="${{ steps.version.outputs.release_tag }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add desktop/CHANGELOG.json
git commit -m "chore: consolidate changelog for v${VERSION}" || echo "No changelog changes to commit"
# Tag the changelog commit first; Codemagic uses this tag to trigger builds.
# NOTE: commit message must NOT contain [skip ci].
git tag "$RELEASE_TAG"
git push origin "$RELEASE_TAG"
- name: Create and auto-merge PR to sync changelog back to main
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
if [ -z "${GH_TOKEN:-}" ]; then
echo "PAT_TOKEN is not configured; cannot auto-merge changelog PR."
exit 1
fi
VERSION="${{ steps.version.outputs.version }}"
BRANCH="changelog/v${VERSION}"
git checkout -B "$BRANCH"
git push --force-with-lease origin "$BRANCH"
PR_NUMBER=$(gh pr list \
--head "$BRANCH" \
--base main \
--state open \
--json number \
--jq '.[0].number')
if [ -z "$PR_NUMBER" ]; then
PR_URL=$(gh pr create \
--title "Update CHANGELOG.json for v${VERSION} [skip ci]" \
--body "Auto-generated: consolidates unreleased entries into v${VERSION} and clears the unreleased array." \
--base main \
--head "$BRANCH")
PR_NUMBER=$(echo "$PR_URL" | awk -F/ '{print $NF}')
fi
# Merge changelog PR in protected branches:
# 1) admin merge if allowed, 2) auto-merge if repo supports it, 3) regular merge if already mergeable.
gh pr merge "$PR_NUMBER" --merge --admin || \
gh pr merge "$PR_NUMBER" --merge --auto || \
gh pr merge "$PR_NUMBER" --merge || \
echo "Changelog PR #$PR_NUMBER requires manual merge."