From b2bb165501abcf0065187fb2ac6d51a5f449903e Mon Sep 17 00:00:00 2001 From: Kyriakos Sidiropoulos Date: Mon, 25 Mar 2024 16:43:17 +0100 Subject: [PATCH] refa (github-deploy.yml): fix the names of the secret-variables used to publish nugets and create new releases --- .github/workflows/github-compile.yml | 46 ++++++++++++++-------------- .github/workflows/github-deploy.yml | 34 ++++++++------------ Laerdal.SetupBuildEnvironment.sh | 42 +++++++++++++++++++------ azure-pipelines.yml | 7 +++-- 4 files changed, 73 insertions(+), 56 deletions(-) diff --git a/.github/workflows/github-compile.yml b/.github/workflows/github-compile.yml index 708e175a..920447a2 100644 --- a/.github/workflows/github-compile.yml +++ b/.github/workflows/github-compile.yml @@ -5,20 +5,18 @@ name: 'Builder' env: - Build_Repository_Folderpath: ${{ github.workspace }} + build_repository_folderpath: ${{ github.workspace }} on: workflow_call: # reusable workflows other workflows can trigger this workflow_dispatch: # allows to run this workflow manually from the actions tab -# currently disabled until we sort out billing issues in github -# -# push: -# branches: -# - '**' # '*' matches zero or more characters but does not match the `/` character '**' matches zero or more of any character -# - '!main' # main will trigger/reuse this workflow by other means via workflow call -# - '!master' # master will trigger/reuse this workflow by other means via workflow call -# - '!develop' # develop will trigger/reuse this workflow by other means via workflow call + push: + branches: + - '**' # '*' matches zero or more characters but does not match the `/` character '**' matches zero or more of any character + - '!main' # main will trigger/reuse this workflow by other means via workflow call + - '!master' # master will trigger/reuse this workflow by other means via workflow call + - '!develop' # develop will trigger/reuse this workflow by other means via workflow call jobs: @@ -30,7 +28,7 @@ jobs: # variable substitution is not supported in github at all so we cant do stuff like this # # env: - # Build_Artifacts_Folderpath: $Build_Repository_Folderpath/Artifacts + # Build_Artifacts_Folderpath: $build_repository_folderpath/Artifacts steps: @@ -40,30 +38,32 @@ jobs: fetch-depth: 1 - name: '🛠 Setup Build Environment' - run: ' chmod +x "$Build_Repository_Folderpath/Laerdal.SetupBuildEnvironment.sh" && "$Build_Repository_Folderpath/Laerdal.SetupBuildEnvironment.sh" ' - shell: bash + shell: 'bash' + run: | + chmod +x "$build_repository_folderpath/Laerdal.Scripts/Laerdal.SetupBuildEnvironment.sh" \ + && \ + "$build_repository_folderpath/Laerdal.Scripts/Laerdal.SetupBuildEnvironment.sh" \ + "https://nuget.pkg.github.com/Laerdal/index.json" \ + "${{ secrets.scl_github_nuget_feed_username }}" \ + "${{ secrets.scl_github_access_token }}" - name: '🏗 📦 Build, Pack & Announce New Release (if appropriate)' shell: bash - env: - Source_Branch_Fullpath: ${{ github.ref }} - Github_Repository_Path: ${{ github.repository }} - Components_Team_Github_Access_Token: ${{ secrets.components_team_github_access_token }} run: | - cd "$Build_Repository_Folderpath" \ - && \ + cd "$build_repository_folderpath" \ + && \ dotnet \ msbuild \ "Laerdal.McuMgr.Builder.targets" \ -m:1 \ -p:ShouldSkipMacCatalyst="false" \ \ - -p:PackageOutputPath="$Build_Repository_Folderpath/Artifacts" \ + -p:PackageOutputPath="$build_repository_folderpath/Artifacts" \ -p:Laerdal_Gradle_Path="/opt/homebrew/opt/gradle@7/bin/gradle" \ - -p:Laerdal_Source_Branch="$Source_Branch_Fullpath" \ - -p:Laerdal_Repository_Path="$Github_Repository_Path" \ - -p:Laerdal_Github_Access_Token="$Components_Team_Github_Access_Token" \ - -p:Laerdal_Test_Results_Folderpath="$Build_Repository_Folderpath/TestResults" + -p:Laerdal_Source_Branch="${{ github.ref }}" \ + -p:Laerdal_Repository_Path="${{ github.repository }}" \ + -p:Laerdal_Github_Access_Token="${{ secrets.scl_github_access_token }}" \ + -p:Laerdal_Test_Results_Folderpath="$build_repository_folderpath/TestResults" - name: '📡 Publish Test Results' # https://github.com/marketplace/actions/publish-test-results uses: EnricoMi/publish-unit-test-result-action/macos@v2 diff --git a/.github/workflows/github-deploy.yml b/.github/workflows/github-deploy.yml index ea4a97e8..c309dbc3 100644 --- a/.github/workflows/github-deploy.yml +++ b/.github/workflows/github-deploy.yml @@ -2,18 +2,12 @@ name: 'Deploy Nugets' on: -# currently disabled until we sort out billing issues in github -# -# push: -# branches: [ "main", "master", "develop", "ksidirop/MAN-296-migrate-to-github-actions" ] + push: + branches: [ "main", "master", "develop" ] workflow_dispatch: # allows to run this workflow manually from the Actions tab -env: - AZURE_ARTIFACTS_FEED_URL: 'https://pkgs.dev.azure.com/LaerdalMedical/_packaging/LaerdalNuGet/nuget/v3/index.json' - - jobs: compile: @@ -21,7 +15,7 @@ jobs: deploy: # inspired by https://stackoverflow.com/a/77663335/863651 - runs-on: macos-14 + runs-on: 'macos-14' needs: 'compile' @@ -33,23 +27,21 @@ jobs: name: 'nugets' path: 'Artifacts/' - # note for this to work we need to make the mcumgr repo public (open source) because as long as the repo is private it cannot have access to the secret variables - # todo remove this once we fully transition over to the laerdal nuget server on github - - name: '🚀 Publish to the Laerdal Private Nuget Server in Azure' # https://learn.microsoft.com/en-us/azure/devops/artifacts/quickstarts/github-actions?view=azure-devops + - name: '🚀 Publish to the Laerdal Nuget Server on Github' # https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry run: | - dotnet \ - nuget \ - push \ - --source "${{ env.SCL_AZURE_ARTIFACTS_FEED_URL }}" \ - --api-key "${{ secrets.SCL_AZURE_ARTIFACTS_API_KEY }}" \ + dotnet \ + nuget \ + push \ + --source "https://nuget.pkg.github.com/Laerdal-Medical/index.json" \ + --api-key "${{ secrets.scl_github_access_token }}" \ "Artifacts/**/*.nupkg" - # note for this to work we need to make the mcumgr repo public (open source) because as long as the repo is private it cannot have access to the secret variables - - name: '🚀 Publish to the Laerdal Nuget Server on Github' # https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry + # todo remove this once we fully transition over to the laerdal nuget server on github + - name: '🚀 Publish to the Laerdal Private Nuget Server in Azure' # https://learn.microsoft.com/en-us/azure/devops/artifacts/quickstarts/github-actions?view=azure-devops run: | dotnet \ nuget \ push \ - --source "${{ env.SCL_GITHUB_ARTIFACTS_FEED_URL }}" \ - --api-key "${{ secrets.SCL_GITHUB_ARTIFACTS_API_KEY }}" \ + --source "https://pkgs.dev.azure.com/LaerdalMedical/_packaging/LaerdalNuGet/nuget/v3/index.json" \ + --api-key "${{ secrets.scl_azure_artifacts_api_key }}" \ "Artifacts/**/*.nupkg" diff --git a/Laerdal.SetupBuildEnvironment.sh b/Laerdal.SetupBuildEnvironment.sh index 039852e8..29ee6e22 100755 --- a/Laerdal.SetupBuildEnvironment.sh +++ b/Laerdal.SetupBuildEnvironment.sh @@ -1,5 +1,24 @@ #!/bin/bash +declare -r NUGET_FEED_URL="$1" +declare -r NUGET_FEED_USERNAME="$2" +declare -r NUGET_FEED_ACCESSTOKEN="$3" + +if [ -z "${NUGET_FEED_URL}" ]; then + echo "##vso[task.logissue type=error]Missing 'NUGET_FEED_URL' which was expected to be parameter #1." + exit 3 +fi + +if [ -z "${NUGET_FEED_USERNAME}" ]; then + echo "##vso[task.logissue type=error]Missing 'NUGET_FEED_USERNAME' which was expected to be parameter #2." + exit 5 +fi + +if [ -z "${NUGET_FEED_ACCESSTOKEN}" ]; then + echo "##vso[task.logissue type=error]Missing 'NUGET_FEED_ACCESSTOKEN' which was expected to be parameter #3." + exit 6 +fi + brew install --cask objectivesharpie declare exitCode=$? if [ $exitCode != 0 ]; then @@ -198,13 +217,18 @@ if [ $exitCode != 0 ]; then echo "##vso[task.logissue type=error]Failed to add 'Artifacts' folder as a nuget source." exit 170 fi -dotnet nuget list source -#echo -#echo "** mtouch:" -#/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch --version -#declare exitCode=$? -#if [ $exitCode != 0 ]; then -# echo "##vso[task.logissue type=error]Failed to find 'mtouch'." -# exit 180 -#fi \ No newline at end of file +echo +echo "** Adding 'Laerdal Nuget Feed' as a Nuget Source:" # keep this after workload-restoration otherwise we will run into problems +dotnet nuget add \ + source "${NUGET_FEED_URL}" \ + --name "LaerdalMedical" \ + --username "${NUGET_FEED_USERNAME}" \ + --password "${NUGET_FEED_ACCESSTOKEN}" +declare exitCode=$? +if [ $exitCode != 0 ]; then + echo "##vso[task.logissue type=error]Failed to add 'Laerdal Nuget Feed' as a nuget source." + exit 180 +fi + +dotnet nuget list source diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5d70dcc4..71422e8d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -74,10 +74,11 @@ jobs: persistCredentials: True - task: Bash@3 - displayName: '🛠 Setup Build Environment' + displayName: 'Setup Build Environment for "Laerdal.Helpers"' inputs: - filePath: 'Laerdal.SetupBuildEnvironment.sh' - targetType: 'filePath' + targetType: filePath + filePath: 'Laerdal.Scripts/Laerdal.SetupBuildEnvironment.sh' + arguments: ' "https://pkgs.dev.azure.com/LaerdalMedical/_packaging/LaerdalNuGet/nuget/v3/index.json" "$(Laerdal.NugetFeed.Username)" "$(Laerdal.NugetFeed.AccessToken)" ' # notice that explicitly disabling parallelization via m:1 below is vital because if parallelization is enabled the ios and android # builds will fail with cryptic errors due to multiple target-frameworks are involved coupled with the custom build logic for native libs