Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ksidirop/MAN-296-migrate-to-github-actions #97

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions .github/workflows/github-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:

Expand All @@ -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
Expand Down
34 changes: 13 additions & 21 deletions .github/workflows/github-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,20 @@ 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:
uses: './.github/workflows/github-compile.yml' # reuse the compile workflow


deploy: # inspired by https://stackoverflow.com/a/77663335/863651
runs-on: macos-14
runs-on: 'macos-14'

needs: 'compile'

Expand All @@ -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"
42 changes: 33 additions & 9 deletions Laerdal.SetupBuildEnvironment.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
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
7 changes: 4 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading