Skip to content

Commit

Permalink
Improve GitHub Actions & Add Firebase Project For the Setup Script (#65)
Browse files Browse the repository at this point in the history
# Improve GitHub Actions & Add Firebase Project For the Setup Script

## ⚙️ Release Notes 
- Improve GitHub Actions
- Add Firebase Project For the Setup Script


## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
PSchmiedmayer authored Jan 18, 2024
1 parent 5e89044 commit ab52a38
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 17 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/beta-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,25 @@ jobs:
name: Build and Test
uses: ./.github/workflows/build-and-test.yml
permissions:
security-events: write
actions: read
contents: read
secrets: inherit
iosapptestflightdeployment:
name: iOS App TestFlight Deployment
needs: buildandtest
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
secrets: inherit
permissions:
contents: read
with:
googleserviceinfoplistpath: 'TemplateApplication/Supporting Files/GoogleService-Info.plist'
setupsigning: true
fastlanelane: beta
secrets: inherit
deployfirebase:
name: Deploy Firebase Project
needs: iosapptestflightdeployment
uses: StanfordBDHG/.github/.github/workflows/firebase-deploy.yml@v2
permissions:
contents: read
with:
arguments: '--debug'
secrets:
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@ jobs:
reuse_action:
name: REUSE Compliance Check
uses: StanfordBDHG/.github/.github/workflows/reuse.yml@v2
permissions:
contents: read
swiftlint:
name: SwiftLint
uses: StanfordBDHG/.github/.github/workflows/swiftlint.yml@v2
permissions:
contents: read
markdownlinkcheck:
name: Markdown Link Check
uses: StanfordBDHG/.github/.github/workflows/markdown-link-check.yml@v2
permissions:
contents: read
buildandtest:
name: Build and Test
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
permissions:
contents: read
with:
artifactname: TemplateApplication.xcresult
runsonlabels: '["macOS", "self-hosted"]'
Expand All @@ -35,5 +43,9 @@ jobs:
name: Upload Coverage Report
needs: buildandtest
uses: StanfordBDHG/.github/.github/workflows/create-and-upload-coverage-report.yml@v2
permissions:
contents: read
with:
coveragereports: TemplateApplication.xcresult
secrets:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/documentation-deployment.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This source file is part of the Stanford Spezi open-source project
# This source file is part of the Stanford Spezi Template Application open-source project
#
# SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/monthly-markdown-link-check.yml.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This source file is part of the Stanford Spezi open-source project
# This source file is part of the Stanford Spezi Template Application open-source project
#
# SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand All @@ -17,3 +17,5 @@ jobs:
markdown_link_check:
name: Markdown Link Check
uses: StanfordBDHG/.github/.github/workflows/markdown-link-check.yml@v2
permissions:
contents: read
2 changes: 1 addition & 1 deletion Scripts/TEMPLATEREADME.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SPDX-License-Identifier: MIT
This repository contains the Spezi Template Application.
The Spezi Template Application is using the [Spezi](https://github.com/StanfordSpezi/Spezi) ecosystem and builds on top of the [{{SSTA}}](https://github.com/StanfordSpezi/Spezi{{TA}}).<!-- markdown-link-check-disable-line -->

> [!NOTE] 
> [!NOTE] 
> Do you want to learn more about the {{SSTA}} and how to use, extend, and modify this application? Check out the [{{SSTA}} documentation](https://stanfordspezi.github.io/Spezi{{TA}})<!-- markdown-link-check-disable-line -->

Expand Down
29 changes: 20 additions & 9 deletions Scripts/create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ error_exit_help() {

# Function to display help message
show_help() {
echo "Usage: $0 --name <appName> --bundleIdentifier <bundleId> [--provisioningProfile <procitationFile>]"
echo "Usage: $0 --name <appName> --bundleIdentifier <bundleIdentifier> [--provisioningProfile <provisioningProfileName>] [--firebaseProject <firebaseProjectId>]"
echo
echo "Options:"
echo " --name Name of the application. (required)"
echo " --bundleIdentifier The iOS bundle identifier of the application. (required)"
echo " --provisioningProfile The name of the iOS provisioning profile to build the application. (optional, defaults to the value of --name)"
echo " --firebaseProject The Firebase project identifier. (optional, defaults to the value of --name lowercased without spaces)"
echo " --help Display this help and exit."
}

Expand All @@ -53,6 +54,11 @@ while [[ $# -gt 0 ]]; do
shift # past argument
shift # past value
;;
--firebaseProject)
firebaseProject="$2"
shift # past argument
shift # past value
;;
--help)
show_help
exit 0
Expand All @@ -72,17 +78,21 @@ if [ -z "$bundleIdentifier" ]; then
error_exit_help "The --bundleIdentifier argument is required."
fi

# Set default value for provisioningProfile if not provided
if [ -z "$provisioningProfile" ]; then
provisioningProfile="$appName"
fi

# Remove spaces from appName
appNameNoSpaces="${appName// /}"

# Convert appName to lowercase and remove spaces
appNameLowerNoSpaces=$(echo "$appName" | tr '[:upper:]' '[:lower:]' | tr -d ' ')

# Set default value for provisioningProfile & firebaseProject if not provided
if [ -z "$provisioningProfile" ]; then
provisioningProfile="$appName"
fi

if [ -z "$firebaseProject" ]; then
firebaseProject="$appNameLowerNoSpaces"
fi

# Testing the input:
echo "Application Name: $appName"
echo "Bundle Identifier: $bundleIdentifier"
Expand All @@ -109,10 +119,10 @@ sed -i '' "s/${oldProvisioningProfileEscaped}/${provisioningProfileEscaped}/g" "
# Firebase project name:
firebaseProjectNameEscaped=$(sed 's:/:\\/:g' <<< "stanfordspezitemplateapp")
appNameLowerNoSpacesEscaped=$(sed 's:/:\\/:g' <<< "$appNameLowerNoSpaces")
firebaseProjectEscaped=$(sed 's:/:\\/:g' <<< "$firebaseProject")
sed -i '' "s/${firebaseProjectNameEscaped}/${appNameLowerNoSpacesEscaped}/g" ".firebaserc"
sed -i '' "s/${firebaseProjectNameEscaped}/${appNameLowerNoSpacesEscaped}/g" "./TemplateApplication/Supporting Files/GoogleService-Info.plist"
sed -i '' "s/${firebaseProjectNameEscaped}/${firebaseProjectEscaped}/g" ".firebaserc"
sed -i '' "s/${firebaseProjectNameEscaped}/${firebaseProjectEscaped}/g" "./TemplateApplication/Supporting Files/GoogleService-Info.plist"
# Rename project and code:
Expand All @@ -130,6 +140,7 @@ taFullEscaped=$(sed 's:/:\\/:g' <<< "TemplateApplication")
newHeaderFileEscaped=$(sed 's:/:\\/:g' <<< "$appName based on the $sstaEscaped")
appNameEscaped=$(sed 's:/:\\/:g' <<< "$appName")
appNameNoSpacesEscaped=$(sed 's:/:\\/:g' <<< "$appNameNoSpaces")
appNameLowerNoSpacesEscaped=$(sed 's:/:\\/:g' <<< "$firebaseProject")
find . -type f -not \( -path '*/.git/*' \) -not \( -path '*/Scripts/create.sh' \) -exec grep -Iq . {} \; -print | while read -r file; do
sed -i '' "s/${projectNameLowercaseEscaped}/${appNameLowerNoSpacesEscaped}/g" "$file" || echo "Failed to process $file"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ The Spezi Template application repository provides a convenient script to rename

The shell script can be called as follows:
```bash
$ sh Scripts/create.sh --name <appName> --bundleIdentifier <bundleId> [--provisioningProfile <procitationFile>]
$ sh Scripts/create.sh --name <appName> --bundleIdentifier <bundleIdentifier> [--provisioningProfile <provisioningProfileName>] [--firebaseProject <firebaseProjectId>]
```

Argument | Description
--- | ---
`--name` | Name of the application. (required)
`--bundleIdentifier` | The iOS bundle identifier of the application. (required)
`--provisioningProfile` | The name of the iOS provisioning profile to build the application. (optional, defaults to the value of --name).
`--provisioningProfile` | The name of the iOS provisioning profile to build the application. (optional, defaults to the value of --name)
`--firebaseProject` | The Firebase project identifier. (optional, defaults to the value of --name lowercased without spaces)
`--help` | Display help and exit.

The following example shows renaming the application to "My Spezi App":
Expand Down

0 comments on commit ab52a38

Please sign in to comment.