From 72cabf75b599d9f37b47a8df2ba173640f98d9cf Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Wed, 25 Oct 2023 11:48:40 -0400 Subject: [PATCH 01/16] WIP --- .../workflows/github-actions-build-number.yml | 42 +++++++++++++++++++ Jenkinsfile | 10 ++--- Tools/setup-story-details.sh | 2 +- 3 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/github-actions-build-number.yml diff --git a/.github/workflows/github-actions-build-number.yml b/.github/workflows/github-actions-build-number.yml new file mode 100644 index 000000000..2e38ce32a --- /dev/null +++ b/.github/workflows/github-actions-build-number.yml @@ -0,0 +1,42 @@ +name: Update Build Number +run-name: ${{ github.actor }} is updating the build version 🛠️ +on: + pull_request: + types: [ labeled ] +jobs: + Update-Build-Number: + if: github.event.label.name == 'Ready for Testing' + runs-on: ubuntu-latest + # defaults: + # run: + # working-directory: ./PlaybookSwift + env: + # Set an environment variable for the branch name + BRANCH_NAME: ${{ github.head_ref }} + steps: + - uses: actions/setup-node@v3 + with: + node-version: 20 + - name: Set Git Config + run: | + git config --local user.name "${{ github.actor }}" + git config --local user.email "${{ github.actor }}@users.noreply.github.com" + - name: Get Build Number + run: | + git clone --depth 5 git@github.com:powerhome/nitro-buildnumber.git . + echo $(ls nitro-buildnumber) + "666" >> ./buildNumber.txt + echo $(cat ./buildNumber.txt) + # - name: Leave PR comment + # env: + # PR_NUMBER: ${{ github.event.pull_request.number }} + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # RUBY_GEM_VERSION: ${{ env.new_ruby_alpha_version }} + # RUBY_GEM_LINK: https://rubygems.org/gems/playbook_ui/versions/${{env.new_ruby_alpha_version}} + # NPM_VERSION: ${{ env.new_npm_alpha_version }} + # NPM_LINK: https://www.npmjs.com/package/playbook-ui/v/${{env.new_npm_alpha_version}} + # run: | + # curl -H "Authorization: token ${GITHUB_TOKEN}" \ + # -X POST \ + # -d '{"body": "🎉 Congratulations on creating an Alpha Version! \n\n Your Alpha for Ruby Gems is [${{env.RUBY_GEM_VERSION}}](${{env.RUBY_GEM_LINK}}) \n\n Your Alpha for NPM is [${{env.NPM_VERSION}}](${{env.NPM_LINK}}) "}' \ + # "https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" diff --git a/Jenkinsfile b/Jenkinsfile index c46362890..16e17c1e1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,13 +16,8 @@ def steps = [ runNode { getReleaseNotes() def args = "type:${buildType()}" - // prepareToBuild(buildType()) buildAndShipiOS(args) } - // }, 'macOS': { - // runNode { - // buildAndShipMacOS(args) - // } } ] def map = steps @@ -332,8 +327,9 @@ def updateBuildNumber() { // clone repo dir('.buildnumber') { try { - sh 'git clone --depth 5 git@github.com:powerhome/nitro-buildnumber.git .' - buildNumber = sh(returnStdout: true, script: './increment PlaybookSwift-version').trim().toInteger() + // sh 'git clone --depth 5 git@github.com:powerhome/nitro-buildnumber.git .' + // buildNumber = sh(returnStdout: true, script: './increment PlaybookSwift-version').trim().toInteger() + buildNumber = 666 print "Build number: ${buildNumber}" } finally { diff --git a/Tools/setup-story-details.sh b/Tools/setup-story-details.sh index 686f135bd..f9820fe67 100755 --- a/Tools/setup-story-details.sh +++ b/Tools/setup-story-details.sh @@ -29,7 +29,7 @@ if [ -n "$GITHUB_PULL_REQUEST_ID" ]; then getPullRequestDetails "$GITHUB_PULL_REQUEST_ID" \ | tee "$PR_DETAILS" \ - | jq ". | {url, user, id, number, title, state, commits, mergeable}" + | jq ". | {commits, draft, id, mergeable, number, state, title, url, user}" export PR_USER_HANDLE=`jq -r .user.login "$PR_DETAILS"` else From d55b31864ace7f05899500456003b627b9d7b74d Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Wed, 25 Oct 2023 12:16:37 -0400 Subject: [PATCH 02/16] Temporarily disable Jenkins builds for this PR --- Jenkinsfile => _Jenkinsfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Jenkinsfile => _Jenkinsfile (100%) diff --git a/Jenkinsfile b/_Jenkinsfile similarity index 100% rename from Jenkinsfile rename to _Jenkinsfile From 08d14ccf5692890fa12e8483076c32926de70db4 Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Wed, 25 Oct 2023 12:19:09 -0400 Subject: [PATCH 03/16] WIP --- .github/workflows/github-actions-build-number.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-actions-build-number.yml b/.github/workflows/github-actions-build-number.yml index 2e38ce32a..7e819c2bd 100644 --- a/.github/workflows/github-actions-build-number.yml +++ b/.github/workflows/github-actions-build-number.yml @@ -19,10 +19,12 @@ jobs: node-version: 20 - name: Set Git Config run: | - git config --local user.name "${{ github.actor }}" - git config --local user.email "${{ github.actor }}@users.noreply.github.com" + git config --global user.name "${{ github.actor }}" + git config --global user.email "${{ github.actor }}@users.noreply.github.com" - name: Get Build Number run: | + echo $(git config user.name) + echo $(git config user.email) git clone --depth 5 git@github.com:powerhome/nitro-buildnumber.git . echo $(ls nitro-buildnumber) "666" >> ./buildNumber.txt From 5da900d57e4726c5af0e7db4063acc8ec6099b79 Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Wed, 25 Oct 2023 14:19:15 -0400 Subject: [PATCH 04/16] WIP --- _Jenkinsfile => Jenkinsfile | 10 ++++++---- .../PlaybookShowcase.xcodeproj/project.pbxproj | 6 ++++++ PlaybookShowcase/Versioning.xcconfig | 1 + fastlane/Fastfile | 3 ++- 4 files changed, 15 insertions(+), 5 deletions(-) rename _Jenkinsfile => Jenkinsfile (95%) create mode 100644 PlaybookShowcase/Versioning.xcconfig diff --git a/_Jenkinsfile b/Jenkinsfile similarity index 95% rename from _Jenkinsfile rename to Jenkinsfile index 16e17c1e1..0915d048b 100644 --- a/_Jenkinsfile +++ b/Jenkinsfile @@ -79,7 +79,10 @@ def runNodeWith(label, block, isShort) { stage('Checkout') { checkout scm } - + stage('Update Build Number') { + sh "echo \"CURRENT_PROJECT_VERSION = ${buildNumber}\" > ./PlaybookShowcase/Versioning.xcconfig" + sh "echo \$(cat ./PlaybookShowcase/Versioning.xcconfig)" + } if (isShort == false) { stage('Dependencies') { sh 'make dependencies' @@ -327,9 +330,8 @@ def updateBuildNumber() { // clone repo dir('.buildnumber') { try { - // sh 'git clone --depth 5 git@github.com:powerhome/nitro-buildnumber.git .' - // buildNumber = sh(returnStdout: true, script: './increment PlaybookSwift-version').trim().toInteger() - buildNumber = 666 + sh 'git clone --depth 5 git@github.com:powerhome/nitro-buildnumber.git .' + buildNumber = sh(returnStdout: true, script: './increment PlaybookSwift-version').trim().toInteger() print "Build number: ${buildNumber}" } finally { diff --git a/PlaybookShowcase/PlaybookShowcase.xcodeproj/project.pbxproj b/PlaybookShowcase/PlaybookShowcase.xcodeproj/project.pbxproj index ad1a59a9b..b48997fb8 100644 --- a/PlaybookShowcase/PlaybookShowcase.xcodeproj/project.pbxproj +++ b/PlaybookShowcase/PlaybookShowcase.xcodeproj/project.pbxproj @@ -8,6 +8,8 @@ /* Begin PBXBuildFile section */ 639039872A13A496004576FF /* ContentListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 639039862A13A496004576FF /* ContentListView.swift */; }; + 8F6D944E2AE98ED800AF0D15 /* Versioning.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 8F6D944D2AE98ED800AF0D15 /* Versioning.xcconfig */; }; + 8F6D944F2AE98ED800AF0D15 /* Versioning.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 8F6D944D2AE98ED800AF0D15 /* Versioning.xcconfig */; }; F905151B29F03B0700F9B66D /* PlaybookShowcaseApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = F905151A29F03B0700F9B66D /* PlaybookShowcaseApp.swift */; }; F905151F29F03B0700F9B66D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F905151E29F03B0700F9B66D /* Assets.xcassets */; }; F905152229F03B0700F9B66D /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F905152129F03B0700F9B66D /* Preview Assets.xcassets */; }; @@ -21,6 +23,7 @@ /* Begin PBXFileReference section */ 639039862A13A496004576FF /* ContentListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentListView.swift; sourceTree = ""; }; + 8F6D944D2AE98ED800AF0D15 /* Versioning.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Versioning.xcconfig; sourceTree = ""; }; F905151829F03B0700F9B66D /* PlaybookShowcase-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "PlaybookShowcase-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; F905151A29F03B0700F9B66D /* PlaybookShowcaseApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybookShowcaseApp.swift; sourceTree = ""; }; F905151E29F03B0700F9B66D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -82,6 +85,7 @@ F9370FC929EDCC0100FFD0DF = { isa = PBXGroup; children = ( + 8F6D944D2AE98ED800AF0D15 /* Versioning.xcconfig */, F937100029EDCC1900FFD0DF /* Packages */, F905151929F03B0700F9B66D /* PlaybookShowcase */, F905154729F03B3C00F9B66D /* PlaybookShowcase-macOS */, @@ -203,6 +207,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 8F6D944E2AE98ED800AF0D15 /* Versioning.xcconfig in Resources */, F905152229F03B0700F9B66D /* Preview Assets.xcassets in Resources */, F905151F29F03B0700F9B66D /* Assets.xcassets in Resources */, ); @@ -212,6 +217,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 8F6D944F2AE98ED800AF0D15 /* Versioning.xcconfig in Resources */, F943570A29F070F10051C650 /* Preview Assets.xcassets in Resources */, F943570929F070E90051C650 /* Assets.xcassets in Resources */, ); diff --git a/PlaybookShowcase/Versioning.xcconfig b/PlaybookShowcase/Versioning.xcconfig new file mode 100644 index 000000000..c07c20c8a --- /dev/null +++ b/PlaybookShowcase/Versioning.xcconfig @@ -0,0 +1 @@ +CURRENT_PROJECT_VERSION = 135.3 diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 19e614642..30c0a0496 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -51,7 +51,8 @@ lane :build_ios do |opts| output_name: "#{target_ios}.ipa", build_path: build_path, derived_data_path: derived_data_path, - xcargs: '-skipPackagePluginValidation' + xcargs: '-skipPackagePluginValidation', + xcconfig: './PlaybookShowcase/Versioning.xcconfig' ) end From 8e74903678438cd65bf626747e25be517b4306c0 Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Wed, 25 Oct 2023 16:03:07 -0400 Subject: [PATCH 05/16] Remove GH Actions --- .../workflows/github-actions-build-number.yml | 44 ------------------- 1 file changed, 44 deletions(-) delete mode 100644 .github/workflows/github-actions-build-number.yml diff --git a/.github/workflows/github-actions-build-number.yml b/.github/workflows/github-actions-build-number.yml deleted file mode 100644 index 7e819c2bd..000000000 --- a/.github/workflows/github-actions-build-number.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Update Build Number -run-name: ${{ github.actor }} is updating the build version 🛠️ -on: - pull_request: - types: [ labeled ] -jobs: - Update-Build-Number: - if: github.event.label.name == 'Ready for Testing' - runs-on: ubuntu-latest - # defaults: - # run: - # working-directory: ./PlaybookSwift - env: - # Set an environment variable for the branch name - BRANCH_NAME: ${{ github.head_ref }} - steps: - - uses: actions/setup-node@v3 - with: - node-version: 20 - - name: Set Git Config - run: | - git config --global user.name "${{ github.actor }}" - git config --global user.email "${{ github.actor }}@users.noreply.github.com" - - name: Get Build Number - run: | - echo $(git config user.name) - echo $(git config user.email) - git clone --depth 5 git@github.com:powerhome/nitro-buildnumber.git . - echo $(ls nitro-buildnumber) - "666" >> ./buildNumber.txt - echo $(cat ./buildNumber.txt) - # - name: Leave PR comment - # env: - # PR_NUMBER: ${{ github.event.pull_request.number }} - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # RUBY_GEM_VERSION: ${{ env.new_ruby_alpha_version }} - # RUBY_GEM_LINK: https://rubygems.org/gems/playbook_ui/versions/${{env.new_ruby_alpha_version}} - # NPM_VERSION: ${{ env.new_npm_alpha_version }} - # NPM_LINK: https://www.npmjs.com/package/playbook-ui/v/${{env.new_npm_alpha_version}} - # run: | - # curl -H "Authorization: token ${GITHUB_TOKEN}" \ - # -X POST \ - # -d '{"body": "🎉 Congratulations on creating an Alpha Version! \n\n Your Alpha for Ruby Gems is [${{env.RUBY_GEM_VERSION}}](${{env.RUBY_GEM_LINK}}) \n\n Your Alpha for NPM is [${{env.NPM_VERSION}}](${{env.NPM_LINK}}) "}' \ - # "https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" From bf2ad22e7388aa2500d6d74e376c7b832f36521b Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Thu, 26 Oct 2023 10:32:19 -0400 Subject: [PATCH 06/16] Generate better Runway comment link --- fastlane/Fastfile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 30c0a0496..c978110bc 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -21,6 +21,7 @@ target_ios = 'PlaybookShowcase-iOS' build_path = "BuildTemp/Archives" derived_data_path = "DerivedData" ios_plist = "./Info.plist" +appcenter_token = "bf0ae509c985f2a1102c2ad53894b35a5fa5383e" desc "Tag build" lane :tag_build do |opts| @@ -77,7 +78,7 @@ end desc "Ship iOS to App Center" lane :ship_ios_to_appcenter do |opts| - + app_name = "Playbook-Showcase-Beta" if opts[:type] == 'production' app_name = "Playbook-Showcase" @@ -85,7 +86,7 @@ lane :ship_ios_to_appcenter do |opts| opts[:os] = 'ios' appcenter_upload( - api_token: "bf0ae509c985f2a1102c2ad53894b35a5fa5383e", + api_token: appcenter_token, owner_name: "powerhome", owner_type: "organization", app_name: app_name, @@ -118,10 +119,18 @@ lane :create_runway_comment do |opts| merged_comment = "✅ MERGED ✅\n\n" end + # https://install.appcenter.ms/orgs/powerhome/apps/#{app_name}/releases/#{release_num} + # Generate the link above based on this call: + version_info = appcenter_fetch_version_number( + api_token: appcenter_token, + owner_name: "powerhome", + app_name: app_name + ) + comment = <<~HEREDOC

