diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml new file mode 100644 index 00000000..3bda6731 --- /dev/null +++ b/.github/workflows/github-actions.yml @@ -0,0 +1,117 @@ +# +# https://docs.github.com/en/actions/migrating-to-github-actions/automated-migrations/migrating-from-azure-devops-with-github-actions-importer#environment-variable-mapping +# + +name: 'Build, Pack & Deploy Nugets' + +env: + BUILD_REPOSITORY_FOLDERPATH: ${{ github.workspace }} + + LAERDAL_SOURCE_BRANCH: ${{ github.ref }} + LAERDAL_REPOSITORY_PATH: ${{ github.repository }} + + SCL_GITHUB_ACCESS_TOKEN: ${{ secrets.SCL_GITHUB_ACCESS_TOKEN }} + SCL_AZURE_ARTIFACTS_API_KEY: ${{ secrets.SCL_AZURE_ARTIFACTS_API_KEY }} + SCL_GITHUB_NUGET_FEED_USERNAME: ${{ secrets.SCL_GITHUB_NUGET_FEED_USERNAME }} + + +on: + workflow_call: # so that other workflows can trigger this + workflow_dispatch: # allows to run this workflow manually from the actions tab + + push: + branches: + - '**' # '*' matches zero or more characters but does not match the `/` character '**' matches zero or more of any character + + +jobs: + + build: + + runs-on: 'macos-14' + + # variable substitution is not supported in github at all so we cant do stuff like this + # + # env: + # Build_Artifacts_Folderpath: ${{env.BUILD_REPOSITORY_FOLDERPATH}}/Artifacts + + steps: + + - name: '🔽 Checkout' + uses: 'actions/checkout@v3' + # with: + # fetch-depth: 1 + + - name: '🛠 Setup Build Environment' + shell: 'bash' + run: | + chmod +x "${{env.BUILD_REPOSITORY_FOLDERPATH}}/Laerdal.Scripts/Laerdal.SetupBuildEnvironment.sh" \ + && \ + "${{env.BUILD_REPOSITORY_FOLDERPATH}}/Laerdal.Scripts/Laerdal.SetupBuildEnvironment.sh" \ + "https://nuget.pkg.github.com/Laerdal/index.json" \ + "${{env.SCL_GITHUB_NUGET_FEED_USERNAME}}" \ + "${{env.SCL_GITHUB_ACCESS_TOKEN}}" \ + "${{env.BUILD_REPOSITORY_FOLDERPATH}}/Artifacts" + + - name: '🏗 📦 Build, Pack & Announce New Release (if appropriate)' + shell: 'bash' + run: | + cd "${{env.BUILD_REPOSITORY_FOLDERPATH}}/Laerdal.Scripts" \ + && \ + dotnet \ + msbuild \ + "Laerdal.Builder.targets" \ + -m:1 \ + -p:ShouldSkipMacCatalyst="false" \ + \ + -p:PackageOutputPath="${{env.BUILD_REPOSITORY_FOLDERPATH}}/Artifacts" \ + -p:Laerdal_Gradle_Path="/opt/homebrew/opt/gradle@7/bin/gradle" \ + -p:Laerdal_Source_Branch="${{env.LAERDAL_SOURCE_BRANCH}}" \ + -p:Laerdal_Repository_Path="${{env.LAERDAL_REPOSITORY_PATH}}" \ + -p:Laerdal_Github_Access_Token="${{env.SCL_GITHUB_ACCESS_TOKEN}}" \ + -p:Laerdal_Test_Results_Folderpath="${{env.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' + if: always() + with: + files: | + TestResults/**/TEST-*.xml + TestResults/**/TEST-*.trx + + - name: '⬆️ Upload Artifacts' # to share with other workflows https://stackoverflow.com/a/77663335/863651 + uses: 'actions/upload-artifact@v3' + with: + name: 'nugets' + path: 'Artifacts/**/*.nupkg' + + - 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 + shell: 'bash' + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/ksidirop/MAN-296-migrate-to-github-actions' + run: | + cd "${{env.BUILD_REPOSITORY_FOLDERPATH}}/Artifacts/" \ + && \ + ls . \ + && \ + dotnet \ + nuget \ + push \ + --source "https://nuget.pkg.github.com/Laerdal-Medical/index.json" \ + --api-key "${{env.SCL_GITHUB_ACCESS_TOKEN}}" \ + *nupkg + + # todo remove this once we fully transition over to the laerdal nuget server on github + - name: '🚀 Publish to the Laerdal Nuget Server in Azure' # https://learn.microsoft.com/en-us/azure/devops/artifacts/quickstarts/github-actions?view=azure-devops + shell: 'bash' + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/ksidirop/MAN-296-migrate-to-github-actions' + run: | + cd "${{env.BUILD_REPOSITORY_FOLDERPATH}}/Artifacts/" \ + && \ + ls . \ + && \ + dotnet \ + nuget \ + push \ + --source "https://pkgs.dev.azure.com/LaerdalMedical/_packaging/LaerdalNuGet/nuget/v3/index.json" \ + --api-key "${{env.SCL_AZURE_ARTIFACTS_API_KEY}}" \ + *nupkg diff --git a/.github/workflows/github-compile.yml b/.github/workflows/github-compile.yml deleted file mode 100644 index 200e6ea6..00000000 --- a/.github/workflows/github-compile.yml +++ /dev/null @@ -1,81 +0,0 @@ -# -# https://docs.github.com/en/actions/migrating-to-github-actions/automated-migrations/migrating-from-azure-devops-with-github-actions-importer#environment-variable-mapping -# - -name: 'Builder' - -env: - 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 - - 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: - - build: - - runs-on: macos-14 - - # variable substitution is not supported in github at all so we cant do stuff like this - # - # env: - # Build_Artifacts_Folderpath: $build_repository_folderpath/Artifacts - - steps: - - - name: '🔽 Checkout' - uses: 'actions/checkout@v3' - with: - fetch-depth: 1 - - - name: '🛠 Setup Build Environment' - 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 }}" \ - "$build_repository_folderpath/Artifacts" - - - name: '🏗 📦 Build, Pack & Announce New Release (if appropriate)' - shell: bash - run: | - cd "$build_repository_folderpath/Laerdal.Scripts" \ - && \ - dotnet \ - msbuild \ - "Laerdal.McuMgr.Builder.targets" \ - -m:1 \ - -p:ShouldSkipMacCatalyst="false" \ - \ - -p:PackageOutputPath="$build_repository_folderpath/Artifacts" \ - -p:Laerdal_Gradle_Path="/opt/homebrew/opt/gradle@7/bin/gradle" \ - -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 - if: always() - with: - files: | - TestResults/**/TEST-*.xml - TestResults/**/TEST-*.trx - - - name: '⬆️ Upload Artifacts' # to share with other workflows https://stackoverflow.com/a/77663335/863651 - uses: actions/upload-artifact@v3 - with: - name: 'nugets' - path: 'Artifacts/**/*.nupkg' diff --git a/.github/workflows/github-deploy.yml b/.github/workflows/github-deploy.yml deleted file mode 100644 index c309dbc3..00000000 --- a/.github/workflows/github-deploy.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: 'Deploy Nugets' - -on: - - push: - branches: [ "main", "master", "develop" ] - - workflow_dispatch: # allows to run this workflow manually from the Actions tab - - -jobs: - - compile: - uses: './.github/workflows/github-compile.yml' # reuse the compile workflow - - - deploy: # inspired by https://stackoverflow.com/a/77663335/863651 - runs-on: 'macos-14' - - needs: 'compile' - - steps: - - - name: '⬇️ Download Artifacts' - uses: 'actions/download-artifact@v3' - with: - name: 'nugets' - path: 'Artifacts/' - - - 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 "https://nuget.pkg.github.com/Laerdal-Medical/index.json" \ - --api-key "${{ secrets.scl_github_access_token }}" \ - "Artifacts/**/*.nupkg" - - # 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 "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.McuMgr.sln b/Laerdal.McuMgr.sln index 66832693..8252dce1 100644 --- a/Laerdal.McuMgr.sln +++ b/Laerdal.McuMgr.sln @@ -6,12 +6,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Misc", "_Misc", "{2459FC0F .gitignore = .gitignore azure-pipelines.yml = azure-pipelines.yml Laerdal.CreateNewReleaseInGithub.sh = Laerdal.Scripts\Laerdal.CreateNewReleaseInGithub.sh - Laerdal.McuMgr.Builder.targets = Laerdal.Scripts\Laerdal.McuMgr.Builder.targets + Laerdal.Builder.targets = Laerdal.Scripts\Laerdal.Builder.targets Laerdal.Version.sh = Laerdal.Scripts\Laerdal.Version.sh global.json = global.json Laerdal.SetupBuildEnvironment.sh = Laerdal.Scripts\Laerdal.SetupBuildEnvironment.sh - .github\workflows\github-compile.yml = .github\workflows\github-compile.yml - .github\workflows\github-deploy.yml = .github\workflows\github-deploy.yml + .github\workflows\github-actions.yml = .github\workflows\github-actions.yml EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Laerdal.McuMgr", "Laerdal.McuMgr\Laerdal.McuMgr.csproj", "{4E2952A5-394E-4184-8E12-F2D5342A43B2}" diff --git a/Laerdal.Scripts/Laerdal.McuMgr.Builder.targets b/Laerdal.Scripts/Laerdal.Builder.targets similarity index 97% rename from Laerdal.Scripts/Laerdal.McuMgr.Builder.targets rename to Laerdal.Scripts/Laerdal.Builder.targets index e74cefe2..ad8c0773 100644 --- a/Laerdal.Scripts/Laerdal.McuMgr.Builder.targets +++ b/Laerdal.Scripts/Laerdal.Builder.targets @@ -6,19 +6,19 @@ - + - + - + diff --git a/README.md b/README.md index 2a8c6476..5aa95ef4 100644 --- a/README.md +++ b/README.md @@ -775,14 +775,14 @@ You'll find the resulting nugets in the folder `Artifacts/`. # on macos *sh dotnet \ msbuild \ - Laerdal.McuMgr.Builder.targets \ + Laerdal.Builder.targets \ '"/m:1"' \ '"/p:Laerdal_Version_Full=1.0.x.0"' # on windows powershell & dotnet ^ msbuild ^ - Laerdal.McuMgr.Builder.targets ^ + Laerdal.Builder.targets ^ '"/m:1"' ^ '"/p:Laerdal_Version_Full=1.0.x.0"' diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 36db7887..a8df4b6c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -90,7 +90,7 @@ jobs: inputs: command: 'custom' custom: 'msbuild' - arguments: 'Laerdal.Scripts/Laerdal.McuMgr.Builder.targets -m:1 -p:ShouldSkipMacCatalyst="true" -p:Laerdal_Gradle_Path="/usr/local/opt/gradle@7/bin/gradle" -p:Laerdal_Test_Results_Folderpath="$(Laerdal_Test_Results_Folderpath)" -p:Laerdal_Github_Access_Token="$(Github.ComponentsTeam.AccessToken)" -p:Laerdal_Repository_Path="$(Repository.Path)" -p:Laerdal_Source_Branch="$(Build.SourceBranch)" -p:PackageOutputPath="$(Build.ArtifactStagingDirectory)/Artifacts/" ' + arguments: 'Laerdal.Scripts/Laerdal.Builder.targets -m:1 -p:ShouldSkipMacCatalyst="true" -p:Laerdal_Gradle_Path="/usr/local/opt/gradle@7/bin/gradle" -p:Laerdal_Test_Results_Folderpath="$(Laerdal_Test_Results_Folderpath)" -p:Laerdal_Github_Access_Token="$(Github.ComponentsTeam.AccessToken)" -p:Laerdal_Repository_Path="$(Repository.Path)" -p:Laerdal_Source_Branch="$(Build.SourceBranch)" -p:PackageOutputPath="$(Build.ArtifactStagingDirectory)/Artifacts/" ' - task: PublishTestResults@2 displayName: '📡 Publish Test Results'