diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5456d84f..6abaccbb 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -63,6 +63,13 @@ jobs: path: ./src/lima/lima-and-qemu.macos* if-no-files-found: error + - name: Upload dependency mapping ARM64 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: dep-version-mapping-aarch64 + path: ./src/lima/dep-version-mapping-aarch64.json + if-no-files-found: error + - name: Make and release source code of dependencies run: make download-sources - name: Upload MacOS build @@ -119,6 +126,49 @@ jobs: path: ./src/lima/lima-and-qemu.macos* if-no-files-found: error + - name: Upload dependency mapping x86_64 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: dep-version-mapping-x86_64 + path: ./src/lima/dep-version-mapping-x86_64.json + if-no-files-found: error + + upload-dependency-mappings: + runs-on: ubuntu-latest + timeout-minutes: 10 + needs: + - macos-x86-build + - macos-arm64-build + + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + fetch-depth: 1 + persist-credentials: false + + - name: configure aws credentials + uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1 + with: + role-to-assume: ${{ secrets.DEPENDENCY_MAPPING_BUCKET_ROLE }} + role-session-name: dependency-mapping-upload-session + aws-region: ${{ secrets.DEPENDENCY_MAPPING_BUCKET_REGION }} + + - name: Download dependency mapping ARM64 + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 + with: + name: dep-version-mapping-aarch64 + path: build + + - name: Download dependency mapping x86_64 + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 + with: + name: dep-version-mapping-x86_64 + path: build + + - name: Upload dependency mappings to S3 + run: | + aws s3 cp ./build/dep-version-mapping-aarch64.json s3://${{ secrets.DEPENDENCY_MAPPING_BUCKET_NAME }}/aarch64/dep-version-mapping.json + aws s3 cp ./build/dep-version-mapping-x86_64.json s3://${{ secrets.DEPENDENCY_MAPPING_BUCKET_NAME }}/x86-64/dep-version-mapping.json release: runs-on: ubuntu-latest diff --git a/bin/lima-and-qemu.pl b/bin/lima-and-qemu.pl index f05d3bb5..f6c66dde 100755 --- a/bin/lima-and-qemu.pl +++ b/bin/lima-and-qemu.pl @@ -142,6 +142,39 @@ unlink("$repo_root/$dist.tar.gz"); system("tar cvfz $repo_root/$dist.tar.gz -C /tmp/$dist $files"); +# Extract package versions from Cellar and export to JSON +my %package_versions; +for my $file (keys %deps) { + # Extract package info from Cellar path: /opt/homebrew/Cellar/package/version/... + if ($file =~ m|/Cellar/([^/]+)/([^/]+)/|) { + my ($package, $version) = ($1, $2); + $package_versions{$package} = { + "package" => $package, + "version" => $version + }; + } + # Handle direct bin files (like limactl) that might not be in Cellar + elsif ($file =~ m|^$install_dir/bin/([^/]+)$|) { + my $binary_name = $1; + # Try to get version from the binary itself + my $version_output = qx($file --version 2>/dev/null | head -1); + if ($version_output =~ /(\d+\.\d+\.\d+[^\s]*)/) { + $package_versions{$binary_name} = { + "package" => $binary_name, + "version" => $1 + }; + } + } +} + +# Export to JSON +use JSON qw( encode_json ); +my $json_file = "$repo_root/dep-version-mapping-$arch.json"; +open(my $json_fh, ">", $json_file) or die "Can't write $json_file: $!"; +print $json_fh encode_json(\%package_versions); +close($json_fh); +print "Generated dependency mapping: $json_file\n"; + exit; # File references may involve multiple symlinks that need to be recorded as well, e.g.