|
| 1 | +name: publish |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - "v*" |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + packages: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + pack_and_publish: |
| 15 | + runs-on: macos-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + - name: Determine package version |
| 22 | + id: version |
| 23 | + shell: bash |
| 24 | + run: | |
| 25 | + if [[ "${{ github.ref }}" =~ ^refs/tags/v ]]; then |
| 26 | + REF="${{ github.ref }}" |
| 27 | + VERSION="${REF#refs/tags/v}" |
| 28 | + else |
| 29 | + CSPROJ="src/Kapusch.FacebookApisForiOSComponents/Kapusch.FacebookApisForiOSComponents.csproj" |
| 30 | + BASE_VERSION=$(grep -oE '<Version>[^<]+' "$CSPROJ" | head -n 1 | sed 's/<Version>//' || echo "0.1.0") |
| 31 | + COMMIT_SHORT=$(git rev-parse --short HEAD) |
| 32 | + RUN_NUMBER="${{ github.run_number }}" |
| 33 | + VERSION="${BASE_VERSION}-prerelease.${RUN_NUMBER}.${COMMIT_SHORT}" |
| 34 | + fi |
| 35 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 36 | + echo "Package version: ${VERSION}" |
| 37 | +
|
| 38 | + - uses: actions/setup-dotnet@v4 |
| 39 | + with: |
| 40 | + dotnet-version: "10.0.x" |
| 41 | + |
| 42 | + - name: Install iOS workload |
| 43 | + run: | |
| 44 | + dotnet workload install ios |
| 45 | +
|
| 46 | + - name: Cache NuGet |
| 47 | + uses: actions/cache@v4 |
| 48 | + with: |
| 49 | + path: ~/.nuget/packages |
| 50 | + key: ${{ runner.os }}-nuget-${{ hashFiles('global.json', '**/*.csproj') }} |
| 51 | + |
| 52 | + - name: Cache SwiftPM scratch |
| 53 | + uses: actions/cache@v4 |
| 54 | + with: |
| 55 | + path: | |
| 56 | + src/Kapusch.FacebookApisForiOSComponents/Native/iOS/build/spm |
| 57 | + key: ${{ runner.os }}-swiftpm-${{ hashFiles('src/Kapusch.FacebookApisForiOSComponents/Native/iOS/KapuschFacebookAuthInterop/Package.resolved') }} |
| 58 | + |
| 59 | + - name: Build iOS wrapper |
| 60 | + run: | |
| 61 | + bash src/Kapusch.FacebookApisForiOSComponents/Native/iOS/build.sh |
| 62 | +
|
| 63 | + - name: Collect Facebook xcframeworks |
| 64 | + run: | |
| 65 | + bash src/Kapusch.FacebookApisForiOSComponents/Native/iOS/collect-facebook-xcframeworks.sh |
| 66 | +
|
| 67 | + - name: Pack |
| 68 | + run: | |
| 69 | + dotnet pack src/Kapusch.FacebookApisForiOSComponents/Kapusch.FacebookApisForiOSComponents.csproj \ |
| 70 | + -c Release \ |
| 71 | + -o artifacts/nuget \ |
| 72 | + /p:PackageVersion="${{ steps.version.outputs.version }}" |
| 73 | +
|
| 74 | + - name: Validate nupkg layout |
| 75 | + run: | |
| 76 | + python3 - <<'PY' |
| 77 | + import glob, sys, zipfile |
| 78 | +
|
| 79 | + nupkgs = glob.glob("artifacts/nuget/*.nupkg") |
| 80 | + if not nupkgs: |
| 81 | + print("ERROR: no .nupkg found under artifacts/nuget/") |
| 82 | + sys.exit(1) |
| 83 | +
|
| 84 | + nupkg = sorted(nupkgs)[-1] |
| 85 | + print(f"Validating {nupkg}") |
| 86 | +
|
| 87 | + z = zipfile.ZipFile(nupkg) |
| 88 | + names = set(z.namelist()) |
| 89 | +
|
| 90 | + required = [ |
| 91 | + "buildTransitive/Kapusch.Facebook.iOS.targets", |
| 92 | + "kfb.xcframework/Info.plist", |
| 93 | + "fb/FBAEMKit.xcframework/Info.plist", |
| 94 | + "fb/FBSDKCoreKit.xcframework/Info.plist", |
| 95 | + "fb/FBSDKCoreKit_Basics.xcframework/Info.plist", |
| 96 | + "fb/FBSDKGamingServicesKit.xcframework/Info.plist", |
| 97 | + "fb/FBSDKLoginKit.xcframework/Info.plist", |
| 98 | + "fb/FBSDKShareKit.xcframework/Info.plist", |
| 99 | + ] |
| 100 | +
|
| 101 | + missing = [p for p in required if p not in names] |
| 102 | + if missing: |
| 103 | + print("ERROR: missing required paths in nupkg:") |
| 104 | + for p in missing: |
| 105 | + print(f" - {p}") |
| 106 | + sys.exit(1) |
| 107 | +
|
| 108 | + if "Info.plist" in names: |
| 109 | + print("ERROR: wrapper appears flattened (found 'Info.plist' at package root).") |
| 110 | + sys.exit(1) |
| 111 | +
|
| 112 | + print("OK: nupkg layout looks correct.") |
| 113 | + PY |
| 114 | +
|
| 115 | + - name: Push to GitHub Packages |
| 116 | + env: |
| 117 | + NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 118 | + run: | |
| 119 | + dotnet nuget push artifacts/nuget/*.nupkg \ |
| 120 | + --api-key "$NUGET_AUTH_TOKEN" \ |
| 121 | + --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \ |
| 122 | + --skip-duplicate |
0 commit comments