Skip to content

Commit e70136b

Browse files
authored
Merge pull request #151 from LoopKit/release-3.4
* Updates for Release 3.4
2 parents 96772eb + ba1b0d2 commit e70136b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+997
-313
lines changed

.circleci/config.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
jobs:
2-
build:
2+
build_and_test:
33
macos:
4-
xcode: 14.1.0
4+
xcode: 15.4.0
55
steps:
66
- checkout
77
- run:
88
name: Checkout submodules
99
command: git submodule update --init --recursive --depth 1
1010
- run:
1111
name: Build Loop
12-
command: set -o pipefail && time xcodebuild -workspace LoopWorkspace.xcworkspace -scheme 'LoopWorkspace' -destination 'platform=iOS Simulator,name=iPhone 13,OS=15.5' build | xcpretty
12+
command: set -o pipefail && time xcodebuild -workspace LoopWorkspace.xcworkspace -scheme 'LoopWorkspace' -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.5' build | xcpretty
1313
- run:
1414
name: Run Tests
15-
command: set -o pipefail && time xcodebuild -workspace LoopWorkspace.xcworkspace -scheme 'LoopWorkspace' -destination 'platform=iOS Simulator,name=iPhone 13,OS=15.5' test | xcpretty
16-
15+
command: set -o pipefail && time xcodebuild -workspace LoopWorkspace.xcworkspace -scheme 'LoopWorkspace' -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.5' test | xcpretty
16+
workflows:
17+
version: 2
18+
build_and_test:
19+
jobs:
20+
- build_and_test

.github/workflows/add_identifiers.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,42 @@
11
name: 2. Add Identifiers
2-
run-name: Add Identifiers
2+
run-name: Add Identifiers (${{ github.ref_name }})
33
on:
44
workflow_dispatch:
55

66
jobs:
7-
secrets:
7+
validate:
8+
name: Validate
89
uses: ./.github/workflows/validate_secrets.yml
910
secrets: inherit
10-
11+
1112
identifiers:
12-
needs: secrets
13+
name: Add Identifiers
14+
needs: validate
1315
runs-on: macos-14
1416
steps:
17+
# Uncomment to manually select latest Xcode if needed
18+
#- name: Select Latest Xcode
19+
# run: "sudo xcode-select --switch /Applications/Xcode_13.0.app/Contents/Developer"
20+
1521
# Checks-out the repo
1622
- name: Checkout Repo
1723
uses: actions/checkout@v4
18-
24+
1925
# Patch Fastlane Match to not print tables
2026
- name: Patch Match Tables
2127
run: find /usr/local/lib/ruby/gems -name table_printer.rb | xargs sed -i "" "/puts(Terminal::Table.new(params))/d"
28+
29+
# Install project dependencies
30+
- name: Install Project Dependencies
31+
run: bundle install
2232

2333
# Sync the GitHub runner clock with the Windows time server (workaround as suggested in https://github.com/actions/runner/issues/2996)
2434
- name: Sync clock
2535
run: sudo sntp -sS time.windows.com
2636

2737
# Create or update identifiers for app
2838
- name: Fastlane Provision
29-
run: fastlane identifiers
39+
run: bundle exec fastlane identifiers
3040
env:
3141
TEAMID: ${{ secrets.TEAMID }}
3242
GH_PAT: ${{ secrets.GH_PAT }}

.github/workflows/build_loop.yml

Lines changed: 239 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,267 @@
11
name: 4. Build Loop
2-
run-name: Build Loop ${{ github.ref_name }}
2+
run-name: Build Loop (${{ github.ref_name }})
33
on:
44
workflow_dispatch:
55

66
## Remove the "#" sign from the beginning of the line below to get automated builds on push (code changes in your repository)
77
#push:
8+
9+
schedule:
10+
- cron: '0 8 * * 3' # Checks for updates at 08:00 UTC every Wednesday
11+
- cron: '0 6 1 * *' # Builds the app on the 1st of every month at 06:00 UTC
812

9-
## Remove the "#" sign from the beginning of the two lines below to get automated builds every two months
10-
#schedule:
11-
#- cron: '0 17 1 */2 *' # Runs at 17:00 UTC on the 1st in Jan, Mar, May, Jul, Sep and Nov.
13+
env:
14+
UPSTREAM_REPO: LoopKit/LoopWorkspace
15+
UPSTREAM_BRANCH: ${{ github.ref_name }} # branch on upstream repository to sync from (replace with specific branch name if needed)
16+
TARGET_BRANCH: ${{ github.ref_name }} # target branch on fork to be kept in sync, and target branch on upstream to be kept alive (replace with specific branch name if needed)
17+
ALIVE_BRANCH: alive
1218

