Newer
Older
dub_jkp / .github / workflows / release.yml
  1. # When a release is published, build the assets and upload them
  2. name: Build release assets
  3.  
  4. on:
  5. release:
  6. types:
  7. - published
  8.  
  9. jobs:
  10. # First we define a job with a matrix that will build all relevant assets,
  11. # and collect them in a temporary storage using `actions/upload-artifacts`
  12. build:
  13. name: 'Build artifacts for ${{ github.event.release.tag_name }}'
  14. strategy:
  15. fail-fast: false
  16. matrix:
  17. os: [ macOS-11, ubuntu-20.04, windows-2019 ]
  18. arch: [ x86_64 ]
  19. include:
  20. - { os: windows-2019, arch: i686 }
  21.  
  22. runs-on: ${{ matrix.os }}
  23. steps:
  24. ## Dependencies
  25. - name: '[OSX] Install dependencies'
  26. if: runner.os == 'macOS'
  27. run: |
  28. brew install pkg-config coreutils
  29. echo "PKG_CONFIG_PATH=/usr/local/opt/openssl@1.1/lib/pkgconfig/" >> $GITHUB_ENV
  30. - name: '[Linux] Install dependencies'
  31. if: runner.os == 'Linux'
  32. run: |
  33. sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
  34.  
  35. ## Boileterplate (compiler/repo)
  36. - name: Install compiler
  37. uses: dlang-community/setup-dlang@v1
  38. with:
  39. compiler: ldc-latest
  40. - name: Checkout repository
  41. uses: actions/checkout@v4
  42. with:
  43. ref: ${{ github.event.release.tag_name }}
  44.  
  45. ## Actually build the releases
  46. - name: '[POSIX] Build release'
  47. if: runner.os == 'Linux' || runner.os == 'macOS'
  48. env:
  49. GITVER: ${{ github.event.release.tag_name }}
  50. DMD: "ldmd2"
  51. ARCH_TRIPLE: ${{ matrix.arch }}-${{ runner.os == 'linux' && 'pc-linux' || 'apple-darwin' }}
  52. run: |
  53. ldc2 -run ./build.d -release -mtriple=${ARCH_TRIPLE}
  54. pushd bin
  55. if [ ${{ runner.os }} == 'Linux' ]; then
  56. tar -c -f 'dub-${{ github.event.release.tag_name }}-linux-${{ matrix.arch }}.tar.gz' -v -z --owner=0 --group=0 dub
  57. else
  58. gtar -c -f 'dub-${{ github.event.release.tag_name }}-osx-${{ matrix.arch }}.tar.gz' -v -z --owner=0 --group=0 dub
  59. fi
  60. popd
  61. - name: '[Windows] Build release'
  62. if: runner.os == 'Windows'
  63. env:
  64. GITVER: ${{ github.event.release.tag_name }}
  65. DMD: "ldmd2"
  66. run: |
  67. ldc2 -run ./build.d -release -mtriple=${{ matrix.arch }}-pc-windows-msvc
  68. pushd bin
  69. 7z a dub-${{ github.event.release.tag_name }}-windows-${{ matrix.arch }}.zip dub.exe
  70. popd
  71.  
  72. - name: 'Upload temporary binaries'
  73. uses: actions/upload-artifact@v4
  74. with:
  75. name: dub-release-${{ matrix.os }}-${{ matrix.arch }}
  76. path: |
  77. bin/dub-${{ github.event.release.tag_name }}-*
  78. if-no-files-found: error
  79. retention-days: 1
  80.  
  81. # Uploads collected builds to the release
  82. release:
  83. name: "Update release artifacts"
  84. runs-on: ubuntu-latest
  85. needs:
  86. - build
  87.  
  88. steps:
  89. - name: Download artifacts to release
  90. uses: actions/download-artifact@v4
  91. with:
  92. path: ~/artifacts/
  93.  
  94. - name: List all artifacts included in the release
  95. id: list-artifacts
  96. shell: bash
  97. run: |
  98. set -euox pipefail
  99. ls -aulR ~/artifacts
  100. echo "artifacts_directory=$HOME/artifacts" >> $GITHUB_OUTPUT
  101.  
  102. - name: Update release artifacts
  103. uses: ncipollo/release-action@v1
  104. with:
  105. token: "${{ secrets.GITHUB_TOKEN }}"
  106. tag: ${{ github.event.release.tag_name }}
  107. artifacts: ${{ steps.list-artifacts.outputs.artifacts_directory }}/*/*
  108. # Keep the existing state of the release
  109. allowUpdates: true
  110. artifactErrorsFailBuild: true
  111. omitNameDuringUpdate: true
  112. omitBodyDuringUpdate: true
  113. omitPrereleaseDuringUpdate: true