-
Notifications
You must be signed in to change notification settings - Fork 10
75 lines (67 loc) · 3.01 KB
/
Copy pathprep-dev.yml
File metadata and controls
75 lines (67 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Roll CalVer to the new month
# On the 1st of each month, roll main's MARKETING_VERSION to <year>.<month>.1
# (un-padded month, matching Android's Packaging.kt rollover) so dogfood/deploy
# builds off main are labelled with the right month between releases. Commits
# straight to main via a PAT — the iOS mirror of Android's prep-dev.yml, which
# pushes to code/cash. The default GITHUB_TOKEN can neither open PRs nor push to
# main here, so BOT_GITHUB_TOKEN (an admin-owned PAT that bypasses the PR gate)
# is required.
#
# Within a month the cycle number is advanced by /release step 9a; this job only
# handles the month boundary. Safe to re-run / dispatch mid-month: it no-ops when
# main is already on the current month (it never downgrades the cycle).
on:
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:
jobs:
roll-version:
name: Roll MARKETING_VERSION to the new month
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
persist-credentials: false # push with the PAT below, not GITHUB_TOKEN
- name: Compute target version
id: calc
run: |
set -euo pipefail
PBX=Code.xcodeproj/project.pbxproj
Y=$(date +%Y)
M=$(date +%m | sed 's/^0//') # un-padded month, matches Android
NEW="$Y.$M.1"
# Current app-family version = the sole non-1.0 MARKETING_VERSION value.
mapfile -t CURVALS < <(grep -oE 'MARKETING_VERSION = [^;]+;' "$PBX" \
| sed -E 's/MARKETING_VERSION = (.+);/\1/' | grep -vx '1.0' | sort -u)
if [ "${#CURVALS[@]}" -ne 1 ]; then
echo "Expected exactly one app-family MARKETING_VERSION, found: ${CURVALS[*]:-none}" >&2
exit 1
fi
CUR="${CURVALS[0]}"
echo "Current: $CUR Target: $NEW"
if [[ "$CUR" == "$Y.$M."* ]]; then
echo "main is already on $Y.$M — nothing to roll (cycle is managed by /release)."
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
sed -i "s/MARKETING_VERSION = ${CUR//./\\.};/MARKETING_VERSION = $NEW;/g" "$PBX"
git diff --quiet "$PBX" && { echo "changed=false" >> "$GITHUB_OUTPUT"; exit 0; }
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "new=$NEW" >> "$GITHUB_OUTPUT"
- name: Commit & push to main
if: steps.calc.outputs.changed == 'true'
env:
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
NEW: ${{ steps.calc.outputs.new }}
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Code.xcodeproj/project.pbxproj
git commit -m "chore: bump version to $NEW"
REMOTE="https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git"
git pull --rebase "$REMOTE" main
git push "$REMOTE" HEAD:main