release = org.cdnutter.<name> (main, Gitea release + Sideload) dev = org.cdnutter.<name>-dev (dev branch, Gitea pre-release + Sideload Developer) prov = org.cdnutter.<name>-prov (personal signed, never published) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
2.3 KiB
Bash
Executable File
37 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# Publishes an IPA built by build-remote.sh. Run from DevOps with everything committed.
|
|
# publish.sh dev on the dev branch: Gitea pre-release ios-v<v>-dev.<build> + Sideload Developer (WHITE-M1 :8097)
|
|
# publish.sh release on main, only when the owner says so: Gitea release ios-v<v> + Sideload (:8093), then source.json
|
|
# Release notes come from $NOTES, else the last commit subject. prov builds are never published.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
MODE=${1:-}; NAME=stemify; TAGP=ios-v
|
|
API=https://git.iamchrisama.com/api/v1/repos/cdnutter/stemify
|
|
T=$(sed -n 's#.*://cdnutter:\([^@]*\)@.*#\1#p' ~/.config/gitea/cdnutter.credentials | head -1)
|
|
V=$(sed -nE 's/^ *VERSION_LABEL: "(.*)"/\1/p' project.yml | tr 'A-Z' 'a-z' | sed -E 's/ (rc|beta) /-\1/; s/ /-/g')
|
|
BUILD=$(sed -nE 's/^ *CURRENT_PROJECT_VERSION: "(.*)"/\1/p' project.yml)
|
|
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
die() { echo "$*" >&2; exit 1; }
|
|
case $MODE in
|
|
dev) WANT=dev; IPA=build/dev/$NAME-$V-dev.ipa; TAG=$TAGP$V-dev.$BUILD; PRE=true; UP=http://10.0.0.11:8097 ;;
|
|
release) WANT=main; IPA=build/release/$NAME-$V.ipa; TAG=$TAGP$V; PRE=false; UP=http://10.0.0.11:8093 ;;
|
|
*) die "usage: $0 dev|release" ;;
|
|
esac
|
|
[ "$BRANCH" = "$WANT" ] || die "$MODE builds publish from $WANT (on $BRANCH)"
|
|
[ -f "$IPA" ] || die "missing $IPA, run scripts/build-remote.sh $MODE"
|
|
git diff --quiet HEAD || die "uncommitted changes"
|
|
[ "$(curl -s -o /dev/null -w '%{http_code}' -H "Authorization: token $T" $API/releases/tags/$TAG)" = 404 ] \
|
|
|| die "$TAG already exists, bump CURRENT_PROJECT_VERSION (dev) or VERSION_LABEL (release)"
|
|
git push -q -u origin $BRANCH
|
|
BODY=${NOTES:-$(git log -1 --format=%s)}
|
|
ID=$(jq -n --arg t "$TAG" --arg c "$(git rev-parse HEAD)" --arg b "$BODY" --argjson p $PRE \
|
|
'{tag_name:$t, target_commitish:$c, name:$t, body:$b, prerelease:$p}' |
|
|
curl -fsS -H "Authorization: token $T" -H 'Content-Type: application/json' -d @- $API/releases | jq -r .id)
|
|
curl -fsS -o /dev/null -H "Authorization: token $T" -F "attachment=@$IPA" "$API/releases/$ID/assets?name=$(basename $IPA)"
|
|
curl -fsS -o /dev/null -X POST --data-binary @$IPA $UP/api/upload/ipa
|
|
echo "published $TAG ($(basename $IPA)) to Gitea and $UP"
|
|
if [ $MODE = release ]; then
|
|
GITEA_TOKEN=$T python3 scripts/make-source.py
|
|
git add source.json && git commit -qm "iOS source.json for $TAG" && git push -q origin main
|
|
fi
|