Repository navigation
Aether - Sync upstream #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Aether - Sync upstream | |
| # Follows NuvioMedia/NuvioMobile: merges each new upstream release (or the upstream branch tip) | |
| # into this fork, then builds and publishes the IPA with the AetherEngine player. | |
| # | |
| # Settings (Settings > Secrets and variables > Actions): | |
| # secret FORK_SYNC_TOKEN fine-grained token with Contents + Workflows read/write on this | |
| # repository. Needed whenever an upstream merge touches | |
| # .github/workflows (the default token is not allowed to push those). | |
| # secret NUVIO_LOCAL_PROPERTIES_BASE64 optional, same as upstream's (runtime keys) | |
| # variable UPSTREAM_REPOSITORY default NuvioMedia/NuvioMobile | |
| # variable UPSTREAM_BRANCH default cmp-rewrite | |
| # variable AETHER_TRACK "release" (default) or "branch" | |
| # variable AETHER_MACOS_RUNNER default xcode-27 | |
| on: | |
| schedule: | |
| - cron: "23 */6 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| track: | |
| description: Follow upstream releases, or the tip of the upstream branch | |
| type: choice | |
| options: | |
| - release | |
| - branch | |
| default: release | |
| force_build: | |
| description: Build and publish even if this version was already published | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| issues: write | |
| concurrency: | |
| group: aether-sync-upstream | |
| cancel-in-progress: false | |
| jobs: | |
| sync: | |
| name: Merge upstream | |
| # Fork-only: upstream is only ever read (fetch, release list); everything is written to this | |
| # repository, and the workflow never runs in the upstream repository itself. | |
| if: github.repository != 'NuvioMedia/NuvioMobile' | |
| runs-on: ubuntu-latest | |
| env: | |
| UPSTREAM_REPOSITORY: ${{ vars.UPSTREAM_REPOSITORY || 'NuvioMedia/NuvioMobile' }} | |
| UPSTREAM_BRANCH: ${{ vars.UPSTREAM_BRANCH || 'cmp-rewrite' }} | |
| TRACK: ${{ inputs.track || vars.AETHER_TRACK || 'release' }} | |
| FORCE_BUILD: ${{ inputs.force_build || false }} | |
| BRANCH: ${{ github.ref_name }} | |
| HAS_SYNC_TOKEN: ${{ secrets.FORK_SYNC_TOKEN != '' }} | |
| GH_TOKEN: ${{ github.token }} | |
| outputs: | |
| build: ${{ steps.decide.outputs.build }} | |
| upstream_tag: ${{ steps.upstream.outputs.tag }} | |
| branch: ${{ github.ref_name }} | |
| steps: | |
| - name: Check out fork | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.ref_name }} | |
| fetch-depth: 0 | |
| token: ${{ secrets.FORK_SYNC_TOKEN || github.token }} | |
| - name: Find the upstream target | |
| id: upstream | |
| run: | | |
| git remote add upstream "https://github.com/${UPSTREAM_REPOSITORY}.git" | |
| if [[ "${TRACK}" == "branch" ]]; then | |
| git fetch --no-tags upstream "${UPSTREAM_BRANCH}" | |
| ref="refs/remotes/upstream/${UPSTREAM_BRANCH}" | |
| label="${UPSTREAM_REPOSITORY}@${UPSTREAM_BRANCH}" | |
| tag="" | |
| else | |
| # Newest published release, pre-releases included (upstream ships "x.y.z-beta"). | |
| tag="$(gh release list --repo "${UPSTREAM_REPOSITORY}" --exclude-drafts --limit 1 \ | |
| --json tagName --jq '.[0].tagName')" | |
| if [[ -z "${tag}" ]]; then | |
| echo "No upstream release found." >&2 | |
| exit 1 | |
| fi | |
| git fetch --no-tags upstream "+refs/tags/${tag}:refs/upstream-tags/${tag}" | |
| ref="refs/upstream-tags/${tag}" | |
| label="${UPSTREAM_REPOSITORY} ${tag}" | |
| fi | |
| { | |
| echo "ref=${ref}" | |
| echo "label=${label}" | |
| echo "tag=${tag}" | |
| } >> "${GITHUB_OUTPUT}" | |
| echo "Upstream target: ${label} ($(git rev-parse --short "${ref}^{commit}"))" | |
| - name: Merge | |
| id: merge | |
| env: | |
| REF: ${{ steps.upstream.outputs.ref }} | |
| LABEL: ${{ steps.upstream.outputs.label }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| report() { | |
| local title="Upstream sync blocked: ${LABEL}" | |
| local body_file="${RUNNER_TEMP}/issue.md" | |
| { | |
| echo "$1" | |
| echo | |
| echo "Resolve it locally, then push:" | |
| echo | |
| echo '```bash' | |
| echo "git remote add upstream https://github.com/${UPSTREAM_REPOSITORY}.git" | |
| echo "git fetch upstream" | |
| echo "git merge $(git rev-parse "${REF}^{commit}") # ${LABEL}" | |
| echo "python3 aether/scripts/patch-xcode-project.py # must still succeed (do not commit its changes)" | |
| echo "git checkout -- iosApp/iosApp.xcodeproj/project.pbxproj" | |
| echo "git push" | |
| echo '```' | |
| echo | |
| echo "Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | |
| } > "${body_file}" | |
| cat "${body_file}" >> "${GITHUB_STEP_SUMMARY}" | |
| # Best effort: issues may be disabled on the fork. | |
| existing="$(gh issue list --repo "${GITHUB_REPOSITORY}" --state open --search "\"${title}\" in:title" \ | |
| --json number --jq '.[0].number // empty' 2>/dev/null || true)" | |
| if [[ -n "${existing}" ]]; then | |
| gh issue comment "${existing}" --repo "${GITHUB_REPOSITORY}" --body-file "${body_file}" || true | |
| else | |
| gh issue create --repo "${GITHUB_REPOSITORY}" --title "${title}" --body-file "${body_file}" || true | |
| fi | |
| } | |
| target="$(git rev-parse "${REF}^{commit}")" | |
| if git merge-base --is-ancestor "${target}" HEAD; then | |
| echo "${BRANCH} already contains ${LABEL}." | |
| echo "merged=false" >> "${GITHUB_OUTPUT}" | |
| exit 0 | |
| fi | |
| if ! git merge --no-ff --no-edit -m "Merge upstream ${LABEL} into ${BRANCH}" "${target}"; then | |
| # shellcheck disable=SC2016 # "$" is sed's end-of-line anchor | |
| conflicts="$(git diff --name-only --diff-filter=U | sed 's/^/- `/; s/$/`/')" | |
| git merge --abort | |
| report "Merging ${LABEL} into \`${BRANCH}\` conflicts in:"$'\n\n'"${conflicts}" | |
| exit 1 | |
| fi | |
| # The AetherEngine integration must still apply to upstream's Xcode project. | |
| cp iosApp/iosApp.xcodeproj/project.pbxproj "${RUNNER_TEMP}/project.pbxproj" | |
| if ! python3 aether/scripts/patch-xcode-project.py "${RUNNER_TEMP}/project.pbxproj"; then | |
| report "After merging ${LABEL}, \`aether/scripts/patch-xcode-project.py\` no longer applies to upstream's Xcode project. Nothing was pushed." | |
| exit 1 | |
| fi | |
| if ! git push origin "HEAD:${BRANCH}" 2> "${RUNNER_TEMP}/push.log"; then | |
| cat "${RUNNER_TEMP}/push.log" >&2 | |
| if grep -q "workflow" "${RUNNER_TEMP}/push.log" && [[ "${HAS_SYNC_TOKEN}" != "true" ]]; then | |
| report "The merge of ${LABEL} changes \`.github/workflows\`, which the default token cannot push. Add a \`FORK_SYNC_TOKEN\` secret (fine-grained token, Contents and Workflows: read and write) and re-run." | |
| else | |
| report "Pushing the merge of ${LABEL} to \`${BRANCH}\` failed." | |
| fi | |
| exit 1 | |
| fi | |
| echo "merged=true" >> "${GITHUB_OUTPUT}" | |
| echo "Merged ${LABEL} into ${BRANCH}." >> "${GITHUB_STEP_SUMMARY}" | |
| - name: Decide whether to build | |
| id: decide | |
| run: | | |
| version="$(sed -nE 's/^[[:space:]]*MARKETING_VERSION[[:space:]]*=[[:space:]]*([^[:space:]#]+).*$/\1/p' \ | |
| iosApp/Configuration/Version.xcconfig | head -n 1)" | |
| published="$(gh release list --repo "${GITHUB_REPOSITORY}" --limit 200 --json tagName \ | |
| --jq "[.[] | select(.tagName | startswith(\"${version}-aether\"))] | length")" | |
| build=false | |
| if [[ "${FORCE_BUILD}" == "true" || "${published}" == "0" ]]; then | |
| build=true | |
| fi | |
| echo "build=${build}" >> "${GITHUB_OUTPUT}" | |
| echo "Version ${version}: ${published} AetherEngine release(s) published, build=${build}" >> "${GITHUB_STEP_SUMMARY}" | |
| build: | |
| name: Build and publish | |
| needs: sync | |
| if: needs.sync.outputs.build == 'true' | |
| uses: ./.github/workflows/aether-build-ipa.yml | |
| with: | |
| ref: ${{ needs.sync.outputs.branch }} | |
| configuration: Release | |
| publish: true | |
| upstream_tag: ${{ needs.sync.outputs.upstream_tag }} | |
| secrets: inherit |