1
0

action.yml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. name: 'Setup DJGPP toolchain'
  2. description: 'Download DJGPP and setup CMake toolchain'
  3. runs:
  4. using: 'composite'
  5. steps:
  6. - name: 'Calculate variables'
  7. id: calc
  8. shell: sh
  9. run: |
  10. version="12.2.0"
  11. case "${{ runner.os }}-${{ runner.arch }}" in
  12. "Linux-X86")
  13. archive="djgpp-linux32-gcc1220.tar.bz2"
  14. ;;
  15. "Linux-X64")
  16. archive="djgpp-linux64-gcc1220.tar.bz2"
  17. ;;
  18. "macOS-X86" | "macOS-X64" | "macOS-ARM64")
  19. archive="djgpp-osx-gcc1220.tar.bz2"
  20. ;;
  21. "Windows-X86" | "Windows-X64")
  22. archive="djgpp-mingw-gcc1220.zip"
  23. ;;
  24. *)
  25. echo "Unsupported ${{ runner.os }}-${{ runner.arch }}"
  26. exit 1;
  27. ;;
  28. esac
  29. echo "url=https://github.com/andrewwutw/build-djgpp/releases/download/v3.4/${archive}" >> ${GITHUB_OUTPUT}
  30. echo "archive=${archive}" >> ${GITHUB_OUTPUT}
  31. echo "version=${version}" >> ${GITHUB_OUTPUT}
  32. echo "cache-key=${archive}-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}" >> ${GITHUB_OUTPUT}
  33. - name: 'Restore cached ${{ steps.calc.outputs.archive }}'
  34. id: cache-restore
  35. uses: actions/cache/restore@v4
  36. with:
  37. path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
  38. key: ${{ steps.calc.outputs.cache-key }}
  39. - name: 'Download DJGPP ${{ steps.calc.outputs.version }} for ${{ runner.os }} (${{ runner.arch }})'
  40. if: ${{ !steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false' }}
  41. shell: pwsh
  42. run: |
  43. Invoke-WebRequest "${{ steps.calc.outputs.url }}" -OutFile "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
  44. - name: 'Cache ${{ steps.calc.outputs.archive }}'
  45. if: ${{ !steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false' }}
  46. uses: actions/cache/save@v4
  47. with:
  48. path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
  49. key: ${{ steps.calc.outputs.cache-key }}
  50. - name: 'Extract DJGP archive'
  51. shell: pwsh
  52. run: |
  53. $archive = "${{ steps.calc.outputs.archive }}";
  54. if ($archive.EndsWith(".bz2")) {
  55. # Remove ".bz2" suffix
  56. $tar_archive = $archive.Substring(0, $archive.Length - 4)
  57. 7z "-o${{ runner.temp }}" x "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
  58. 7z "-o${{ runner.temp }}" x "${{ runner.temp }}/$tar_archive"
  59. } else {
  60. 7z "-o${{ runner.temp }}" x "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
  61. }
  62. - name: 'Set output variables'
  63. id: final
  64. shell: pwsh
  65. run: |
  66. echo "${{ runner.temp }}/djgpp/bin" >> $env:GITHUB_PATH