Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions .github/workflows/release-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
# How it runs:
# - A pull request into dev: tests and builds every package, publishes
# nothing (packages are on the run's page). A newer push to the PR cancels
# the older run.
# the older run. A package that already passed on the PR is not built
# again unless a file it builds from changed since (tools/ci/changed-jobs.sh;
# the "changes" job's summary links the run where it passed).
# - Merging it (any push to dev): builds and publishes the next beta,
# <Cargo.toml version>-beta.<run number>, e.g. 0.1.0-beta.12, and tags it.
# Run numbers count PR runs too, so betas are not consecutive.
# - By hand: Actions > Beta release > Run workflow. Untick "publish" for a
# dry run.
# - Push a tag: git tag v0.1.0-beta.3 && git push origin v0.1.0-beta.3
# Changes to Markdown alone do not run it.
# Changes to Markdown, docs/ or brand/ alone do not run it.
#
# Mullion.app checks these releases for updates (crates/host/src/update.rs);
# it installs the .pkg asset.
Expand All @@ -30,14 +32,15 @@
default: true
pull_request:
branches: [dev]
paths-ignore: ["**.md"]
paths-ignore: ["**.md", "docs/**", "brand/**"]
push:
branches: [dev]
tags: ["v*-beta.*"]
paths-ignore: ["**.md"]
paths-ignore: ["**.md", "docs/**", "brand/**"]

permissions:
contents: write
actions: read # changes: earlier runs of this PR

Check warning on line 43 in .github/workflows/release-beta.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move this read permission from workflow level to job level.

See more on https://sonarcloud.io/project/issues?id=th3r-dev_mullion&issues=AaHMdsNJ2tqX_I7jvwxH&open=AaHMdsNJ2tqX_I7jvwxH&pullRequest=25

# Releases one at a time, in order; a PR's runs replace each other.
concurrency:
Expand All @@ -63,8 +66,30 @@
echo "version=$v" >> "$GITHUB_OUTPUT"
echo "Version: $v"

# Which packages this run builds: on a PR, only those a change can affect.
changes:
runs-on: ubuntu-latest
outputs:
macos: ${{ steps.pick.outputs.macos }}
windows: ${{ steps.pick.outputs.windows }}
android: ${{ steps.pick.outputs.android }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # to compare with the commit where a package last passed
- id: pick
env:
EVENT: ${{ github.event_name }}
TO_SHA: ${{ github.sha }}
REPO: ${{ github.repository }}
BRANCH: ${{ github.head_ref }}
RUN_ID: ${{ github.run_id }}
GH_TOKEN: ${{ github.token }}
run: tools/ci/changed-jobs.sh

macos:
needs: version
needs: [version, changes]
if: needs.changes.outputs.macos == 'true'
# Apple silicon, like the package (hostArchitectures="arm64").
runs-on: macos-15
timeout-minutes: 45
Expand Down Expand Up @@ -107,7 +132,8 @@
if-no-files-found: error

windows:
needs: version
needs: [version, changes]
if: needs.changes.outputs.windows == 'true'
runs-on: windows-latest
timeout-minutes: 45
env:
Expand All @@ -130,7 +156,8 @@
if-no-files-found: error

android:
needs: version
needs: [version, changes]
if: needs.changes.outputs.android == 'true'
runs-on: ubuntu-latest
timeout-minutes: 45
env:
Expand Down
73 changes: 73 additions & 0 deletions tools/ci/changed-jobs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bash
# Which platform jobs a run of release-beta.yml must build (its "changes" job).
#
# On a pull request a job is skipped when it already passed on this PR at some
# commit S, and nothing it builds from has changed since S. Pushes to dev, tags
# and manual runs build everything: each release stamps a new version into all
# three packages.
#
# Env: EVENT (github.event_name), TO_SHA (the commit this run builds),
# REPO, BRANCH (the PR's head branch), RUN_ID (this run, left out of the
# search), GH_TOKEN. Writes macos=, windows=, android= to $GITHUB_OUTPUT and a
# line per job to $GITHUB_STEP_SUMMARY.
set -euo pipefail

out=${GITHUB_OUTPUT:-/dev/stdout}
summary=${GITHUB_STEP_SUMMARY:-/dev/stderr}
jobs="macos windows android"

# What each job builds from (tools/package-macos.sh, build-android.sh, the
# include_str!s). Shared: every package compiles proto and carries the page.
shared='^(Cargo\.(toml|lock)$|crates/proto/|crates/app/assets/|\.github/workflows/release-beta\.yml$|tools/ci/)'
own() {
case $1 in

Check failure on line 23 in tools/ci/changed-jobs.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a default case (*) to handle unexpected values.

See more on https://sonarcloud.io/project/issues?id=th3r-dev_mullion&issues=AaHMdsLl2tqX_I7jvwxA&open=AaHMdsLl2tqX_I7jvwxA&pullRequest=25
macos) echo '^(crates/host/|tools/package-macos\.sh$|tools/macos/)' ;;
# cargo build of the app: not android/ (Kotlin, launcher icons) or Dioxus.toml.
windows) echo '^crates/app/(src/|build\.rs$|Cargo\.toml$)' ;;
android) echo '^(crates/app/|crates/host/|tools/build-android\.sh$)' ;;
esac
}

