Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.2.3 #462

Merged
merged 21 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e98a712
Merge pull request #435 from nightscout/release/0.2.2
Sjoerd-Bo3 Oct 19, 2024
dba0ff3
✏️ Fix broken link in README
ebouchut Nov 16, 2024
9accac9
✏️ Fix broken link in Documentation section
ebouchut Nov 17, 2024
b322c6a
update OmniXXX submodules: improvements, bug-fix Eros
marionbarker Dec 10, 2024
f06675b
Automate handling of Distribution certificates and profiles
bjornoleh Jan 14, 2025
80e0bd2
update OmniXXX submodules: improved unacknowledged command recovery
marionbarker Jan 16, 2025
005339f
validate_secrets.yml: Continue on errors in fastlane validate_secrets
bjornoleh Jan 18, 2025
786743e
Update OmniXXX: prevent 0x31 (049) fault
marionbarker Jan 18, 2025
b6fe250
Merge pull request #442 from ebouchut-aps/fix/broken_link_in_README
bjornoleh Jan 26, 2025
f057386
feat(issue templates): adding bug/feat type instead of tag
Sjoerd-Bo3 Jan 20, 2025
cb47fd7
feat(issue templates): adding bug/feat type instead of tag
Sjoerd-Bo3 Jan 20, 2025
b0a1974
Merge pull request #445 from nightscout/update_omnixxx_submodules_trio
Sjoerd-Bo3 Jan 26, 2025
cc43497
Update testflight.md for automated Distribution certificate renewal
marionbarker Jan 16, 2025
282a5c5
Merge pull request #453 from bjornoleh/certs_trio
Sjoerd-Bo3 Jan 26, 2025
a2cf40b
Merge branch 'issue-template-updates' of https://github.com/Sjoerd-Bo…
Sjoerd-Bo3 Jan 26, 2025
7c4d05b
fix(issuetemplates): need to be in brackets
Sjoerd-Bo3 Jan 26, 2025
bbbe7db
fix(issuetemplates): need to be in double qoutes
Sjoerd-Bo3 Jan 26, 2025
cf27d20
Merge pull request #461 from Sjoerd-Bo3/issueupdates
Sjoerd-Bo3 Jan 26, 2025
25544a5
chore: bump version v0.2.3
Sjoerd-Bo3 Jan 26, 2025
55b74c9
update SHA to match trio branch, no change to code
marionbarker Jan 26, 2025
9035ee4
Merge pull request #464 from nightscout/update_omnixxx_sha
Sjoerd-Bo3 Jan 26, 2025
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
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: "\U0001F41B Bug report"
about: Create a report to help us fix things
title: ''
labels: ['bug', 'needs-triage']
labels: ['needs-triage']
type: "bug"
assignees: ''
projects: ['nightscout/2']

Expand Down
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: "\U0001F4A1 Feature request \U0001F4A1"
about: Suggest an idea for this project
title: ''
labels: ['enhancement', 'needs-triage']
labels: ['needs-triage']
types: "feature"
assignees: ''
projects: ['nightscout/2']

Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/build_trio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ env:
ALIVE_BRANCH_DEV: alive-dev

jobs:
validate:
name: Validate
uses: ./.github/workflows/validate_secrets.yml
secrets: inherit
# Checks if Distribution certificate is present and valid, optionally nukes and
# creates new certs if the repository variable ENABLE_NUKE_CERTS == 'true'
check_certs:
name: Check certificates
uses: ./.github/workflows/create_certs.yml
secrets: inherit

# Checks if GH_PAT holds workflow permissions
# Checks for existence of alive branch; if non-existent creates it
check_alive_and_permissions:
needs: validate
needs: check_certs
runs-on: ubuntu-latest
name: Check alive branch and permissions
permissions:
Expand Down Expand Up @@ -96,7 +98,7 @@ jobs:
# Checks for changes in upstream repository; if changes exist prompts sync for build
# Performs keepalive to avoid stale fork
check_latest_from_upstream:
needs: [validate, check_alive_and_permissions]
needs: [check_certs, check_alive_and_permissions]
runs-on: ubuntu-latest
name: Check upstream and keep alive
outputs:
Expand Down Expand Up @@ -185,7 +187,7 @@ jobs:
# Builds Trio
build:
name: Build
needs: [validate, check_alive_and_permissions, check_latest_from_upstream]
needs: [check_certs, check_alive_and_permissions, check_latest_from_upstream]
runs-on: macos-14
permissions:
contents: write
Expand Down
109 changes: 90 additions & 19 deletions .github/workflows/create_certs.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
name: 3. Create Certificates
run-name: Create Certificates (${{ github.ref_name }})
on:
workflow_dispatch:

on: [workflow_call, workflow_dispatch]

