diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 00605d6..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,37 +0,0 @@ - -name: Build -run-name: ${{ github.job }} #${{ github.run_number }} on ${{ github.ref }} by @${{ github.actor }} - -on: - push: - branches: - - '*' - pull_request: - branches: - - '*' - -jobs: - build: - runs-on: macos-14 - timeout-minutes: 5 - steps: - - - name: Checkout - uses: actions/checkout@v4 - - - name: Restore Workloads - run: dotnet workload restore - shell: bash - - - name: Build - run: dotnet build -p:GITHUB_ACCESS_TOKEN=${{ secrets.GITHUB_TOKEN }} - shell: bash - env: - GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Publish Artifact - uses: actions/upload-artifact@v4 - with: - name: output - path: Output - if-no-files-found: error diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml new file mode 100644 index 0000000..527693d --- /dev/null +++ b/.github/workflows/github-actions.yml @@ -0,0 +1,116 @@ +# +# https://docs.github.com/en/actions/migrating-to-github-actions/automated-migrations/migrating-from-azure-devops-with-github-actions-importer#environment-variable-mapping +# +# bare in mind that variable substitution is not supported in github at all so we cant do stuff like this +# +# env: +# Build_Artifacts_Folderpath: $build_repository_folderpath/Artifacts +# + +name: '🏗 📦 Build, Pack & Deploy Nugets' + +run-name: ${{ github.job }} #${{ github.run_number }} on ${{ github.ref }} by @${{ github.actor }} + + +env: + BUILD_REPOSITORY_FOLDERPATH: ${{ github.workspace }} + + LAERDAL_SOURCE_BRANCH: ${{ github.ref }} + LAERDAL_REPOSITORY_PATH: ${{ github.repository }} + + # note that its vital that we use our own token here instead of GITHUB_TOKEN that is because access the + # nuget repos of Laerdal.Dfu.Bindings.iOS and Laerdal.Dfu.Bindings.Android which are inaccessible to the GITHUB_TOKEN + SCL_GITHUB_ACCESS_TOKEN: ${{ secrets.SCL_GITHUB_ACCESS_TOKEN }} + SCL_NUGET_ORG_FEED_API_KEY: ${{ secrets.NUGET_ORG_FEED_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 + + pull_request: + branches: + - '**' + + +jobs: + + build: + + runs-on: 'macos-14' + timeout-minutes: 20 + + 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/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" \ + \ + -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/**/*' + if-no-files-found: error + + - 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-335-ios-runtime-error-fix-about-you-should-not-call-this-method' + run: | + cd "${{env.BUILD_REPOSITORY_FOLDERPATH}}/Artifacts/" \ + && \ + ls . \ + && \ + dotnet \ + nuget \ + push \ + --source "https://nuget.pkg.github.com/Laerdal/index.json" \ + --api-key "${{env.SCL_GITHUB_ACCESS_TOKEN}}" \ + *nupkg + + - name: '🚀 Publish to the Nuget.org' + 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://api.nuget.org/v3/index.json" \ + --api-key "${{env.SCL_NUGET_ORG_FEED_API_KEY}}" \ + *.nupkg diff --git a/.gitignore b/.gitignore index c59dc09..ad1288c 100644 --- a/.gitignore +++ b/.gitignore @@ -409,4 +409,8 @@ Laerdal.Dfu.Bindings.iOS/Carthage/ Laerdal.Dfu.Bindings.iOS/Sharpie/ *.binlog -*.csproj.xml \ No newline at end of file +*.csproj.xml + +# we dont want to allow any local nuget.configs to be checked in as they can cause issues with the build and/or contain hardcoded API keys with write access to the +# nuget feed and this is something we definitely want to avoid at all costs for obvious reasons such nuget.config files should be remain local to each dev machine +[Nn][Uu][Gg][Ee][Tt].[Cc][Oo][Nn][Ff][Ii][Gg] diff --git a/Carthage/Carthage/Build/ZIPFoundation.xcframework/.keepme_in_git_otherwise_azure_pipelines_will_break b/Carthage/Carthage/Build/ZIPFoundation.xcframework/.keepme_in_git_otherwise_azure_pipelines_will_break new file mode 100644 index 0000000..e69de29 diff --git a/Carthage/Carthage/Build/iOSDFULibrary.xcframework/.keepme_in_git_otherwise_azure_pipelines_will_break b/Carthage/Carthage/Build/iOSDFULibrary.xcframework/.keepme_in_git_otherwise_azure_pipelines_will_break new file mode 100644 index 0000000..e69de29 diff --git a/Laerdal.Dfu.Bindings.iOS.sln b/Laerdal.Dfu.Bindings.iOS.sln index 4b2e124..74fab34 100644 --- a/Laerdal.Dfu.Bindings.iOS.sln +++ b/Laerdal.Dfu.Bindings.iOS.sln @@ -5,6 +5,18 @@ VisualStudioVersion = 17.5.002.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Laerdal.Dfu.Bindings.iOS", "Laerdal.Dfu.Bindings.iOS\Laerdal.Dfu.Bindings.iOS.csproj", "{A9FE8625-F74F-431E-BED5-A50AAD22FB88}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Misc", "_Misc", "{DB8D9BFF-ABFA-4C39-AAD8-416338998414}" + ProjectSection(SolutionItems) = preProject + LICENSE = LICENSE + README.md = README.md + .github\workflows\github-actions.yml = .github\workflows\github-actions.yml + Laerdal.Scripts\Laerdal.SetupBuildEnvironment.sh = Laerdal.Scripts\Laerdal.SetupBuildEnvironment.sh + Laerdal.Scripts\Laerdal.CreateNewReleaseInGithub.sh = Laerdal.Scripts\Laerdal.CreateNewReleaseInGithub.sh + Laerdal.Scripts\Laerdal.Changelog.sh = Laerdal.Scripts\Laerdal.Changelog.sh + Laerdal.Scripts\Laerdal.Builder.targets = Laerdal.Scripts\Laerdal.Builder.targets + .gitignore = .gitignore + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Release|Any CPU = Release|Any CPU diff --git a/Laerdal.Dfu.Bindings.iOS/ApiDefinition.cs b/Laerdal.Dfu.Bindings.iOS/ApiDefinition.cs index f29b725..0aa68cc 100644 --- a/Laerdal.Dfu.Bindings.iOS/ApiDefinition.cs +++ b/Laerdal.Dfu.Bindings.iOS/ApiDefinition.cs @@ -1,3 +1,21 @@ +// +// to future maintainers - anything with '@interface : NSObject' just needs the [BaseType] if we use [Model] on these an exception will be thrown +// to future maintainers in runtime because we will get an empty model with no code besides the exception being thrown +// to future maintainers +// to future maintainers // @interface DFUFirmware : NSObject +// to future maintainers [BaseType(typeof(NSObject), Name = "_TtC9NordicDFU11DFUFirmware")] +// to future maintainers [DisableDefaultCtor] +// to future maintainers interface DFUFirmware { ... } +// to future maintainers +// to future maintainers - anything '@protocol ' is decorated like so: +// to future maintainers +// to future maintainers // @protocol DFUPeripheralSelectorDelegate +// to future maintainers [BaseType(typeof(NSObject), Name = "_TtP9NordicDFU29DFUPeripheralSelectorDelegate_")] +// to future maintainers [Protocol(Name = "_TtP9NordicDFU29DFUPeripheralSelectorDelegate_")] +// to future maintainers [Model(Name = "_TtP9NordicDFU29DFUPeripheralSelectorDelegate_")] +// to future maintainers interface DFUPeripheralSelectorDelegate { ... } +// + using System; using CoreBluetooth; using CoreFoundation; @@ -7,9 +25,8 @@ namespace Laerdal.Dfu.Bindings.iOS { // @interface DFUFirmware : NSObject + // [Model (Name = "_TtC13iOSDFULibrary11DFUFirmware")] // [Protocol (Name = "_TtC13iOSDFULibrary11DFUFirmware")] [BaseType (typeof(NSObject), Name = "_TtC13iOSDFULibrary11DFUFirmware")] - [Protocol (Name = "_TtC13iOSDFULibrary11DFUFirmware")] - [Model (Name = "_TtC13iOSDFULibrary11DFUFirmware")] [DisableDefaultCtor] interface DFUFirmware { @@ -35,6 +52,7 @@ interface DFUFirmware // -(instancetype _Nullable)initWithUrlToZipFile:(NSURL * _Nonnull)urlToZipFile error:(NSError * _Nullable * _Nullable)error; [Export ("initWithUrlToZipFile:error:")] + [DesignatedInitializer] NativeHandle Constructor (NSUrl urlToZipFile, [NullAllowed] out NSError error); // -(instancetype _Nullable)initWithUrlToZipFile:(NSURL * _Nonnull)urlToZipFile type:(enum DFUFirmwareType)type error:(NSError * _Nullable * _Nullable)error __attribute__((objc_designated_initializer)); @@ -68,9 +86,8 @@ interface DFUFirmware } // @interface DFUFirmwareSize : NSObject + // [Model (Name = "_TtC13iOSDFULibrary15DFUFirmwareSize")] // [Protocol (Name = "_TtC13iOSDFULibrary15DFUFirmwareSize")] [BaseType (typeof(NSObject), Name = "_TtC13iOSDFULibrary15DFUFirmwareSize")] - [Protocol (Name = "_TtC13iOSDFULibrary15DFUFirmwareSize")] - [Model (Name = "_TtC13iOSDFULibrary15DFUFirmwareSize")] [DisableDefaultCtor] interface DFUFirmwareSize { @@ -88,9 +105,9 @@ interface DFUFirmwareSize } // @protocol DFUPeripheralSelectorDelegate - [BaseType (typeof(NSObject), Name = "_TtP13iOSDFULibrary29DFUPeripheralSelectorDelegate_")] - [Protocol (Name = "_TtP13iOSDFULibrary29DFUPeripheralSelectorDelegate_")] [Model (Name = "_TtP13iOSDFULibrary29DFUPeripheralSelectorDelegate_")] + [Protocol (Name = "_TtP13iOSDFULibrary29DFUPeripheralSelectorDelegate_")] + [BaseType (typeof(NSObject), Name = "_TtP13iOSDFULibrary29DFUPeripheralSelectorDelegate_")] interface IDFUPeripheralSelectorDelegate { // @required -(BOOL)select:(CBPeripheral * _Nonnull)peripheral advertisementData:(NSDictionary * _Nonnull)advertisementData RSSI:(NSNumber * _Nonnull)RSSI hint:(NSString * _Nullable)name __attribute__((warn_unused_result(""))); @@ -106,9 +123,9 @@ interface IDFUPeripheralSelectorDelegate } // @protocol DFUProgressDelegate - [BaseType (typeof(NSObject), Name = "_TtP13iOSDFULibrary19DFUProgressDelegate_")] - [Protocol (Name = "_TtP13iOSDFULibrary19DFUProgressDelegate_")] [Model (Name = "_TtP13iOSDFULibrary19DFUProgressDelegate_")] + [Protocol (Name = "_TtP13iOSDFULibrary19DFUProgressDelegate_")] + [BaseType (typeof(NSObject), Name = "_TtP13iOSDFULibrary19DFUProgressDelegate_")] interface DFUProgressDelegate { // @required -(void)dfuProgressDidChangeFor:(NSInteger)part outOf:(NSInteger)totalParts to:(NSInteger)progress currentSpeedBytesPerSecond:(double)currentSpeedBytesPerSecond avgSpeedBytesPerSecond:(double)avgSpeedBytesPerSecond; @@ -118,9 +135,8 @@ interface DFUProgressDelegate } // @interface DFUServiceController : NSObject + // [Model (Name = "_TtC13iOSDFULibrary20DFUServiceController")] // [Protocol (Name = "_TtC13iOSDFULibrary20DFUServiceController")] [BaseType (typeof(NSObject), Name = "_TtC13iOSDFULibrary20DFUServiceController")] - [Protocol (Name = "_TtC13iOSDFULibrary20DFUServiceController")] - [Model (Name = "_TtC13iOSDFULibrary20DFUServiceController")] [DisableDefaultCtor] interface DFUServiceController { @@ -150,9 +166,9 @@ interface DFUServiceController } // @protocol DFUServiceDelegate - [BaseType (typeof(NSObject), Name = "_TtP13iOSDFULibrary18DFUServiceDelegate_")] - [Protocol (Name = "_TtP13iOSDFULibrary18DFUServiceDelegate_")] [Model (Name = "_TtP13iOSDFULibrary18DFUServiceDelegate_")] + [Protocol (Name = "_TtP13iOSDFULibrary18DFUServiceDelegate_")] + [BaseType (typeof(NSObject), Name = "_TtP13iOSDFULibrary18DFUServiceDelegate_")] interface DFUServiceDelegate { // @required -(void)dfuStateDidChangeTo:(enum DFUState)state; @@ -167,9 +183,8 @@ interface DFUServiceDelegate } // @interface DFUServiceInitiator : NSObject + // [Model (Name = "_TtC13iOSDFULibrary19DFUServiceInitiator")] [Protocol (Name = "_TtC13iOSDFULibrary19DFUServiceInitiator")] [BaseType (typeof(NSObject), Name = "_TtC13iOSDFULibrary19DFUServiceInitiator")] - [Protocol (Name = "_TtC13iOSDFULibrary19DFUServiceInitiator")] - [Model (Name = "_TtC13iOSDFULibrary19DFUServiceInitiator")] [DisableDefaultCtor] interface DFUServiceInitiator { @@ -268,9 +283,8 @@ interface DFUServiceInitiator } // @interface DFUUuid : NSObject + // [Model (Name = "_TtC13iOSDFULibrary7DFUUuid")] // [Protocol (Name = "_TtC13iOSDFULibrary7DFUUuid")] [BaseType (typeof(NSObject), Name = "_TtC13iOSDFULibrary7DFUUuid")] - [Protocol (Name = "_TtC13iOSDFULibrary7DFUUuid")] - [Model (Name = "_TtC13iOSDFULibrary7DFUUuid")] [DisableDefaultCtor] interface DFUUuid { @@ -289,9 +303,9 @@ interface DFUUuid } // @interface DFUUuidHelper : NSObject + // [Model (Name = "_TtC13iOSDFULibrary13DFUUuidHelper")] // [Protocol (Name = "_TtC13iOSDFULibrary13DFUUuidHelper")] [BaseType (typeof(NSObject), Name = "_TtC13iOSDFULibrary13DFUUuidHelper")] - [Protocol (Name = "_TtC13iOSDFULibrary13DFUUuidHelper")] - [Model (Name = "_TtC13iOSDFULibrary13DFUUuidHelper")] + [DisableDefaultCtor] interface DFUUuidHelper { // @property (readonly, nonatomic, strong) CBUUID * _Nonnull legacyDFUService; @@ -344,17 +358,17 @@ interface DFUUuidHelper } // @interface IntelHex2BinConverter : NSObject + // [Model (Name = "_TtC13iOSDFULibrary21IntelHex2BinConverter")] // [Protocol (Name = "_TtC13iOSDFULibrary21IntelHex2BinConverter")] [BaseType (typeof(NSObject), Name = "_TtC13iOSDFULibrary21IntelHex2BinConverter")] - [Protocol (Name = "_TtC13iOSDFULibrary21IntelHex2BinConverter")] - [Model (Name = "_TtC13iOSDFULibrary21IntelHex2BinConverter")] + [DisableDefaultCtor] interface IntelHex2BinConverter { } // @interface LegacyDFUServiceInitiator : DFUServiceInitiator + // [Model (Name = "_TtC13iOSDFULibrary25LegacyDFUServiceInitiator")] // [Protocol (Name = "_TtC13iOSDFULibrary25LegacyDFUServiceInitiator")] [BaseType (typeof(DFUServiceInitiator), Name = "_TtC13iOSDFULibrary25LegacyDFUServiceInitiator")] - [Protocol (Name = "_TtC13iOSDFULibrary25LegacyDFUServiceInitiator")] - [Model (Name = "_TtC13iOSDFULibrary25LegacyDFUServiceInitiator")] + [DisableDefaultCtor] interface LegacyDFUServiceInitiator { // -(DFUServiceController * _Nullable)startWithTargetWithIdentifier:(NSUUID * _Nonnull)uuid __attribute__((warn_unused_result(""))); @@ -374,9 +388,9 @@ interface LegacyDFUServiceInitiator } // @protocol LoggerDelegate - [BaseType (typeof(NSObject), Name = "_TtP13iOSDFULibrary14LoggerDelegate_")] - [Protocol (Name = "_TtP13iOSDFULibrary14LoggerDelegate_")] [Model (Name = "_TtP13iOSDFULibrary14LoggerDelegate_")] + [Protocol (Name = "_TtP13iOSDFULibrary14LoggerDelegate_")] + [BaseType (typeof(NSObject), Name = "_TtP13iOSDFULibrary14LoggerDelegate_")] interface LoggerDelegate { // @required -(void)logWith:(enum LogLevel)level message:(NSString * _Nonnull)message; @@ -386,9 +400,9 @@ interface LoggerDelegate } // @interface SecureDFUServiceInitiator : DFUServiceInitiator + // [Model (Name = "_TtC13iOSDFULibrary25SecureDFUServiceInitiator")] // [Protocol (Name = "_TtC13iOSDFULibrary25SecureDFUServiceInitiator")] [BaseType (typeof(DFUServiceInitiator), Name = "_TtC13iOSDFULibrary25SecureDFUServiceInitiator")] - [Protocol (Name = "_TtC13iOSDFULibrary25SecureDFUServiceInitiator")] - [Model (Name = "_TtC13iOSDFULibrary25SecureDFUServiceInitiator")] + [DisableDefaultCtor] interface SecureDFUServiceInitiator { // -(DFUServiceController * _Nullable)startWithTargetWithIdentifier:(NSUUID * _Nonnull)uuid __attribute__((warn_unused_result(""))); diff --git a/Laerdal.Dfu.Bindings.iOS/Laerdal.Dfu.Bindings.iOS.csproj b/Laerdal.Dfu.Bindings.iOS/Laerdal.Dfu.Bindings.iOS.csproj index 92d0b4b..99f24f1 100644 --- a/Laerdal.Dfu.Bindings.iOS/Laerdal.Dfu.Bindings.iOS.csproj +++ b/Laerdal.Dfu.Bindings.iOS/Laerdal.Dfu.Bindings.iOS.csproj @@ -4,8 +4,7 @@ Ble;Tools;Xamarin;Dfu;Bluetooth;Nordic;Semiconductor Laerdal Medical, Francois Raminosona Xamarin wrapper around Nordic.Dfu for iOS. - - 4.13.0 + @@ -13,55 +12,65 @@ net7.0-ios -v -v -v -v - + true true true - false + + + true - $(BUILD_BUILDID) - $([MSBuild]::Add(43857, $(GITHUB_RUN_NUMBER))) - $([MSBuild]::Add(43857, $(CI_PIPELINE_IID))) - 0 + + + 4.13.0 + 0 - $(Nordic_Package_Version).$(Laerdal_Revision) + $(Nordic_Package_Version).$(Laerdal_Revision) - + - - + + - - + + - - - - - - + + + + + + + + + + + + - - + + + + + + + @@ -69,7 +78,7 @@ False Foundation - + Framework diff --git a/Laerdal.Scripts/Laerdal.Builder.targets b/Laerdal.Scripts/Laerdal.Builder.targets new file mode 100644 index 0000000..f621c02 --- /dev/null +++ b/Laerdal.Scripts/Laerdal.Builder.targets @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + High + + Release + + $([System.IO.Path]::Combine($(MSBuildThisFileDirectory), `..`, `Output`)) + $(BUILD_ARTIFACTSTAGINGDIRECTORY) + + $([System.IO.Path]::Combine($(MSBuildThisFileDirectory), `..`, `Laerdal.Dfu.Bindings.iOS`, `Laerdal.Dfu.Bindings.iOS.csproj`)) + + $(MSBuildThisFileDirectory) + + + 4.13.0 + $(BUILD_BUILDID) + $([MSBuild]::Add(43857, $(GITHUB_RUN_NUMBER))) + $([MSBuild]::Add(43857, $(CI_PIPELINE_IID))) + 0 + + $(Nordic_Package_Version).$(Laerdal_Revision) + + + + + + + + + + + + <_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters);Configuration=$(Configuration) + <_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters);Laerdal_Version=$(Laerdal_Version) + <_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters);PackageOutputPath=$(PackageOutputPath) + <_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters);Laerdal_Github_Access_Token=$(Laerdal_Github_Access_Token) + + + + + + + + + + + + + + + + + + + $([System.IO.Path]::Combine($(MSBuildThisFileDirectory), `Laerdal.CreateNewReleaseInGithub.sh`)) + + <_Laerdal_Create_Github_Release_Script_Parameters>$(_Laerdal_Create_Github_Release_Script_Parameters) --git-branch '$(Laerdal_Source_Branch)' + <_Laerdal_Create_Github_Release_Script_Parameters>$(_Laerdal_Create_Github_Release_Script_Parameters) --tag-version '$(Laerdal_Version)' + <_Laerdal_Create_Github_Release_Script_Parameters>$(_Laerdal_Create_Github_Release_Script_Parameters) --access-token '$(Laerdal_Github_Access_Token)' + <_Laerdal_Create_Github_Release_Script_Parameters>$(_Laerdal_Create_Github_Release_Script_Parameters) --repository-path '$(Laerdal_Repository_Path)' + + + + + + + + \ No newline at end of file diff --git a/Laerdal.Scripts/Laerdal.Changelog.sh b/Laerdal.Scripts/Laerdal.Changelog.sh new file mode 100644 index 0000000..49e40ae --- /dev/null +++ b/Laerdal.Scripts/Laerdal.Changelog.sh @@ -0,0 +1,102 @@ +#!/bin/bash + +usage(){ + echo "usage: ./Laerdal.Changelog.sh [-nv | --new-version X.Y.Z] [-o | --output version.txt] [-h | --help]" + echo "parameters:" + echo " -nv | --new-version [version] New major.minor.patch version (default is 0.0.0)" + echo " -o | --output [filename] Name of the output file" + echo " -h | --help Prints this message" + echo " -v | --verbose Verbose mode" +} + +function log () { + if [[ $verbose -eq 1 ]]; then + echo "$@" + fi +} + +filename="CHANGELOG.md" + +while [ "$1" != "" ]; do + case $1 in + -nv | --new-version ) shift + newversion="$1" + ;; + -o | --output ) shift + filename="$1" + ;; + -h | --help ) usage + exit + ;; + -v | --verbose ) verbose=1 + ;; + * ) echo + echo "### Wrong parameter: $1 ###" + echo + usage + exit 1 + esac + shift +done + + +if [ ! -z "$newversion" ]; then + if [[ "$newversion" =~ .*"-".* ]]; then + log "New version contains a dash, skipping changelog generation" + else + currenthash=$(git show --format=%h --no-patch) + echo "$currenthash $newversion" > tags.txt + log "New version: $newversion" + fi +else + echo "" > tags.txt +fi + +# Get all tags on develop and Filter out tags that are not in the format "HASH 1.2.3" +git tag --format='%(objectname:short) %(refname:short)' --sort=-version:refname --merged | grep -o '[a-z0-9]* [a-z0-9]*[.][a-z0-9]*[.][a-z0-9]*$' >> tags.txt + +# Create changelog file +echo "# CHANGELOG" > "$filename" +echo "" >> "$filename" +log "Created changelog file: $filename" + + +# Loop through all tags and create changelog +lastline='' +while read line; do + if [ -z "$lastline" ]; then + lastline=$line + else + # Split the line into hash and version + lasthash=`echo $lastline | cut -d' ' -f1` + lastversion=`echo $lastline | cut -d' ' -f2` + hash=`echo $line | cut -d' ' -f1` + + echo "## **$lastversion**" >> "$filename" + log "Added version: $lastversion" + # Get the commit message and author of the tag + git log -n 1 --pretty=tformat:"%b" $lasthash >> "$filename" + + echo "" >> "$filename" + + # Get all commits between the current tag and the previous tag + git log $hash..$lasthash --pretty=format:"- %s [%cn]" --no-merges >> "$filename" + + echo "" >> "$filename" + echo "" >> "$filename" + + # Get the commit message and author of the tag + git log -n 1 --pretty=tformat:"> by _%cn_ on _%cd_" --date=format:'%Y-%m-%d %H:%M:%S' $lasthash >> "$filename" + + echo "" >> "$filename" + echo "---" >> "$filename" + echo "" >> "$filename" + lastline=$line + fi +done < tags.txt + +rm -r -f tags.txt + +log "Done" + +exit 0 \ No newline at end of file diff --git a/Laerdal.Scripts/Laerdal.CreateNewReleaseInGithub.sh b/Laerdal.Scripts/Laerdal.CreateNewReleaseInGithub.sh new file mode 100644 index 0000000..cf1ce63 --- /dev/null +++ b/Laerdal.Scripts/Laerdal.CreateNewReleaseInGithub.sh @@ -0,0 +1,167 @@ +#!/bin/bash + +declare VERBOSE=0 +declare TAG_VERSION="" + +declare GIT_BRANCH="" +declare GITHUB_ACCESS_TOKEN="" +declare GITHUB_REPOSITORY_PATH="" + +function parse_arguments() { + while [[ $# -gt 0 ]]; do + case $1 in + + -v | --log) + VERBOSE=1 + shift + ;; + + -r | --repository-path) + GITHUB_REPOSITORY_PATH="$2" + shift + ;; + + -t | --tag-version) + TAG_VERSION="$2" + shift + ;; + + -b | --git-branch) + GIT_BRANCH="$2" + shift + ;; + + -a | --access-token) + GITHUB_ACCESS_TOKEN="$2" + shift + ;; + + *) + echo "Unknown option: $1" + usage + exit 1 + ;; + + esac + shift + done + + if [[ -z $GIT_BRANCH ]]; then + echo "Missing git-branch." + usage + exit 1 + fi + + if [[ -z $GITHUB_REPOSITORY_PATH ]]; then + echo "Missing github-repository." + usage + exit 1 + fi + + if [[ -z $GITHUB_ACCESS_TOKEN ]]; then + echo "Missing github-access-token." + usage + exit 1 + fi + + validate_tag_format "$TAG_VERSION" +} + +function validate_tag_format() { + local -r tag="$1" + local -r pattern='^[0-9]+\.[0-9]+(\.[0-9]+)?$' + + if ! [[ $tag =~ $pattern ]]; then + exit_with_error "Tag format is invalid: '$tag'" + fi +} + +function usage() { + local -r script_name=$(basename "$0") + + echo "Usage: $script_name [--verbose|-v] [--repository-path|-r]= [--git-branch|-b]= [--access-token|-a]= [--tag-version|-t]=" +} + +function create_release_on_github() { + # https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#create-a-release + + local eventual_tag_name="" + local eventual_singleline_summary="" + if [[ $GIT_BRANCH == "refs/heads/main" || $GIT_BRANCH == "refs/heads/master" ]]; then + eventual_tag_name="v$TAG_VERSION" # builds targeting main have this simple and straightforward tag name + eventual_singleline_summary="Release $eventual_tag_name" + + elif [[ $GIT_BRANCH == "refs/heads/develop" ]]; then # all builds that target develop are beta builds + eventual_tag_name="v$TAG_VERSION-beta" + eventual_singleline_summary="Beta $eventual_tag_name" + + else # all other builds that dont target main are alpha builds should rarely happen in practice but just in case + eventual_tag_name="v$TAG_VERSION-alpha" + eventual_singleline_summary="Alpha $eventual_tag_name" + fi + + local -r payload=$( + cat <"' + +# on windows powershell +dotnet msbuild ^ + Laerdal.Scripts\Laerdal.Builder.targets ^ + /m:1 ^ + /p:Laerdal_Version=1.0.x.0 ^ + /p:Laerdal_Github_Access_Token="" ``` You'll find the nuget in `Output/` -### Known issues +### ❗ Known issues - [**Invalid Swift support when submitted to the Apple AppStore**](https://github.com/Laerdal/Laerdal.Dfu.iOS/issues/3) | @@ -44,6 +64,7 @@ Fix : https://github.com/Laerdal/Laerdal.Dfu.iOS/issues/3#issuecomment-783298581 ```shell #!/usr/bin/env sh + xcode_lib_path="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0/iphoneos" app_path=$1 app_name=