diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 00000000..f9cb322d --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,85 @@ +name: Siksha-CD + +on: + push: + tags: + - testflight/v[0-9]+.[0-9]+.[0-9]+-*.[0-9]+ + - appstore/v[0-9]+.[0-9]+.[0-9]+-*.[0-9]+ + +jobs: + deploy: + name: Execute fastlane for testflight / appstore + + env: + MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} + SSH_KEY: ${{ secrets.SSH_KEY }} + APPSTORE_CONNECT_KEY_ID: ${{ secrets.APPSTORE_CONNECT_KEY_ID }} + APPSTORE_CONNECT_ISSUER_ID: ${{ secrets.APPSTORE_CONNECT_ISSUER_ID }} + APPSTORE_CONNECT_KEY_CONTENT: ${{ secrets.APPSTORE_CONNECT_KEY_CONTENT }} + PROFILE_NAME: ${{ secrets.PROFILE_NAME }} + TEAM_ID: ${{ secrets.TEAM_ID }} + SLACK_URL: ${{ secrets.SLACK_WEBHOOK }} + GIT_TAG_NAME: ${{ github.ref_name }} + BUNDLE_IDENTIFIER: ${{ secrets.BUNDLE_IDENTIFIER }} + BUNDLE_IDENTIFIER_DEV: ${{ secrets.BUNDLE_IDENTIFIER_DEV }} + XCODE_VERSION: "16.2" + + runs-on: macos-15 + + steps: + - name: Parse tag name + uses: actions-ecosystem/action-regex-match@v2 + id: regex + with: + text: ${{ github.ref_name }} + regex: '^(testflight|appstore)\/v(\d+)\.(\d+)\.(\d+)-(release|debug)\.(\d+)$' + + - if: ${{ steps.regex.outputs.group1 == 'appstore' && steps.regex.outputs.group5 == 'debug' }} + run: | + echo "you can't upload debug build to appstore!" + exit 1 + + - uses: actions/checkout@v3 + + - run: | + sudo xcode-select -s /Applications/Xcode_${XCODE_VERSION}.app/Contents/Developer + ls + + - name: Set version number and build number + run: | + echo "VERSION_NUMBER=${{ steps.regex.outputs.group2 }}.${{ steps.regex.outputs.group3 }}.${{ steps.regex.outputs.group4 }}" >> $GITHUB_ENV + echo "BUILD_NUMBER=${{ steps.regex.outputs.group6 }}" >> $GITHUB_ENV + + - name: Install Ruby Dependencies + run: | + bundle install + bundle update fastlane + + - name: Setup match repo ssh + uses: shimataro/ssh-key-action@v2 + with: + key: ${{ secrets.SSH_KEY }} + known_hosts: ${{ secrets.KNOWN_HOSTS }} + + + + - name: Inject secret file dependencies + env: + BUNDLE: ${{ secrets.BUNDLE }} + BUNDLE_DEV: ${{secrets.BUNDLE_DEV}} + CONFIG: ${{ secrets.CONFIG }} + GOOGLE_SERVICE_INFO: ${{ secrets.GOOGLE_SERVICE_INFO }} + GOOGLE_SERVICE_INFO_DEV: ${{ secrets.GOOGLE_SERVICE_INFO_DEV }} + run: | + mkdir "Siksha/Supporting Files" + echo "$BUNDLE" > "Siksha/Supporting Files/bundle.xcconfig" + echo "$BUNDLE_DEV" > "Siksha/Supporting Files/bundle-dev.xcconfig" + echo "$CONFIG" > "Siksha/Supporting Files/config.plist" + echo "$GOOGLE_SERVICE_INFO" > "Siksha/Supporting Files/GoogleService-Info.plist" + echo "$GOOGLE_SERVICE_INFO_DEV" > "Siksha/Supporting Files/GoogleService-Info-dev.plist" + + + - name: Upload prod app to TestFlight + if: ${{ steps.regex.outputs.group1 == 'testflight' && steps.regex.outputs.group5 == 'release' }} + run: | + bundle exec fastlane beta diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 381783f9..00f67a79 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -16,14 +16,43 @@ default_platform(:ios) platform :ios do - desc "Description of what the lane does" - lane :custom_lane do + desc "Upload app to testflight" + lane :beta do + ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "120" + setup_ci + app_store_connect_api_key( + key_id:ENV["APPSTORE_CONNECT_KEY_ID"], + issuer_id:ENV["APPSTORE_CONNECT_ISSUER_ID"], + key_content:ENV["APPSTORE_CONNECT_KEY_CONTENT"] + ) + + match( + type: "appstore", + app_identifier:ENV["BUNDLE_IDENTIFIER"], + readonly: true + ) + + update_code_signing_settings( + use_automatic_signing: false, + code_sign_identity: "Apple Distribution", + profile_name:ENV["PROFILE_NAME"], + path:"Siksha.xcodeproj", + bundle_identifier:ENV["BUNDLE_IDENTIFIER"], + targets:"Siksha-Release", + team_id:ENV["TEAM_ID"] + ) + build_app(project:"Siksha.xcodeproj",scheme:"Siksha-Release",configuration:"Release",clean:true, silent:true) + increment_build_number(build_number:ENV["BUILD_NUMBER"],xcodeproj:"Siksha.xcodeproj") + upload_to_testflight(app_version:ENV["VERSION_NUMBER"]) + slack(message:"uploaded to testflight") # add actions here: https://docs.fastlane.tools/actions end + + end lane :register_new_devices do register_devices( devices_file: "./devices.txt" ) -end \ No newline at end of file +end diff --git a/fastlane/README.md b/fastlane/README.md index 5749fd80..d465cd5f 100644 --- a/fastlane/README.md +++ b/fastlane/README.md @@ -21,6 +21,14 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do +### beta + +```sh +[bundle exec] fastlane beta +``` + + + ----