#{merged_comment}#{type} build #{build_number}

    -
  • PlaybookShowcase-iOS: iOS
  • +
  • PlaybookShowcase-iOS: iOS
HEREDOC From 2318599b41c9faa42b194e3ec8be12d3b12dca00 Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Thu, 26 Oct 2023 14:09:58 -0400 Subject: [PATCH 07/16] Prevent upload and RW comment if not ready for testing --- Jenkinsfile | 10 +++++++--- Tools/setup-story-details.sh | 4 +++- fastlane/Fastfile | 2 -- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0915d048b..e551d3d52 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -146,7 +146,9 @@ def writeRunwayComment() { echo "Bot PR detected. Skipping Runway comment." return true } - fastlane("create_runway_comment build_number:${buildNumber} type:${buildType()} runway_api_token:${RUNWAY_API_TOKEN} runway_backlog_item_id:${RUNWAY_BACKLOG_ITEM_ID} github_pull_request_id:${env.CHANGE_ID}") + if (env.PR_READY_FOR_TESTING) { + fastlane("create_runway_comment build_number:${buildNumber} type:${buildType()} runway_api_token:${RUNWAY_API_TOKEN} runway_backlog_item_id:${RUNWAY_BACKLOG_ITEM_ID} github_pull_request_id:${env.CHANGE_ID}") + } } def buildType() { @@ -266,8 +268,10 @@ def buildAndShipiOS(String fastlaneOpts) { fastlane("build_ios ${fastlaneOpts}") } checkForFailedParallelJob() - stage('Upload iOS') { - fastlane("upload_ios ${fastlaneOpts} release_notes:\"${releaseNotes}\" appcenter_token:${APPCENTER_API_TOKEN}") + if (env.PR_READY_FOR_TESTING) { + stage('Upload iOS') { + fastlane("upload_ios ${fastlaneOpts} release_notes:\"${releaseNotes}\" appcenter_token:${APPCENTER_API_TOKEN}") + } } } diff --git a/Tools/setup-story-details.sh b/Tools/setup-story-details.sh index f9820fe67..4b73b2814 100755 --- a/Tools/setup-story-details.sh +++ b/Tools/setup-story-details.sh @@ -29,7 +29,9 @@ if [ -n "$GITHUB_PULL_REQUEST_ID" ]; then getPullRequestDetails "$GITHUB_PULL_REQUEST_ID" \ | tee "$PR_DETAILS" \ - | jq ". | {commits, draft, id, mergeable, number, state, title, url, user}" + | jq ". | {commits, draft, id, labels, mergeable, number, state, title, url, user}" + + export PR_READY_FOR_TESTING=`jq -r '.labels | map(select(.name == "Ready for Testing"))| . != []'` export PR_USER_HANDLE=`jq -r .user.login "$PR_DETAILS"` else diff --git a/fastlane/Fastfile b/fastlane/Fastfile index c978110bc..4914f1ef2 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -119,8 +119,6 @@ lane :create_runway_comment do |opts| merged_comment = "✅ MERGED ✅\n\n" end - # https://install.appcenter.ms/orgs/powerhome/apps/#{app_name}/releases/#{release_num} - # Generate the link above based on this call: version_info = appcenter_fetch_version_number( api_token: appcenter_token, owner_name: "powerhome", From bb73019d2ed672cd786e884e4fe0658c46d5c09b Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Thu, 26 Oct 2023 15:13:31 -0400 Subject: [PATCH 08/16] WIP --- Jenkinsfile | 15 +++++++++++---- Tools/setup-story-details.sh | 4 +++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e551d3d52..3d4b84aaf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,6 +3,8 @@ success = true defaultNode = 'xcode-14' +readyForTesting = env.PR_READY_FOR_TESTING + stage('Build number') { node(defaultNode) { setupEnvironment { @@ -81,7 +83,6 @@ def runNodeWith(label, block, isShort) { } stage('Update Build Number') { sh "echo \"CURRENT_PROJECT_VERSION = ${buildNumber}\" > ./PlaybookShowcase/Versioning.xcconfig" - sh "echo \$(cat ./PlaybookShowcase/Versioning.xcconfig)" } if (isShort == false) { stage('Dependencies') { @@ -142,11 +143,17 @@ def getReleaseNotes() { } def writeRunwayComment() { - if (env.PR_USER_HANDLE in ['renovate[bot]', 'dependabot'] || "${RUNWAY_BACKLOG_ITEM_ID}" == env.FAKE_RUNWAY_STORY_ID) { + if (env.PR_USER_HANDLE in ['renovate[bot]', 'dependabot']) { echo "Bot PR detected. Skipping Runway comment." return true } - if (env.PR_READY_FOR_TESTING) { + if ("${RUNWAY_BACKLOG_ITEM_ID}" == env.FAKE_RUNWAY_STORY_ID) { + echo "No Runway story ID could be found in PR title!. Please add one in this format [PBIOS-XXX]" + return true + } + + echo "readyForTesting ${readyForTesting}" + if (readyForTesting) { fastlane("create_runway_comment build_number:${buildNumber} type:${buildType()} runway_api_token:${RUNWAY_API_TOKEN} runway_backlog_item_id:${RUNWAY_BACKLOG_ITEM_ID} github_pull_request_id:${env.CHANGE_ID}") } } @@ -268,7 +275,7 @@ def buildAndShipiOS(String fastlaneOpts) { fastlane("build_ios ${fastlaneOpts}") } checkForFailedParallelJob() - if (env.PR_READY_FOR_TESTING) { + if (readyForTesting) { stage('Upload iOS') { fastlane("upload_ios ${fastlaneOpts} release_notes:\"${releaseNotes}\" appcenter_token:${APPCENTER_API_TOKEN}") } diff --git a/Tools/setup-story-details.sh b/Tools/setup-story-details.sh index 4b73b2814..f57fd6b86 100755 --- a/Tools/setup-story-details.sh +++ b/Tools/setup-story-details.sh @@ -31,7 +31,9 @@ if [ -n "$GITHUB_PULL_REQUEST_ID" ]; then | tee "$PR_DETAILS" \ | jq ". | {commits, draft, id, labels, mergeable, number, state, title, url, user}" - export PR_READY_FOR_TESTING=`jq -r '.labels | map(select(.name == "Ready for Testing"))| . != []'` + export PR_READY_FOR_TESTING=`jq -r '.labels | map(select(.name == "Ready for Testing"))| . != []' "$PR_DETAILS"` + + echo "$PR_READY_FOR_TESTING" export PR_USER_HANDLE=`jq -r .user.login "$PR_DETAILS"` else From af543090b7331c30a909ce97160d93c5577a60f2 Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Fri, 27 Oct 2023 13:13:29 -0400 Subject: [PATCH 09/16] Rearrange vars --- Jenkinsfile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3d4b84aaf..804f33136 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,8 +3,6 @@ success = true defaultNode = 'xcode-14' -readyForTesting = env.PR_READY_FOR_TESTING - stage('Build number') { node(defaultNode) { setupEnvironment { @@ -18,6 +16,10 @@ def steps = [ runNode { getReleaseNotes() def args = "type:${buildType()}" + + RUNWAY_BACKLOG_ITEM_ID = sh(script: './Tools/setup-story-details.sh', returnStdout: true).trim().replaceAll (/\"/,/\\\"/).readLines().last() + PR_READY_FOR_TESTING = env.PR_READY_FOR_TESTING + buildAndShipiOS(args) } } @@ -130,7 +132,6 @@ def prepareToBuild(String buildType) { def getReleaseNotes() { stage('Release notes') { - RUNWAY_BACKLOG_ITEM_ID = sh(script: './Tools/setup-story-details.sh', returnStdout: true).trim().replaceAll (/\"/,/\\\"/).readLines().last() if (env.CHANGE_ID) { // CHANGE_ID is PR ID releaseNotes = sh(script: "jq -r .title './Build/pr-${env.CHANGE_ID}-details.json'", returnStdout:true).trim().replaceAll (/\"/,/\\\"/) @@ -152,8 +153,8 @@ def writeRunwayComment() { return true } - echo "readyForTesting ${readyForTesting}" - if (readyForTesting) { + echo "PR_READY_FOR_TESTING ${PR_READY_FOR_TESTING}" + if (PR_READY_FOR_TESTING) { fastlane("create_runway_comment build_number:${buildNumber} type:${buildType()} runway_api_token:${RUNWAY_API_TOKEN} runway_backlog_item_id:${RUNWAY_BACKLOG_ITEM_ID} github_pull_request_id:${env.CHANGE_ID}") } } @@ -275,7 +276,7 @@ def buildAndShipiOS(String fastlaneOpts) { fastlane("build_ios ${fastlaneOpts}") } checkForFailedParallelJob() - if (readyForTesting) { + if (PR_READY_FOR_TESTING) { stage('Upload iOS') { fastlane("upload_ios ${fastlaneOpts} release_notes:\"${releaseNotes}\" appcenter_token:${APPCENTER_API_TOKEN}") } From cb271ff166e7d9838214c638d9aabcd416b47285 Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Mon, 30 Oct 2023 09:48:09 -0400 Subject: [PATCH 10/16] Don't load setup-story-details.sh again in Jenkinsfile directly --- Jenkinsfile | 14 +++++++++----- Tools/setup-story-details.sh | 2 -- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 804f33136..22042d63e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,9 +17,6 @@ def steps = [ getReleaseNotes() def args = "type:${buildType()}" - RUNWAY_BACKLOG_ITEM_ID = sh(script: './Tools/setup-story-details.sh', returnStdout: true).trim().replaceAll (/\"/,/\\\"/).readLines().last() - PR_READY_FOR_TESTING = env.PR_READY_FOR_TESTING - buildAndShipiOS(args) } } @@ -144,6 +141,14 @@ def getReleaseNotes() { } def writeRunwayComment() { + RUNWAY_BACKLOG_ITEM_ID = env.RUNWAY_BACKLOG_ITEM_ID + echo "RUNWAY_BACKLOG_ITEM_ID ${RUNWAY_BACKLOG_ITEM_ID}" + + PR_READY_FOR_TESTING = false + echo "PR_READY_FOR_TESTING ${env.PR_READY_FOR_TESTING}" + + echo "PR_USER_HANDLE ${PR_USER_HANDLE}" + if (env.PR_USER_HANDLE in ['renovate[bot]', 'dependabot']) { echo "Bot PR detected. Skipping Runway comment." return true @@ -153,7 +158,6 @@ def writeRunwayComment() { return true } - echo "PR_READY_FOR_TESTING ${PR_READY_FOR_TESTING}" if (PR_READY_FOR_TESTING) { fastlane("create_runway_comment build_number:${buildNumber} type:${buildType()} runway_api_token:${RUNWAY_API_TOKEN} runway_backlog_item_id:${RUNWAY_BACKLOG_ITEM_ID} github_pull_request_id:${env.CHANGE_ID}") } @@ -276,7 +280,7 @@ def buildAndShipiOS(String fastlaneOpts) { fastlane("build_ios ${fastlaneOpts}") } checkForFailedParallelJob() - if (PR_READY_FOR_TESTING) { + if (env.PR_READY_FOR_TESTING) { stage('Upload iOS') { fastlane("upload_ios ${fastlaneOpts} release_notes:\"${releaseNotes}\" appcenter_token:${APPCENTER_API_TOKEN}") } diff --git a/Tools/setup-story-details.sh b/Tools/setup-story-details.sh index f57fd6b86..469189f29 100755 --- a/Tools/setup-story-details.sh +++ b/Tools/setup-story-details.sh @@ -84,5 +84,3 @@ else echo "Unable to parse Runway Backlog Item ID from commit message title" fi fi - -echo $RUNWAY_BACKLOG_ITEM_ID From bb6e75341f88566ae8615bd43902a3e44efb4622 Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Mon, 30 Oct 2023 13:19:45 -0400 Subject: [PATCH 11/16] =?UTF-8?q?=F0=9F=A6=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 22042d63e..b6db0a6c9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,6 +27,7 @@ parallel map waitUntil { success } +// This doesn't setup any of the Github/Runway data! runShortNode { stage('Runway Comment') { writeRunwayComment() @@ -63,6 +64,7 @@ def runShortNode(block) { } def checkForFailedParallelJob() { + echo "Checking for failed parallel job..." if (success == false) { throw new Exception('A parallel job has failed.') } @@ -142,12 +144,8 @@ def getReleaseNotes() { def writeRunwayComment() { RUNWAY_BACKLOG_ITEM_ID = env.RUNWAY_BACKLOG_ITEM_ID - echo "RUNWAY_BACKLOG_ITEM_ID ${RUNWAY_BACKLOG_ITEM_ID}" PR_READY_FOR_TESTING = false - echo "PR_READY_FOR_TESTING ${env.PR_READY_FOR_TESTING}" - - echo "PR_USER_HANDLE ${PR_USER_HANDLE}" if (env.PR_USER_HANDLE in ['renovate[bot]', 'dependabot']) { echo "Bot PR detected. Skipping Runway comment." From ed9c22844065ba8dbaa66a1698f676a1bcc87b3d Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Tue, 31 Oct 2023 10:15:55 -0400 Subject: [PATCH 12/16] =?UTF-8?q?Done=20=F0=9F=8E=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7d4429435..dec174e43 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -147,8 +147,9 @@ def getReleaseNotes() { def writeRunwayComment() { RUNWAY_BACKLOG_ITEM_ID = env.RUNWAY_BACKLOG_ITEM_ID - PR_READY_FOR_TESTING = env.PR_READY_FOR_TESTING - + // PR_READY_FOR_TESTING = env.PR_READY_FOR_TESTING + PR_READY_FOR_TESTING = true + echo "env.PR_READY_FOR_TESTING=${env.PR_READY_FOR_TESTING}" if (env.PR_USER_HANDLE in ['renovate[bot]', 'dependabot']) { @@ -282,10 +283,8 @@ def buildAndShipiOS(String fastlaneOpts) { fastlane("build_ios ${fastlaneOpts}") } checkForFailedParallelJob() - if (env.PR_READY_FOR_TESTING) { - stage('Upload iOS') { - fastlane("upload_ios ${fastlaneOpts} release_notes:\"${releaseNotes}\" appcenter_token:${APPCENTER_API_TOKEN}") - } + stage('Upload iOS') { + fastlane("upload_ios ${fastlaneOpts} release_notes:\"${releaseNotes}\" appcenter_token:${APPCENTER_API_TOKEN}") } } From 5b4f8552d1a9687de0fcc930678f2faac1f74d47 Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Tue, 31 Oct 2023 11:14:06 -0400 Subject: [PATCH 13/16] Stop looking for label --- Jenkinsfile | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index dec174e43..ae76ca54d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -97,8 +97,6 @@ def runNodeWith(label, block, isShort) { stage('Keychain') { setupKeychain() } - } else { - sh './.jenkins/jenkins-setup.sh setup' } checkForFailedParallelJob() block() @@ -133,6 +131,7 @@ def prepareToBuild(String buildType) { def getReleaseNotes() { stage('Release notes') { + RUNWAY_BACKLOG_ITEM_ID = sh(script: './Tools/setup-story-details.sh', returnStdout: true).trim().replaceAll (/\"/,/\\\"/).readLines().last() if (env.CHANGE_ID) { // CHANGE_ID is PR ID releaseNotes = sh(script: "jq -r .title './Build/pr-${env.CHANGE_ID}-details.json'", returnStdout:true).trim().replaceAll (/\"/,/\\\"/) @@ -145,25 +144,11 @@ def getReleaseNotes() { } def writeRunwayComment() { - RUNWAY_BACKLOG_ITEM_ID = env.RUNWAY_BACKLOG_ITEM_ID - - // PR_READY_FOR_TESTING = env.PR_READY_FOR_TESTING - PR_READY_FOR_TESTING = true - - echo "env.PR_READY_FOR_TESTING=${env.PR_READY_FOR_TESTING}" - - if (env.PR_USER_HANDLE in ['renovate[bot]', 'dependabot']) { + if (env.PR_USER_HANDLE in ['renovate[bot]', 'dependabot'] || "${RUNWAY_BACKLOG_ITEM_ID}" == env.FAKE_RUNWAY_STORY_ID) { echo "Bot PR detected. Skipping Runway comment." return true } - if ("${RUNWAY_BACKLOG_ITEM_ID}" == env.FAKE_RUNWAY_STORY_ID) { - echo "No Runway story ID could be found in PR title!. Please add one in this format [PBIOS-XXX]" - return true - } - - if (PR_READY_FOR_TESTING) { - fastlane("create_runway_comment build_number:${buildNumber} type:${buildType()} runway_api_token:${RUNWAY_API_TOKEN} runway_backlog_item_id:${RUNWAY_BACKLOG_ITEM_ID} github_pull_request_id:${env.CHANGE_ID}") - } + fastlane("create_runway_comment build_number:${buildNumber} type:${buildType()} runway_api_token:${RUNWAY_API_TOKEN} runway_backlog_item_id:${RUNWAY_BACKLOG_ITEM_ID} github_pull_request_id:${env.CHANGE_ID}") } def buildType() { From 4cc11b378e114fb282c1bfb7797ab81f67c8834a Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Tue, 31 Oct 2023 11:35:04 -0400 Subject: [PATCH 14/16] Fastfile --- fastlane/Fastfile | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index d5ee4cad8..38d063371 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -21,7 +21,6 @@ target_ios = 'PlaybookShowcase-iOS' build_path = "BuildTemp/Archives" derived_data_path = "DerivedData" ios_plist = "./Info.plist" -appcenter_token = "bf0ae509c985f2a1102c2ad53894b35a5fa5383e" desc "Set up build. build_number:1" lane :setup_before_build do |opts| @@ -42,8 +41,7 @@ lane :build_ios do |opts| output_name: "#{target_ios}.ipa", build_path: build_path, derived_data_path: derived_data_path, - xcargs: '-skipPackagePluginValidation', - xcconfig: './PlaybookShowcase/Versioning.xcconfig' + xcargs: '-skipPackagePluginValidation' ) end @@ -68,7 +66,7 @@ end desc "Ship iOS to App Center" lane :ship_ios_to_appcenter do |opts| - + app_name = "Playbook-Showcase-Beta" if opts[:type] == 'production' app_name = "Playbook-Showcase" @@ -76,7 +74,7 @@ lane :ship_ios_to_appcenter do |opts| opts[:os] = 'ios' appcenter_upload( - api_token: appcenter_token, + api_token: "bf0ae509c985f2a1102c2ad53894b35a5fa5383e", owner_name: "powerhome", owner_type: "organization", app_name: app_name, @@ -109,16 +107,10 @@ lane :create_runway_comment do |opts| merged_comment = "✅ MERGED ✅\n\n" end - version_info = appcenter_fetch_version_number( - api_token: appcenter_token, - owner_name: "powerhome", - app_name: app_name - ) - comment = <<~HEREDOC

#{merged_comment}#{type} build #{build_number}

    -
  • PlaybookShowcase-iOS: iOS
  • +
  • PlaybookShowcase-iOS: iOS
HEREDOC From 867822eebd8d2b1547d5465aece69714334f58b2 Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Tue, 31 Oct 2023 12:09:01 -0400 Subject: [PATCH 15/16] Fix bad merge --- fastlane/Fastfile | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 38d063371..59e97ed40 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -21,6 +21,17 @@ target_ios = 'PlaybookShowcase-iOS' build_path = "BuildTemp/Archives" derived_data_path = "DerivedData" ios_plist = "./Info.plist" +appcenter_token = "bf0ae509c985f2a1102c2ad53894b35a5fa5383e" + +desc "Tag build" +lane :tag_build do |opts| + begin + add_git_tag(tag: "builds/#{opts[:build]}") + push_git_tags(remote: "git@github.com:powerhome/PlaybookSwift.git") + rescue => ex + UI.error(ex) + end +end desc "Set up build. build_number:1" lane :setup_before_build do |opts| @@ -41,7 +52,8 @@ lane :build_ios do |opts| output_name: "#{target_ios}.ipa", build_path: build_path, derived_data_path: derived_data_path, - xcargs: '-skipPackagePluginValidation' + xcargs: '-skipPackagePluginValidation', + xcconfig: './PlaybookShowcase/Versioning.xcconfig' ) end @@ -66,7 +78,7 @@ end desc "Ship iOS to App Center" lane :ship_ios_to_appcenter do |opts| - + app_name = "Playbook-Showcase-Beta" if opts[:type] == 'production' app_name = "Playbook-Showcase" @@ -74,7 +86,7 @@ lane :ship_ios_to_appcenter do |opts| opts[:os] = 'ios' appcenter_upload( - api_token: "bf0ae509c985f2a1102c2ad53894b35a5fa5383e", + api_token: appcenter_token, owner_name: "powerhome", owner_type: "organization", app_name: app_name, @@ -107,10 +119,18 @@ lane :create_runway_comment do |opts| merged_comment = "✅ MERGED ✅\n\n" end + # https://install.appcenter.ms/orgs/powerhome/apps/#{app_name}/releases/#{release_num} + # Generate the link above based on this call: + version_info = appcenter_fetch_version_number( + api_token: appcenter_token, + owner_name: "powerhome", + app_name: app_name + ) + comment = <<~HEREDOC

#{merged_comment}#{type} build #{build_number}

    -
  • PlaybookShowcase-iOS: iOS
  • +
  • PlaybookShowcase-iOS: iOS
HEREDOC @@ -150,4 +170,4 @@ def keep_trying(ignore=[], interval=300, retry_counter=0, &block) end end nil -end +end \ No newline at end of file From 0cc6c63e355946cd07b1bd4df143a7505dc747f8 Mon Sep 17 00:00:00 2001 From: Stephen Marshall Date: Tue, 31 Oct 2023 13:00:50 -0400 Subject: [PATCH 16/16] =?UTF-8?q?We=20should=20set=20the=20entire=20CI=20b?= =?UTF-8?q?uild=20code=20on=20fire=20=F0=9F=94=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tools/setup-story-details.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tools/setup-story-details.sh b/Tools/setup-story-details.sh index 469189f29..f57fd6b86 100755 --- a/Tools/setup-story-details.sh +++ b/Tools/setup-story-details.sh @@ -84,3 +84,5 @@ else echo "Unable to parse Runway Backlog Item ID from commit message title" fi fi + +echo $RUNWAY_BACKLOG_ITEM_ID