reuse_latest_release_binaries.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. name: reuse binaries of the latest release if no more modification on the_path since last_commit
  4. on:
  5. workflow_call:
  6. inputs:
  7. binary_name_stem:
  8. type: string
  9. required: true
  10. last_commit:
  11. type: string
  12. required: true
  13. the_path:
  14. type: string
  15. required: true
  16. upload_url:
  17. description: upload binary assets to the URL of release
  18. type: string
  19. required: true
  20. outputs:
  21. result:
  22. value: ${{ jobs.build.outputs.result }}
  23. permissions:
  24. contents: read
  25. jobs:
  26. reuse:
  27. runs-on: ubuntu-latest
  28. outputs:
  29. result: ${{ steps.try_reuse.outputs.result }}
  30. permissions:
  31. contents: write # for creating realease and uploading release artifacts
  32. steps:
  33. - uses: actions/checkout@v4
  34. # Full git history is needed to get a proper list of commits and tags
  35. with:
  36. fetch-depth: 0
  37. - name: try to reuse binaries
  38. id: try_reuse
  39. run: |
  40. echo '::echo::on'
  41. python3 ./.github/scripts/reuse_latest_release_binaries.py \
  42. --binary_name_stem ${{ inputs.binary_name_stem }} \
  43. --last_commit ${{ inputs.last_commit }} \
  44. --the_path ${{ inputs.the_path }} .
  45. ls -lh .
  46. - run: echo ${{ steps.try_reuse.outputs.result }}
  47. - name: upload release tar.gz
  48. if: steps.try_reuse.outputs.result == 'hit'
  49. uses: actions/upload-release-asset@v1
  50. env:
  51. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  52. with:
  53. upload_url: ${{ inputs.upload_url }}
  54. asset_path: ${{ inputs.binary_name_stem }}.tar.gz
  55. asset_name: ${{ inputs.binary_name_stem }}.tar.gz
  56. asset_content_type: application/x-gzip
  57. - name: upload release zip
  58. if: steps.try_reuse.outputs.result == 'hit'
  59. uses: actions/upload-release-asset@v1
  60. env:
  61. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  62. with:
  63. upload_url: ${{ inputs.upload_url }}
  64. asset_path: ${{ inputs.binary_name_stem }}.zip
  65. asset_name: ${{ inputs.binary_name_stem }}.zip
  66. asset_content_type: application/zip