env:
TEAMID: ${{ secrets.TEAMID }}
GH_PAT: ${{ secrets.GH_PAT }}
GH_TOKEN: ${{ secrets.GH_PAT }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
FASTLANE_KEY_ID: ${{ secrets.FASTLANE_KEY_ID }}
FASTLANE_ISSUER_ID: ${{ secrets.FASTLANE_ISSUER_ID }}
FASTLANE_KEY: ${{ secrets.FASTLANE_KEY }}

jobs:
validate:
name: Validate
uses: ./.github/workflows/validate_secrets.yml
secrets: inherit
certificates:
name: Create Certificates

create_certs:
name: Certificates
needs: validate
runs-on: macos-14
outputs:
new_certificate_needed: ${{ steps.set_output.outputs.new_certificate_needed }}

steps:
# Uncomment to manually select latest Xcode if needed
#- name: Select Latest Xcode
Expand All @@ -37,17 +49,76 @@ jobs:
- name: Install Project Dependencies
run: bundle install

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

# Create or update certificates for app
- name: Create Certificates
run: bundle exec fastlane certs
env:
TEAMID: ${{ secrets.TEAMID }}
GH_PAT: ${{ secrets.GH_PAT }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
FASTLANE_KEY_ID: ${{ secrets.FASTLANE_KEY_ID }}
FASTLANE_ISSUER_ID: ${{ secrets.FASTLANE_ISSUER_ID }}
FASTLANE_KEY: ${{ secrets.FASTLANE_KEY }}
# Create or update Distribution certificate and provisioning profiles
- name: Check and create or update Distribution certificate and profiles if needed
run: |
echo "Running Fastlane certs lane..."
bundle exec fastlane certs || true # ignore and continue on errors without annotating an exit code

- name: Check Distribution certificate and launch Nuke certificates if needed
run: bundle exec fastlane check_and_renew_certificates
id: check_certs

- name: Set output and annotations based on Fastlane result
id: set_output
run: |
CERT_STATUS_FILE="${{ github.workspace }}/fastlane/new_certificate_needed.txt"
ENABLE_NUKE_CERTS=${{ vars.ENABLE_NUKE_CERTS }}

if [ -f "$CERT_STATUS_FILE" ]; then
CERT_STATUS=$(cat "$CERT_STATUS_FILE" | tr -d '\n' | tr -d '\r') # Read file content and strip newlines
echo "new_certificate_needed: $CERT_STATUS"
echo "new_certificate_needed=$CERT_STATUS" >> $GITHUB_OUTPUT
else
echo "Certificate status file not found. Defaulting to false."
echo "new_certificate_needed=false" >> $GITHUB_OUTPUT
fi

# Check if ENABLE_NUKE_CERTS is not set to true when certs are valid
if [ "$CERT_STATUS" != "true" ] && [ "$ENABLE_NUKE_CERTS" != "true" ]; then
echo "::notice::🔔 Automated renewal of certificates is disabled because the repository variable ENABLE_NUKE_CERTS is not set to 'true'."
fi

# Check if ENABLE_NUKE_CERTS is not set to true when certs are not valid
if [ "$CERT_STATUS" = "true" ] && [ "$ENABLE_NUKE_CERTS" != "true" ]; then
echo "::error::❌ No valid distribution certificate found. Automated renewal of certificates was skipped because the repository variable ENABLE_NUKE_CERTS is not set to 'true'."
exit 1
fi

# Check if vars.FORCE_NUKE_CERTS is not set to true
if [ vars.FORCE_NUKE_CERTS = "true" ]; then
echo "::warning::‼️ Nuking of certificates was forced because the repository variable FORCE_NUKE_CERTS is set to 'true'."
fi

# Nuke Certs if needed, and if the repository variable ENABLE_NUKE_CERTS is set to 'true', or if FORCE_NUKE_CERTS is set to 'true', which will always force certs to be nuked
nuke_certs:
name: Nuke certificates
needs: [validate, create_certs]
runs-on: macos-14
if: ${{ (needs.create_certs.outputs.new_certificate_needed == 'true' && vars.ENABLE_NUKE_CERTS == 'true') || vars.FORCE_NUKE_CERTS == 'true' }}
steps:
- name: Output from step id 'check_certs'
run: echo "new_certificate_needed=${{ needs.create_certs.outputs.new_certificate_needed }}"

- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: bundle install

- name: Run Fastlane nuke_certs
run: |
set -e # Set error immediately after this step if error occurs
bundle exec fastlane nuke_certs

- name: Recreate Distribution certificate after nuking
run: |
set -e # Set error immediately after this step if error occurs
bundle exec fastlane certs

- name: Add success annotations for nuke and certificate recreation
if: ${{ success() }}
run: |
echo "::warning::⚠️ All Distribution certificates and TestFlight profiles have been revoked and recreated."
echo "::warning::❗️ If you have other apps being distributed by GitHub Actions / Fastlane / TestFlight that does not renew certificates automatically, please run the '3. Create Certificates' workflow for each of these apps to allow these apps to be built."
echo "::warning::✅ But don't worry about your existing TestFlight builds, they will keep working!"
9 changes: 4 additions & 5 deletions .github/workflows/validate_secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,15 @@ jobs:
elif ! echo "$FASTLANE_KEY" | openssl pkcs8 -nocrypt >/dev/null; then
failed=true
echo "::error::The FASTLANE_KEY secret is set but invalid. Verify that you copied it correctly from the API Key file (*.p8) you downloaded and try again."
elif ! bundle exec fastlane validate_secrets 2>&1 | tee fastlane.log; then
elif ! (bundle exec fastlane validate_secrets 2>&1 || true) | tee fastlane.log; then # ignore "fastlane validate_secrets" errors and continue on errors without annotating an exit code
if grep -q "bad decrypt" fastlane.log; then
failed=true
echo "::error::Unable to decrypt the Match-Secrets repository using the MATCH_PASSWORD secret. Verify that it is set correctly and try again."
elif grep -q -e "required agreement" -e "license agreement" fastlane.log; then
failed=true
echo "::error::Unable to create a valid authorization token for the App Store Connect API. Verify that the latest developer program license agreement has been accepted at https://developer.apple.com/account (review and accept any updated agreement), then wait a few minutes for changes to propagate and try again."
elif ! grep -q -e "No code signing identity found" -e "Could not install WWDR certificate" fastlane.log; then
failed=true
echo "::error::Unable to create a valid authorization token for the App Store Connect API. Verify that the FASTLANE_ISSUER_ID, FASTLANE_KEY_ID, and FASTLANE_KEY secrets are set correctly and try again."
echo "::error::❗️ Verify that the latest developer program license agreement has been accepted at https://developer.apple.com/account (review and accept any updated agreement), then wait a few minutes for changes to take effect and try again."
elif grep -q "Your certificate .* is not valid" fastlane.log; then
echo "::notice::Your Distribution certificate is invalid or expired. Automated renewal of the certificate will be attempted."
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion Config.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
APP_DISPLAY_NAME = Trio
APP_VERSION = 0.2.2
APP_VERSION = 0.2.3
APP_BUILD_NUMBER = 1
COPYRIGHT_NOTICE =
DEVELOPER_TEAM = ##TEAM_ID##
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You can either use the Build Script or you can run each command manually.

### Build Script:

If you copy, paste, and run the following script in Terminal, it will guide you through downloading and installing Trio. More information about the script can be found [here](https://docs.diy-trio.org/en/latest/operate/build.html#build-trio-with-script).
If you copy, paste, and run the following script in Terminal, it will guide you through downloading and installing Trio. More information about the script can be found [here](https://docs.diy-trio.org/operate/build/#build-trio-with-script).

```
/bin/bash -c "$(curl -fsSL \
Expand Down Expand Up @@ -65,7 +65,7 @@ Instructions in greater detail, but not Trio-specific:

[Discord Trio - Server ](http://discord.diy-trio.org)

[Trio documentation](https://docs.diy-trio.org/en/latest/)
[Trio documentation](https://docs.diy-trio.org/)

TODO: Add link: Trio Website (under development, not existing yet)

Expand Down
57 changes: 55 additions & 2 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ platform :ios do

match(
type: "appstore",
force: true,
force: false,
verbose: true,
git_basic_authorization: Base64.strict_encode64("#{GITHUB_REPOSITORY_OWNER}:#{GH_PAT}"),
app_identifier: [
"#{BUNDLE_ID}",
Expand Down Expand Up @@ -271,4 +272,56 @@ platform :ios do
git_basic_authorization: Base64.strict_encode64("#{GITHUB_REPOSITORY_OWNER}:#{GH_PAT}")
)
end
end

desc "Check Certificates and Trigger Workflow for Expired or Missing Certificates"
lane :check_and_renew_certificates do
setup_ci if ENV['CI']
ENV["MATCH_READONLY"] = false.to_s

# Authenticate using App Store Connect API Key
api_key = app_store_connect_api_key(
key_id: ENV["FASTLANE_KEY_ID"],
issuer_id: ENV["FASTLANE_ISSUER_ID"],
key_content: ENV["FASTLANE_KEY"] # Ensure valid key content
)

# Initialize flag to track if renewal of certificates is needed
new_certificate_needed = false

# Fetch all certificates
certificates = Spaceship::ConnectAPI::Certificate.all

# Filter for Distribution Certificates
distribution_certs = certificates.select { |cert| cert.certificate_type == "DISTRIBUTION" }

# Handle case where no distribution certificates are found
if distribution_certs.empty?
puts "No Distribution certificates found! Triggering action to create certificate."
new_certificate_needed = true
else
# Check for expiration
distribution_certs.each do |cert|
expiration_date = Time.parse(cert.expiration_date)

puts "Current Distribution Certificate: #{cert.id}, Expiration date: #{expiration_date}"

if expiration_date < Time.now
puts "Distribution Certificate #{cert.id} is expired! Triggering action to renew certificate."
new_certificate_needed = true
else
puts "Distribution certificate #{cert.id} is valid. No action required."
end
end
end

# Write result to new_certificate_needed.txt
file_path = File.expand_path('new_certificate_needed.txt')
File.write(file_path, new_certificate_needed ? 'true' : 'false')

# Log the absolute path and contents of the new_certificate_needed.txt file
puts ""
puts "Absolute path of new_certificate_needed.txt: #{file_path}"
new_certificate_needed_content = File.read(file_path)
puts "Certificate creation or renewal needed: #{new_certificate_needed_content}"
end
end
Loading