if [ "${EVENT:?}" != pull_request ]; then

Check failure on line 31 in tools/ci/changed-jobs.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=th3r-dev_mullion&issues=AaHMdsLl2tqX_I7jvwxB&open=AaHMdsLl2tqX_I7jvwxB&pullRequest=25
for j in $jobs; do echo "$j=true" >> "$out"; done
echo "Builds every package (${EVENT})." >> "$summary"
exit 0
fi

# The newest earlier run on this PR in which each job passed: its commit and
# run id. Only real builds count, never a skip, so reuse does not chain.
runs=$(gh api -X GET "repos/${REPO:?}/actions/workflows/release-beta.yml/runs" \
-f branch="${BRANCH:?}" -f event=pull_request -f per_page=30 \
--jq '.workflow_runs[] | "\(.id) \(.head_sha)"') || runs="" # API trouble: build everything
found=""
while read -r id sha; do
[ -n "$id" ] && [ "$id" != "${RUN_ID:-}" ] || continue

Check failure on line 44 in tools/ci/changed-jobs.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=th3r-dev_mullion&issues=AaHMdsLl2tqX_I7jvwxC&open=AaHMdsLl2tqX_I7jvwxC&pullRequest=25

Check failure on line 44 in tools/ci/changed-jobs.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=th3r-dev_mullion&issues=AaHMdsLl2tqX_I7jvwxD&open=AaHMdsLl2tqX_I7jvwxD&pullRequest=25
passed=$(gh api "repos/$REPO/actions/runs/$id/jobs" --jq '.jobs[] | select(.conclusion == "success") | .name') || passed=""
for j in $jobs; do
case " $found " in *" $j="*) continue ;; esac
if grep -qx "$j" <<< "$passed"; then found="$found $j=$id:$sha"; fi
done
[ "$(wc -w <<< "$found")" -lt 3 ] || break

Check failure on line 50 in tools/ci/changed-jobs.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=th3r-dev_mullion&issues=AaHMdsLl2tqX_I7jvwxE&open=AaHMdsLl2tqX_I7jvwxE&pullRequest=25
done <<< "$runs"

for j in $jobs; do
hit=$(tr ' ' '\n' <<< "$found" | sed -n "s/^$j=//p")
run=${hit%%:*} sha=${hit#*:}
build=true why="no earlier pass on this PR"
if [ -n "$hit" ]; then
if ! git cat-file -e "$sha^{commit}" 2>/dev/null; then
why="its last pass (${sha:0:7}) is gone from history (force push)"
else
# Against the merge commit this run builds: also counts what dev gained
# since, so a skip is never wrong (it may rebuild more than needed).
changed=$(git diff --name-only "$sha" "${TO_SHA:?}" | grep -E "$shared|$(own "$j")" || true)
if [ -z "$changed" ]; then

Check failure on line 64 in tools/ci/changed-jobs.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=th3r-dev_mullion&issues=AaHMdsLl2tqX_I7jvwxF&open=AaHMdsLl2tqX_I7jvwxF&pullRequest=25
build=false why="reused: passed at ${sha:0:7} in [run $run](https://github.com/$REPO/actions/runs/$run), nothing it builds from changed since"
else
why="changed since its pass at ${sha:0:7}: $(head -3 <<< "$changed" | tr '\n' ' ')"
fi
fi
fi
echo "$j=$build" >> "$out"
echo "- **$j**: $([ "$build" = true ] && echo built || echo skipped). $why" >> "$summary"

Check failure on line 72 in tools/ci/changed-jobs.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=th3r-dev_mullion&issues=AaHMdsLl2tqX_I7jvwxG&open=AaHMdsLl2tqX_I7jvwxG&pullRequest=25
done
3 changes: 3 additions & 0 deletions tools/package-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# tools/package-macos.sh
# -> dist/macos/Mullion.app, dist/Mullion-<version>.pkg (ad-hoc signed)
#
# In CI a pull request rebuilds this package only when a file it builds from
# changed (tools/ci/changed-jobs.sh): add new inputs there too.
#
# Signing (optional):
# MULLION_SIGN_ID="Mullion Code Signing" tools/package-macos.sh
# A stable signature: macOS keeps Screen Recording permission across
Expand Down
Loading