1319
jobs:
14-
secrets:
20+
validate:
21+
name: Validate
1522
uses: ./.github/workflows/validate_secrets.yml
1623
secrets: inherit
24+
25+
# Checks if GH_PAT holds workflow permissions
26+
# Checks for existence of alive branch; if non-existent creates it
27+
check_alive_and_permissions:
28+
needs: validate
29+
runs-on: ubuntu-latest
30+
name: Check alive branch and permissions
31+
permissions:
32+
contents: write
33+
outputs:
34+
WORKFLOW_PERMISSION: ${{ steps.workflow-permission.outputs.has_permission }}
35+
36+
steps:
37+
- name: Check for workflow permissions
38+
id: workflow-permission
39+
env:
40+
TOKEN_TO_CHECK: ${{ secrets.GH_PAT }}
41+
run: |
42+
PERMISSIONS=$(curl -sS -f -I -H "Authorization: token ${{ env.TOKEN_TO_CHECK }}" https://api.github.com | grep ^x-oauth-scopes: | cut -d' ' -f2-);
43+
44+
if [[ $PERMISSIONS =~ "workflow" || $PERMISSIONS == "" ]]; then
45+
echo "GH_PAT holds workflow permissions or is fine-grained PAT."
46+
echo "has_permission=true" >> $GITHUB_OUTPUT # Set WORKFLOW_PERMISSION to false.
47+
else
48+
echo "GH_PAT lacks workflow permissions."
49+
echo "Automated build features will be skipped!"
50+
echo "has_permission=false" >> $GITHUB_OUTPUT # Set WORKFLOW_PERMISSION to false.
51+
fi
52+
53+
- name: Check for alive branch
54+
if: steps.workflow-permission.outputs.has_permission == 'true'
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
57+
run: |
58+
if [[ "$(gh api -H "Accept: application/vnd.github+json" /repos/${{ github.repository_owner }}/LoopWorkspace/branches | jq --raw-output 'any(.name=="alive")')" == "true" ]]; then
59+
echo "Branch 'alive' exists."
60+
echo "ALIVE_BRANCH_EXISTS=true" >> $GITHUB_ENV # Set ALIVE_BRANCH_EXISTS to true
61+
else
62+
echo "Branch 'alive' does not exist."
63+
echo "ALIVE_BRANCH_EXISTS=false" >> $GITHUB_ENV # Set ALIVE_BRANCH_EXISTS to false
64+
fi
65+
66+
- name: Create alive branch
67+
if: env.ALIVE_BRANCH_EXISTS == 'false'
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
70+
run: |
71+
# Get ref for LoopKit/LoopWorkspace:dev
72+
SHA=$(curl -sS https://api.github.com/repos/${{ env.UPSTREAM_REPO }}/git/refs \
73+
| jq '.[] | select(.ref == "refs/heads/dev" ) | .object.sha' \
74+
| tr -d '"'
75+
);
76+
77+
# Create alive branch based on LoopKit/LoopWorkspace:dev
78+
gh api \
79+
--method POST \
80+
-H "Authorization: token $GITHUB_TOKEN" \
81+
-H "Accept: application/vnd.github.v3+json" \
82+
/repos/${{ github.repository_owner }}/LoopWorkspace/git/refs \
83+
-f ref='refs/heads/alive' \
84+
-f sha=$SHA
85+
86+
# Checks for changes in upstream repository; if changes exist prompts sync for build
87+
# Performs keepalive to avoid stale fork
88+
check_latest_from_upstream:
89+
needs: [validate, check_alive_and_permissions]
90+
runs-on: ubuntu-latest
91+
name: Check upstream and keep alive
92+
outputs:
93+
NEW_COMMITS: ${{ steps.sync.outputs.has_new_commits }}
94+
95+
steps:
96+
- name: Checkout target repo
97+
if: |
98+
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
99+
(vars.SCHEDULED_BUILD != 'false' || vars.SCHEDULED_SYNC != 'false')
100+
uses: actions/checkout@v4
101+
with:
102+
token: ${{ secrets.GH_PAT }}
103+
ref: alive
104+
105+
- name: Sync upstream changes
106+
if: | # do not run the upstream sync action on the upstream repository
107+
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
108+
vars.SCHEDULED_SYNC != 'false' && github.repository_owner != 'LoopKit'
109+
id: sync
110+
uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1
111+
with:
112+
target_sync_branch: ${{ env.ALIVE_BRANCH }}
113+
shallow_since: 6 months ago
114+
target_repo_token: ${{ secrets.GH_PAT }}
115+
upstream_sync_branch: ${{ env.UPSTREAM_BRANCH }}
116+
upstream_sync_repo: ${{ env.UPSTREAM_REPO }}
117+
118+
# Display a sample message based on the sync output var 'has_new_commits'
119+
- name: New commits found
120+
if: |
121+
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
122+
vars.SCHEDULED_SYNC != 'false' && steps.sync.outputs.has_new_commits == 'true'
123+
run: echo "New commits were found to sync."
124+
125+
- name: No new commits
126+
if: |
127+
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
128+
vars.SCHEDULED_SYNC != 'false' && steps.sync.outputs.has_new_commits == 'false'
129+
run: echo "There were no new commits."
130+
131+
- name: Show value of 'has_new_commits'
132+
if: needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' && vars.SCHEDULED_SYNC != 'false'
133+
run: |
134+
echo ${{ steps.sync.outputs.has_new_commits }}
135+
echo "NEW_COMMITS=${{ steps.sync.outputs.has_new_commits }}" >> $GITHUB_OUTPUT
136+
137+
# Keep repository "alive": add empty commits to ALIVE_BRANCH after "time_elapsed" days of inactivity to avoid inactivation of scheduled workflows
138+
- name: Keep alive
139+
if: |
140+
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
141+
(vars.SCHEDULED_BUILD != 'false' || vars.SCHEDULED_SYNC != 'false')
142+
uses: gautamkrishnar/keepalive-workflow@v1 # using the workflow with default settings
143+
with:
144+
time_elapsed: 20 # Time elapsed from the previous commit to trigger a new automated commit (in days)
17145

146+
- name: Show scheduled build configuration message
147+
if: needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION != 'true'
148+
run: |
149+
echo "### :calendar: Scheduled Sync and Build Disabled :mobile_phone_off:" >> $GITHUB_STEP_SUMMARY
150+
echo "You have not yet configured the scheduled sync and build for Loop's browser build." >> $GITHUB_STEP_SUMMARY
151+
echo "Synchronizing your fork of <code>LoopWorkspace</code> with the upstream repository <code>LoopKit/LoopWorkspace</code> will be skipped." >> $GITHUB_STEP_SUMMARY
152+
echo "If you want to enable automatic builds and updates for your Loop, please follow the instructions \
153+
under the following path <code>LoopWorkspace/fastlane/testflight.md</code>." >> $GITHUB_STEP_SUMMARY
154+
155+
# Builds Loop
18156
build:
19-
needs: secrets
157+
name: Build
158+
needs: [validate, check_alive_and_permissions, check_latest_from_upstream]
20159
runs-on: macos-14
160+
permissions:
161+
contents: write
162+
if: | # runs if started manually, or if sync schedule is set and enabled and scheduled on the first Saturday each month, or if sync schedule is set and enabled and new commits were found
163+
github.event_name == 'workflow_dispatch' ||
164+
(needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
165+
(vars.SCHEDULED_BUILD != 'false' && github.event.schedule == '0 6 1 * *') ||
166+
(vars.SCHEDULED_SYNC != 'false' && needs.check_latest_from_upstream.outputs.NEW_COMMITS == 'true' )
167+
)
21168
steps:
22-
# Uncomment to manually select latest Xcode if needed
23-
- name: Select Latest Xcode
24-
run: "sudo xcode-select --switch /Applications/Xcode_15.3.app/Contents/Developer"
169+
- name: Select Xcode version
170+
run: "sudo xcode-select --switch /Applications/Xcode_15.4.app/Contents/Developer"
171+
172+
- name: Checkout Repo for syncing
173+
if: |
174+
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
175+
vars.SCHEDULED_SYNC != 'false'
176+
uses: actions/checkout@v4
177+
with:
178+
token: ${{ secrets.GH_PAT }}
179+
ref: ${{ env.TARGET_BRANCH }}
180+
181+
- name: Sync upstream changes
182+
if: | # do not run the upstream sync action on the upstream repository
183+
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
184+
vars.SCHEDULED_SYNC != 'false' && github.repository_owner != 'LoopKit'
185+
id: sync
186+
uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1
187+
with:
188+
target_sync_branch: ${{ env.TARGET_BRANCH }}
189+
shallow_since: 6 months ago
190+
target_repo_token: ${{ secrets.GH_PAT }}
191+
upstream_sync_branch: ${{ env.UPSTREAM_BRANCH }}
192+
upstream_sync_repo: ${{ env.UPSTREAM_REPO }}
193+
194+
# Display a sample message based on the sync output var 'has_new_commits'
195+
- name: New commits found
196+
if: |
197+
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
198+
vars.SCHEDULED_SYNC != 'false' && steps.sync.outputs.has_new_commits == 'true'
199+
run: echo "New commits were found to sync."
200+
201+
- name: No new commits
202+
if: |
203+
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true' &&
204+
vars.SCHEDULED_SYNC != 'false' && steps.sync.outputs.has_new_commits == 'false'
205+
run: echo "There were no new commits."
206+
207+
- name: Show value of 'has_new_commits'
208+
if: |
209+
needs.check_alive_and_permissions.outputs.WORKFLOW_PERMISSION == 'true'
210+
&& vars.SCHEDULED_SYNC != 'false'
211+
run: |
212+
echo ${{ steps.sync.outputs.has_new_commits }}
213+
echo "NEW_COMMITS=${{ steps.sync.outputs.has_new_commits }}" >> $GITHUB_OUTPUT
25214
26-
# Checks-out the repo
27-
- name: Checkout Repo
215+
- name: Checkout Repo for building
28216
uses: actions/checkout@v4
29217
with:
218+
token: ${{ secrets.GH_PAT }}
30219
submodules: recursive
31-
220+
ref: ${{ env.TARGET_BRANCH }}
221+
222+
# Customize Loop: Download and apply patches
223+
- name: Customize Loop
224+
run: |
225+
226+
# LoopWorkspace patches
227+
# -applies any patches located in the LoopWorkspace/patches/ directory
228+
if $(ls ./patches/* &> /dev/null); then
229+
git apply ./patches/* --allow-empty -v --whitespace=fix
230+
fi
231+
232+
# Submodule Loop patches:
233+
# Template for customizing submodule Loop (changes Loop app name to "CustomLoop")
234+
# Remove the "#" sign from the beginning of the line below to activate:
235+
#curl https://github.com/loopnlearn/Loop/commit/d206432b024279ef710df462b20bd464cd9682d4.patch | git apply --directory=Loop -v --whitespace=fix
236+
237+
# Submodule LoopKit patches:
238+
# General template for customizing submodule LoopKit
239+
# Copy url from a GitHub commit or pull request and insert below, and remove the "#" sign from the beginning of the line to activate:
240+
#curl url_to_github_commit.patch | git apply --directory=LoopKit -v --whitespace=fix
241+
242+
# Submodule xxxxx patches:
243+
244+
# Add patches for customization of additional submodules by following the templates above,
245+
# and make sure to specify the submodule by setting "--directory=(submodule_name)".
246+
# Several patches may be added per submodule.
247+
# Adding comments (#) may be useful to easily tell the individual patches apart.
248+
249+
32250
# Patch Fastlane Match to not print tables
33251
- name: Patch Match Tables
34252
run: find /usr/local/lib/ruby/gems -name table_printer.rb | xargs sed -i "" "/puts(Terminal::Table.new(params))/d"
35253

254+
# Install project dependencies
255+
- name: Install Project Dependencies
256+
run: bundle install
257+
36258
# Sync the GitHub runner clock with the Windows time server (workaround as suggested in https://github.com/actions/runner/issues/2996)
37259
- name: Sync clock
38260
run: sudo sntp -sS time.windows.com
39261

40262
# Build signed Loop IPA file
41263
- name: Fastlane Build & Archive
42-
run: fastlane build_loop
264+
run: bundle exec fastlane build_loop
43265
env:
44266
TEAMID: ${{ secrets.TEAMID }}
45267
GH_PAT: ${{ secrets.GH_PAT }}
@@ -50,7 +272,7 @@ jobs:
50272

51273
# Upload to TestFlight
52274
- name: Fastlane upload to TestFlight
53-
run: fastlane release
275+
run: bundle exec fastlane release
54276
env:
55277
TEAMID: ${{ secrets.TEAMID }}
56278
GH_PAT: ${{ secrets.GH_PAT }}
@@ -59,8 +281,9 @@ jobs:
59281
FASTLANE_KEY: ${{ secrets.FASTLANE_KEY }}
60282
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
61283

62-
# Upload IPA and Symbols
63-
- name: Upload IPA and Symbol artifacts
284+
# Upload Build artifacts
285+
- name: Upload build log, IPA and Symbol artifacts
286+
if: always()
64287
uses: actions/upload-artifact@v4
65288
with:
66289
name: build-artifacts

0 commit comments

Comments
 (0)