|
| 1 | +name: Notarize Archive or App Bundle |
| 2 | +description: Notarize ZIP archives, .app bundles, or other files by creating temporary zip |
| 3 | +author: MassaLabs |
| 4 | + |
| 5 | +inputs: |
| 6 | + paths: |
| 7 | + description: Files to notarize (space separated). If not .zip/.pkg/.dmg, creates temporary zip |
| 8 | + required: true |
| 9 | + apple-id: |
| 10 | + description: Apple ID |
| 11 | + required: true |
| 12 | + apple-team-id: |
| 13 | + description: Team ID |
| 14 | + required: true |
| 15 | + apple-app-password: |
| 16 | + description: App password |
| 17 | + required: true |
| 18 | + |
| 19 | +runs: |
| 20 | + using: "composite" |
| 21 | + steps: |
| 22 | + - name: Check file formats and create temporary zip if needed |
| 23 | + run: | |
| 24 | + echo "🔍 Checking file formats for notarization..." |
| 25 | + temp_zip_created=false |
| 26 | + unsupported_files=() |
| 27 | +
|
| 28 | + for path in ${{ inputs.paths }}; do |
| 29 | + echo "📁 Processing: $path" |
| 30 | +
|
| 31 | + # Get file extension (only if it has one) |
| 32 | + filename=$(basename "$path") |
| 33 | + extension="" |
| 34 | + if [[ "$filename" == *.* ]]; then |
| 35 | + extension="${filename##*.}" |
| 36 | + fi |
| 37 | +
|
| 38 | + # Check if file is already in supported format |
| 39 | + if [[ "$extension" == "zip" || "$extension" == "pkg" || "$extension" == "dmg" ]]; then |
| 40 | + echo "✅ File $path is already in supported format ($extension)" |
| 41 | + else |
| 42 | + echo "⚠️ File $path has unsupported extension ($extension) or no extension, will add to temporary zip..." |
| 43 | + unsupported_files+=("$path") |
| 44 | + temp_zip_created=true |
| 45 | + fi |
| 46 | + done |
| 47 | +
|
| 48 | + # Create single temporary zip for all unsupported files |
| 49 | + if [[ "$temp_zip_created" == "true" ]]; then |
| 50 | + echo "📦 Creating single temporary zip for all unsupported files..." |
| 51 | + temp_zip="temp_notarization_package.zip" |
| 52 | + |
| 53 | + # Add all unsupported files to the zip |
| 54 | + for file in "${unsupported_files[@]}"; do |
| 55 | + echo "📁 Adding to zip: $file" |
| 56 | + zip -r "$temp_zip" "$file" |
| 57 | + done |
| 58 | +
|
| 59 | + echo "TEMP_ZIP_CREATED=true" >> $GITHUB_ENV |
| 60 | + echo "TEMP_ZIP_FILE=$temp_zip" >> $GITHUB_ENV |
| 61 | + |
| 62 | + # Store list of unsupported files for later stapling |
| 63 | + printf "%s\n" "${unsupported_files[@]}" > unsupported_files_list.txt |
| 64 | + fi |
| 65 | + shell: bash |
| 66 | + |
| 67 | + - name: Submit packages for notarization |
| 68 | + run: | |
| 69 | + # Process original supported files |
| 70 | + for path in ${{ inputs.paths }}; do |
| 71 | + filename=$(basename "$path") |
| 72 | + extension="" |
| 73 | + if [[ "$filename" == *.* ]]; then |
| 74 | + extension="${filename##*.}" |
| 75 | + fi |
| 76 | +
|
| 77 | + if [[ "$extension" == "zip" || "$extension" == "pkg" || "$extension" == "dmg" ]]; then |
| 78 | + echo "📦 Submitting for notarization: $path" |
| 79 | + xcrun notarytool submit "$path" \ |
| 80 | + --apple-id "${{ inputs.apple-id }}" \ |
| 81 | + --password "${{ inputs.apple-app-password }}" \ |
| 82 | + --team-id "${{ inputs.apple-team-id }}" \ |
| 83 | + --wait |
| 84 | + fi |
| 85 | + done |
| 86 | +
|
| 87 | + # Process single temporary zip file if created |
| 88 | + if [[ "${{ env.TEMP_ZIP_CREATED }}" == "true" ]]; then |
| 89 | + echo "📦 Submitting temporary zip for notarization: ${{ env.TEMP_ZIP_FILE }}" |
| 90 | + xcrun notarytool submit "${{ env.TEMP_ZIP_FILE }}" \ |
| 91 | + --apple-id "${{ inputs.apple-id }}" \ |
| 92 | + --password "${{ inputs.apple-app-password }}" \ |
| 93 | + --team-id "${{ inputs.apple-team-id }}" \ |
| 94 | + --wait |
| 95 | + fi |
| 96 | + shell: bash |
| 97 | + |
| 98 | + - name: Staple notarization tickets to original files |
| 99 | + run: | |
| 100 | + # Staple to original supported files (only .pkg and .dmg, not .zip) |
| 101 | + for path in ${{ inputs.paths }}; do |
| 102 | + filename=$(basename "$path") |
| 103 | + extension="" |
| 104 | + if [[ "$filename" == *.* ]]; then |
| 105 | + extension="${filename##*.}" |
| 106 | + fi |
| 107 | +
|
| 108 | + if [[ "$extension" == "pkg" || "$extension" == "dmg" ]]; then |
| 109 | + echo "📎 Stapling to: $path" |
| 110 | + xcrun stapler staple "$path" |
| 111 | + xcrun stapler validate "$path" |
| 112 | + elif [[ "$extension" == "zip" ]]; then |
| 113 | + echo "⚠️ Skipping stapling for zip file: $path (Zip files cannot be stapled)" |
| 114 | + elif [[ -z "$extension" ]]; then |
| 115 | + echo "⚠️ Skipping stapling for binary: $path (Standalone binaries cannot be stapled)" |
| 116 | + fi |
| 117 | + done |
| 118 | + shell: bash |
| 119 | + |
| 120 | + - name: Clean up temporary files |
| 121 | + run: | |
| 122 | + rm -f temp_notarization_package.zip unsupported_files_list.txt |
| 123 | + shell: bash |
0 commit comments