From 337d18c1e7790f44c40bce43a5f800ee754e572e Mon Sep 17 00:00:00 2001 From: Kyriakos Sidiropoulos Date: Wed, 10 Apr 2024 15:33:44 +0200 Subject: [PATCH] feat (github-actions.yml) --- .github/workflows/github-actions.yml | 90 +++++++++++++++++++ Laerdal.Dfu.sln | 1 + ....Build.targets => Laerdal.Builder.targets} | 0 azure-pipelines.yaml | 2 +- 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/github-actions.yml rename Laerdal.Scripts/{Laerdal.Build.targets => Laerdal.Builder.targets} (100%) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml new file mode 100644 index 0000000..e2dbc79 --- /dev/null +++ b/.github/workflows/github-actions.yml @@ -0,0 +1,90 @@ +# +# 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.GITHUB_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: 'windows-2022' + + # 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@v4' + with: + fetch-tags: true # https://github.com/actions/checkout/issues/1471#issuecomment-1771231294 + fetch-depth: 0 + + - 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-Medical/index.json" \ + "__nuget_server_username_doesnt_matter__" \ + "${{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" \ + \ + -p:PackageOutputPath="${{ env.BUILD_REPOSITORY_FOLDERPATH }}/Artifacts" \ + -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 }}" + + - name: '⬆️ Upload Artifacts' # to share with other workflows https://stackoverflow.com/a/77663335/863651 + uses: 'actions/upload-artifact@v4' + with: + name: 'Artifacts' + path: '${{env.BUILD_REPOSITORY_FOLDERPATH}}/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 + shell: 'bash' + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' + 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 diff --git a/Laerdal.Dfu.sln b/Laerdal.Dfu.sln index 1dbf783..ec6f1f6 100644 --- a/Laerdal.Dfu.sln +++ b/Laerdal.Dfu.sln @@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Misc", "_Misc", "{37EBD209 Laerdal.Scripts\Laerdal.Changelog.sh = Laerdal.Scripts\Laerdal.Changelog.sh Laerdal.Scripts\Laerdal.CreateNewReleaseInGithub.sh = Laerdal.Scripts\Laerdal.CreateNewReleaseInGithub.sh Laerdal.Scripts\Laerdal.SetupBuildEnvironment.sh = Laerdal.Scripts\Laerdal.SetupBuildEnvironment.sh + .github\workflows\github-actions.yml = .github\workflows\github-actions.yml EndProjectSection EndProject Global diff --git a/Laerdal.Scripts/Laerdal.Build.targets b/Laerdal.Scripts/Laerdal.Builder.targets similarity index 100% rename from Laerdal.Scripts/Laerdal.Build.targets rename to Laerdal.Scripts/Laerdal.Builder.targets diff --git a/azure-pipelines.yaml b/azure-pipelines.yaml index 236dec0..556efe0 100644 --- a/azure-pipelines.yaml +++ b/azure-pipelines.yaml @@ -27,7 +27,7 @@ steps: - task: DotNetCoreCLI@2 displayName: 'dotnet build' inputs: - projects: '$(Build.SourcesDirectory)/Laerdal.Scripts/Laerdal.Build.targets' + projects: '$(Build.SourcesDirectory)/Laerdal.Scripts/Laerdal.Builder.targets' arguments: '--verbosity detailed' configuration: 'Release'