Last active
June 22, 2023 15:57
-
-
Save githappens/3a925271fa1e7f29ff95432ead253c22 to your computer and use it in GitHub Desktop.
GitHub Action workflow for building and releasing an iOS app that uses Addressables and relies on the Cloud Content Delivery service.
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: Build and Release Go&Design (iOS) | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| build_type: | |
| description: 'Create Dev Build? (true/false)' | |
| required: true | |
| default: 'false' | |
| env: | |
| UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
| UCD_API_KEY: ${{ secrets.CDN_API_KEY }} | |
| GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
| GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} | |
| jobs: | |
| buildWithLinux: | |
| name: Build for iOS on version 2020.3.0f1 | |
| runs-on: ubuntu-latest | |
| env: | |
| UCD_TOOL_PATH: ${{ format('{0}/tools/ucd-cli-linux', github.workspace) }} | |
| ADDRESSABLES_CONTENT_BUILD_PATH: ${{ format('{0}/ServerData/iOS', github.workspace) }} | |
| steps: | |
| # Checkout | |
| - name: Checkout Repository | |
| uses: actions/[email protected] | |
| with: | |
| lfs: true | |
| - name: Cache Library | |
| uses: actions/[email protected] | |
| with: | |
| path: Library | |
| key: Library-iOS | |
| restore-keys: Library- | |
| - name: Free Disk Space | |
| run: | | |
| df -h | |
| sudo swapoff -a | |
| sudo rm -rf /swapfile /usr/share/dotnet /usr/local/share/boost $AGENT_TOOLSDIRECTORY /usr/local/lib/android /opt/ghc | |
| sudo apt clean | |
| docker rmi $(docker image ls -aq) | |
| df -h | |
| - name: Extract branch name | |
| shell: bash | |
| run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | |
| id: extract_branch | |
| - name: Build Unity Project | |
| uses: game-ci/unity-builder@v2 | |
| with: | |
| unityVersion: 2020.3.0f1 | |
| targetPlatform: iOS | |
| buildMethod: Ampersand.Editor.BuildGoAndDesign.Build # Addressable content build is triggered by the build method | |
| versioning: Semantic | |
| customParameters: -devBuild ${{ github.event.inputs.build_type }} -branch ${{ steps.extract_branch.outputs.branch }} -username ${{ secrets.UNITY_EMAIL }} -password ${{ secrets.UNITY_PASSWORD }} | |
| # Output (player) | |
| - name: Upload Build | |
| uses: actions/upload-artifact@v2 | |
| with: | |
| name: build-iOS | |
| path: build/iOS | |
| # Output (addressable content state) | |
| - name: Upload Addressable Content State data file | |
| uses: actions/upload-artifact@v2 | |
| with: | |
| name: addressables_content_state_iOS | |
| path: Assets/AddressableAssetsData/iOS | |
| - name: Import GPG Key used by the UCD CLI tool | |
| run: | | |
| echo -n "$GPG_PRIVATE_KEY" | base64 --decode | gpg --import | |
| echo -e "5\ny\n" | gpg --no-tty --command-fd 0 --edit-key "$GPG_KEY_ID" trust quit | |
| - name: Set the bucket ID's name | |
| run: | | |
| branch="${{ steps.extract_branch.outputs.branch }}" | |
| echo "UCD_BUCKET_ID_NAME=${branch^^}_IOS_BUCKET_ID" >> $GITHUB_ENV | |
| - name: Upload bundles to UCD & Create content release | |
| run: | | |
| echo "${{ env.UCD_BUCKET_ID_NAME }}" | |
| pass init "$GPG_KEY_ID" | |
| chmod +x $UCD_TOOL_PATH | |
| $UCD_TOOL_PATH auth login $UCD_API_KEY | |
| $UCD_TOOL_PATH config set bucket "${{ secrets[env.UCD_BUCKET_ID_NAME] }}" | |
| $UCD_TOOL_PATH entries sync "$ADDRESSABLES_CONTENT_BUILD_PATH" | |
| curl --user :$UCD_API_KEY -X POST "https://content-api.cloud.unity3d.com/api/v1/buckets/"${{ secrets[env.UCD_BUCKET_ID_NAME] }}"/releases/" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"notes\":\"automatically published from GitHub Actions\"}" | |
| releaseToTestFlight: | |
| name: Release to Test Flight | |
| runs-on: macos-latest | |
| needs: buildWithLinux | |
| env: | |
| APPLE_CONNECT_EMAIL: ${{ secrets.APPLE_CONNECT_EMAIL }} | |
| APPLE_DEVELOPER_EMAIL: ${{ secrets.APPLE_DEVELOPER_EMAIL }} | |
| APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
| APPLE_TEAM_NAME: ${{ secrets.APPLE_TEAM_NAME }} | |
| MATCH_URL: ${{ secrets.MATCH_REPO_URL }} | |
| GIT_TOKEN: ${{ secrets.MATCH_REPO_ACCESS_TOKEN }} | |
| MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} | |
| APPSTORE_KEY_ID: ${{ secrets.APPSTORE_KEY_ID }} | |
| APPSTORE_ISSUER_ID: ${{ secrets.APPSTORE_ISSUER_ID }} | |
| APPSTORE_P8: ${{ secrets. APPSTORE_P8 }} | |
| APPSTORE_P8_PATH: ${{ format('{0}/fastlane/p8.json', github.workspace) }} | |
| IOS_APP_ID: ${{ secrets.IOS_APP_ID }} | |
| IOS_BUILD_PATH: ${{ format('{0}/build/iOS', github.workspace) }} | |
| PROJECT_NAME: Go&Design | |
| RELEASE_NOTES: ${{ github.event.head_commit.message }} | |
| if: ${{ github.ref == 'refs/heads/develop' }} # beta builds should be started from the develop branch | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v2 | |
| - name: Download iOS Artifact | |
| uses: actions/download-artifact@v2 | |
| with: | |
| name: build-iOS | |
| path: build/iOS | |
| - name: Make App Store p8 and Fix File Permissions | |
| run: | | |
| echo "$APPSTORE_P8" > $APPSTORE_P8_PATH | |
| find $IOS_BUILD_PATH -type f -name "**.sh" -exec chmod +x {} \; | |
| find $IOS_BUILD_PATH -type f -iname "*usymtool" -exec chmod +x {} \; | |
| - name: Cache Fastlane Dependencies | |
| uses: actions/cache@v2 | |
| with: | |
| path: vendor/bundle | |
| key: ${{ runner.os }}-${{ hashFiles('**/Gemfile.lock') }} | |
| - name: Install Fastlane | |
| run: bundle install | |
| - name: Upload to TestFlight | |
| uses: maierj/[email protected] | |
| with: | |
| lane: 'ios beta' | |
| - name: Cleanup to avoid storage limit | |
| if: always() | |
| uses: geekyeggo/delete-artifact@v1 | |
| with: | |
| name: build-iOS | |
| releaseToAppStore: | |
| name: Release to the Apple App Store | |
| runs-on: macos-latest | |
| needs: buildWithLinux | |
| env: | |
| APPLE_CONNECT_EMAIL: ${{ secrets.APPLE_CONNECT_EMAIL }} | |
| APPLE_DEVELOPER_EMAIL: ${{ secrets.APPLE_DEVELOPER_EMAIL }} | |
| APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
| APPLE_TEAM_NAME: ${{ secrets.APPLE_TEAM_NAME }} | |
| MATCH_URL: ${{ secrets.MATCH_REPO_URL }} | |
| GIT_TOKEN: ${{ secrets.MATCH_REPO_ACCESS_TOKEN }} | |
| MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} | |
| APPSTORE_KEY_ID: ${{ secrets.APPSTORE_KEY_ID }} | |
| APPSTORE_ISSUER_ID: ${{ secrets.APPSTORE_ISSUER_ID }} | |
| APPSTORE_P8: ${{ secrets. APPSTORE_P8 }} | |
| APPSTORE_P8_PATH: ${{ format('{0}/fastlane/p8.json', github.workspace) }} | |
| IOS_APP_ID: ${{ secrets.IOS_APP_ID }} | |
| IOS_BUILD_PATH: ${{ format('{0}/build/iOS', github.workspace) }} | |
| PROJECT_NAME: Go&Design | |
| RELEASE_NOTES: ${{ github.event.head_commit.message }} | |
| if: ${{ github.ref == 'refs/heads/master' }} # production builds should be started from the master branch | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v2 | |
| - name: Download iOS Artifact | |
| uses: actions/download-artifact@v2 | |
| with: | |
| name: build-iOS | |
| path: build/iOS | |
| - name: Make App Store p8 and Fix File Permissions | |
| run: | | |
| echo "$APPSTORE_P8" > $APPSTORE_P8_PATH | |
| find $IOS_BUILD_PATH -type f -name "**.sh" -exec chmod +x {} \; | |
| find $IOS_BUILD_PATH -type f -iname "*usymtool" -exec chmod +x {} \; | |
| - name: Cache Fastlane Dependencies | |
| uses: actions/cache@v2 | |
| with: | |
| path: vendor/bundle | |
| key: ${{ runner.os }}-${{ hashFiles('**/Gemfile.lock') }} | |
| - name: Install Fastlane | |
| run: bundle install | |
| - name: Upload to TestFlight | |
| uses: maierj/[email protected] | |
| with: | |
| lane: 'ios release' | |
| - name: Cleanup to avoid storage limit | |
| if: always() | |
| uses: geekyeggo/delete-artifact@v1 | |
| with: | |
| name: build-iOS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment