diff --git a/.github/workflows/Updater-on-Demand.yml b/.github/workflows/Updater-on-Demand.yml index 2b1bd0aa7..3d5d34246 100644 --- a/.github/workflows/Updater-on-Demand.yml +++ b/.github/workflows/Updater-on-Demand.yml @@ -1,6 +1,6 @@ --- name: Generate Updates PRs on Demand -run-name: Generate Updates PRs on Demand using ${{ inputs.version_cmd_input }} +run-name: Generating Updates PRs on Demand using ${{ inputs.version_cmd_input }} on: workflow_dispatch: inputs: @@ -63,10 +63,18 @@ jobs: else branch_tag="${pkg_version}" fi - git checkout -b "${pkg}-${branch_tag}" || git checkout "${pkg}-${branch_tag}" - git commit -m "Add unbuilt ${pkg} to ${pkg}-${branch_tag}" + export updater_branch="updater-${pkg}-${branch_tag}" + if git checkout -b "${updater_branch}"; then + echo "${updater_branch} branch created." + else + echo "Updating & rebasing existing ${updater_branch} branch." + git checkout "${updater_branch}" + git pull --rebase origin master + git push -f + fi + git commit -m "Add unbuilt ${pkg} to ${updater_branch}" git push - gh workflow -R chromebrew/chromebrew run Build.yml -f branch="${pkg}-${branch_tag}" + gh workflow -R chromebrew/chromebrew run Build.yml -f branch="${updater_branch}" git stash || true git checkout master done diff --git a/.github/workflows/Updater.yml b/.github/workflows/Updater.yml index 0c92d389c..33805b6dd 100644 --- a/.github/workflows/Updater.yml +++ b/.github/workflows/Updater.yml @@ -16,79 +16,11 @@ jobs: if: ${{ github.repository_owner == 'chromebrew' }} runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4 - with: - persist-credentials: true - - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.4.5' - - name: Install Python pip - run: sudo apt install -y python3-pip - - name: Setup Git. - id: git-setup - run: | - git config --global push.autoSetupRemote true - git config user.name "${{ github.actor }}" - git config user.email "${{ github.actor }}@users.noreply.github.com" - - name: Install ruby-libversion # Hopefully this will get added as an Ubuntu/Debian package. https://github.com/repology/libversion/issues/35 - working-directory: ${{ runner.temp }} - run: | - git clone --depth 1 -b 3.0.3 https://github.com/repology/libversion - cd libversion - mkdir build - cd build - cmake .. - make -j "$(nproc)" - sudo make install - sudo gem install ruby-libversion - name: Check for updates in pip packages. id: pip-update-checks run: | - git pull - git stash drop || true - echo "pwd is $(pwd)" - LD_LIBRARY_PATH=/usr/local/lib ruby tools/version.rb -u "py3_*" - for i in $(git status --porcelain | awk '{print $2}' | grep ^packages/) - do - git stash pop || true - git add $i - pkg=${i%.rb} - pkg=${pkg#packages/} - pkg_version="$(LD_LIBRARY_PATH=/usr/local/lib ruby tools/version.rb -j ${pkg} | jq -r '.[]|.version')" - if [[ -z "$pkg_version" ]]; then - branch_tag="$(date -u +%F-%H-%M)" - else - branch_tag="${pkg_version}" - fi - git checkout -b "${pkg}-${branch_tag}" || git checkout "${pkg}-${branch_tag}" - git commit -m "Add unbuilt ${pkg} to ${pkg}-${branch_tag}" - git push - gh workflow -R chromebrew/chromebrew run Build.yml -f branch="${pkg}-${branch_tag}" - git stash || true - git checkout master - done + gh workflow -R chromebrew/chromebrew run Updater-on-Demand.yml -f version_cmd_input="py3_*" - name: Check for updates in ruby gem packages. id: gem-update-checks run: | - git pull - git stash drop || true - LD_LIBRARY_PATH=/usr/local/lib ruby tools/version.rb -u "ruby_*" - for i in $(git status --porcelain | awk '{print $2}' | grep ^packages/) - do - git stash pop || true - git add $i - pkg=${i%.rb} - pkg=${pkg#packages/} - pkg_version="$(LD_LIBRARY_PATH=/usr/local/lib ruby ./tools/version.rb -j ${pkg} | jq -r '.[]|.version')" - if [[ -z "$pkg_version" ]]; then - branch_tag="$(date -u +%F-%H-%M)" - else - branch_tag="${pkg_version}" - fi - git checkout -b "${pkg}-${branch_tag}" || git checkout "${pkg}-${branch_tag}" - git commit -m "Add unbuilt ${pkg} to ${pkg}-${branch_tag}" - git push - gh workflow -R chromebrew/chromebrew run Build.yml -f branch="${pkg}-${branch_tag}" - git stash || true - git checkout master - done + gh workflow -R chromebrew/chromebrew run Updater-on-Demand.yml -f version_cmd_input="ruby_*" diff --git a/tools/version.rb b/tools/version.rb index 5a13c869e..3cfcc8513 100755 --- a/tools/version.rb +++ b/tools/version.rb @@ -1,5 +1,5 @@ #!/usr/bin/env ruby -# version.rb version 1.5 (for Chromebrew) +# version.rb version 1.6 (for Chromebrew) OPTIONS = %w[-h --help -j --json -u --update-package-files -v --verbose] @@ -39,6 +39,7 @@ UPDATE_PACKAGE_FILES = ARGV.include?('-u') || ARGV.include?('--update-package-fi VERBOSE = ARGV.include?('-v') || ARGV.include?('--verbose') bc_updated = {} pkg_names = {} +updatable_pkg = {} version_line_string = {} versions_updated = {} versions = [] @@ -149,6 +150,15 @@ if filelist.length.positive? puts "#{'-------'.ljust(package_field_length)}#{'------'.ljust(status_field_length)}#{'-------'.ljust(version_field_length)}--------" unless OUTPUT_JSON filelist.each do |filename| pkg = Package.load_package(filename) + # Mark package file as updatable (i.e., the version field can be + # updated in the package file) if the string "version" is on the + # git_hashtag line or the string "#{version}" is on the source_url + # line. + updatable_pkg[pkg.name.to_sym] = if `grep git_hashtag #{filename} | grep version`.empty? + !`grep source_url #{filename} | grep -v SKIP | grep -v "(" | grep "\#{version}"`.empty? + else + true + end pkg_names[pkg.name.to_sym] = pkg.name version_line_string[pkg.name.to_sym] = '' # We annotate some packages to let us know that they won't work here. @@ -198,7 +208,7 @@ if filelist.length.positive? unless upstream_version.nil? versions_updated[pkg.name.to_sym] = 'Up to date.' if (Libversion.version_compare2(PackageUtils.get_clean_version(pkg.version), upstream_version) >= 0) && versions_updated[pkg.name.to_sym] != 'Not Found.' if Libversion.version_compare2(PackageUtils.get_clean_version(pkg.version), upstream_version) == -1 - if UPDATE_PACKAGE_FILES && !pkg.name[/#{CREW_AUTOMATIC_VERSION_UPDATE_EXCLUSION_REGEX}/] + if UPDATE_PACKAGE_FILES && !pkg.name[/#{CREW_AUTOMATIC_VERSION_UPDATE_EXCLUSION_REGEX}/] && updatable_pkg[pkg.name.to_sym] file = File.read(filename) if file.sub!(PackageUtils.get_clean_version(pkg.version), upstream_version.chomp).nil? versions_updated[pkg.name.to_sym] = false