diff --git a/.github/workflows/spdx.yml b/.github/workflows/spdx.yml index 1126ced451eb8f1a4a2a5b73e0492dc6b2ca6bcc..35972a5ac0e5a9cdcbf85fcb17369b1353478774 100644 --- a/.github/workflows/spdx.yml +++ b/.github/workflows/spdx.yml @@ -1,4 +1,4 @@ -name: Update license data +name: Update SPDX license data on: push: paths: @@ -19,17 +19,33 @@ jobs: with: username: BrewTestBot - - name: Update license data + - name: Update SPDX license data + id: update env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | cd "$GITHUB_WORKSPACE/Library/Homebrew" - if brew update-license-data --commit --fail-if-not-changed; then - SPDX_VERSION=$(jq -er .licenseListVersion data/spdx/spdx_licenses.json) - if ! git ls-remote --exit-code --heads origin "spdx-$SPDX_VERSION"; then - git checkout -b "spdx-$SPDX_VERSION" - git push origin "spdx-$SPDX_VERSION" - hub pull-request -m "$(git log -1 --format='%s')" + + if brew update-license-data --fail-if-not-changed; then + if ! git ls-remote --exit-code --heads origin spdx-update; then + git checkout -B spdx-update + git commit -am "spdx: update license data." -m "Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/blob/master/.github/workflows/spdx.yml)." + echo "::set-output name=committed::true" fi fi + + - name: Push commits + if: steps.update.outputs.committed == 'true' + uses: Homebrew/actions/git-try-push@master + with: + token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} + branch: spdx-update + + - name: Open a pull request + if: steps.update.outputs.committed == 'true' + run: | + cd "$GITHUB_WORKSPACE/Library/Homebrew" + hub pull-request --no-edit + env: + GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} diff --git a/.github/workflows/tapioca-update.yml b/.github/workflows/tapioca-update.yml deleted file mode 100644 index 5c76ba4060410c4e8b9deb845258ef2386be5055..0000000000000000000000000000000000000000 --- a/.github/workflows/tapioca-update.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Tapioca Update -on: - push: - paths: - - .github/workflows/tapioca-update.yml - schedule: - - cron: '0 0 */3 * *' # every three days -env: - HOMEBREW_SORBET: 1 -jobs: - update-tapioca: - if: github.repository == 'Homebrew/brew' - runs-on: ubuntu-latest - steps: - - name: Set up Homebrew - id: set-up-homebrew - uses: Homebrew/actions/setup-homebrew@master - - - name: Configure Git user - uses: Homebrew/actions/git-user-config@master - with: - username: BrewTestBot - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.6.3 - - - name: Update Tapioca Definitions - run: | - cd "$GITHUB_WORKSPACE/Library/Homebrew" - bundle install - bundle exec tapioca sync --exclude json - bundle exec srb rbi hidden-definitions - if ! git diff --exit-code -- sorbet; then - BRANCH="tapioca-update" - if ! git ls-remote --exit-code --heads origin "$BRANCH"; then - git checkout -b "$BRANCH" - git commit -am "sorbet: Update gem RBI files using Tapioca - - Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/actions?query=workflow%3A%22Tapioca+Update%22)." - fi - fi - - - name: Push commits - uses: Homebrew/actions/git-try-push@master - with: - token: ${{ secrets.GITHUB_TOKEN }} - branch: tapioca-update - directory: Library/Homebrew/ - - - name: Open a PR - env: - GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} - run: | - cd "$GITHUB_WORKSPACE/Library/Homebrew" - hub pull-request -m "$(git log -1 --format='%s%n%n%b')" diff --git a/.github/workflows/tapioca.yml b/.github/workflows/tapioca.yml new file mode 100644 index 0000000000000000000000000000000000000000..6d228918fed742ca90c533da013becaf5d78e577 --- /dev/null +++ b/.github/workflows/tapioca.yml @@ -0,0 +1,63 @@ +name: Update Tapioca definitions +on: + push: + paths: + - .github/workflows/tapioca.yml + schedule: + - cron: '0 */12 * * *' +jobs: + tapioca: + if: github.repository == 'Homebrew/brew' + runs-on: ubuntu-latest + steps: + - name: Set up Homebrew + id: set-up-homebrew + uses: Homebrew/actions/setup-homebrew@master + + - name: Configure Git user + uses: Homebrew/actions/git-user-config@master + with: + username: BrewTestBot + + # TODO: remove with `brew typecheck` + - name: Set up Ruby + uses: actions/setup-ruby@main + with: + ruby-version: '2.6' + - name: Install RubyGems + run: | + cd "$GITHUB_WORKSPACE/Library/Homebrew" + gem install bundler -v "~>1" + bundle install --jobs 4 --retry 3 + + - name: Update Tapioca definitions + id: update + run: | + cd "$GITHUB_WORKSPACE/Library/Homebrew" + + # TODO: replace with `brew typecheck` + bundle exec tapioca sync --exclude json + bundle exec srb rbi hidden-definitions + + git checkout -B tapioca-update + if ! git diff --exit-code -- sorbet; then + if ! git ls-remote --exit-code --heads origin tapioca-update; then + git commit -am "sorbet: update RBI files using Tapioca." -m "Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/blob/master/.github/workflows/tapioca.yml)." + echo "::set-output name=committed::true" + fi + fi + + - name: Push commits + if: steps.update.outputs.committed == 'true' + uses: Homebrew/actions/git-try-push@master + with: + token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} + branch: tapioca-update + + - name: Open a pull request + if: steps.update.outputs.committed == 'true' + run: | + cd "$GITHUB_WORKSPACE/Library/Homebrew" + hub pull-request --no-edit + env: + GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} diff --git a/Library/Homebrew/dev-cmd/update-license-data.rb b/Library/Homebrew/dev-cmd/update-license-data.rb index dae194f907acc5900392e87e86032db4140f53c4..f22b836239b50d6c0dcdd84430abe860a183c864 100644 --- a/Library/Homebrew/dev-cmd/update-license-data.rb +++ b/Library/Homebrew/dev-cmd/update-license-data.rb @@ -16,8 +16,6 @@ module Homebrew switch "--fail-if-not-changed", description: "Return a failing status code if current license data's version is the same as " \ "the upstream. This can be used to notify CI when the SPDX license data is out of date." - switch "--commit", - description: "Commit changes to the SPDX license data." max_named 0 end end @@ -27,14 +25,8 @@ module Homebrew ohai "Updating SPDX license data..." SPDX.download_latest_license_data! + return unless args.fail_if_not_changed? - Homebrew.failed = system("git", "diff", "--stat", "--exit-code", SPDX::DATA_PATH) if args.fail_if_not_changed? - - return unless args.commit? - - ohai "git add" - safe_system "git", "add", SPDX::DATA_PATH - ohai "git commit" - system "git", "commit", "--message", "spdx license data: update to #{SPDX.latest_tag}" + Homebrew.failed = system("git", "diff", "--stat", "--exit-code", SPDX::DATA_PATH) end end diff --git a/docs/Manpage.md b/docs/Manpage.md index 3cef1f11406a528b646f82e1e37d396e0c6fd910..70852d0a7ab956a902e8ee4dc1a4ca3268e973dc 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -1198,8 +1198,6 @@ working directory. * `--fail-if-not-changed`: Return a failing status code if current license data's version is the same as the upstream. This can be used to notify CI when the SPDX license data is out of date. -* `--commit`: - Commit changes to the SPDX license data. ### `update-python-resources` [*`options`*] *`formula`* diff --git a/manpages/brew.1 b/manpages/brew.1 index 1434de7a4be5616931e9321f83b87e444329242b..3bfdf2426f8382047685d6b631541d0bdc0fb793 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1636,10 +1636,6 @@ Update SPDX license data in the Homebrew repository\. \fB\-\-fail\-if\-not\-changed\fR Return a failing status code if current license data\'s version is the same as the upstream\. This can be used to notify CI when the SPDX license data is out of date\. . -.TP -\fB\-\-commit\fR -Commit changes to the SPDX license data\. -. .SS "\fBupdate\-python\-resources\fR [\fIoptions\fR] \fIformula\fR" Update versions for PyPI resource blocks in \fIformula\fR\. .