release.yml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. name: Release
  2. on:
  3. push:
  4. # Publish `v1.2.3` tags as releases.
  5. tags:
  6. - v*
  7. jobs:
  8. build:
  9. name: Build Release
  10. strategy:
  11. matrix:
  12. go-version: [1.16.x]
  13. os: [ubuntu-18.04, macos-11, windows-2019]
  14. runs-on: ${{ matrix.os }}
  15. steps:
  16. - name: Install Go
  17. uses: actions/setup-go@v2
  18. with:
  19. go-version: ${{ matrix.go-version }}
  20. - name: Checkout Code
  21. uses: actions/checkout@v2
  22. - uses: actions/cache@v2
  23. with:
  24. # In order:
  25. # * Module download cache
  26. # * Build cache (Linux)
  27. # * Build cache (Mac)
  28. # * Build cache (Windows)
  29. path: |
  30. ~/go/pkg/mod
  31. ~/.cache/go-build
  32. ~/Library/Caches/go-build
  33. %LocalAppData%\go-build
  34. key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
  35. restore-keys: |
  36. ${{ runner.os }}-go-
  37. # ==============================
  38. # Linux/Macos/Windows Build
  39. # ==============================
  40. - name: Build Binary for ${{matrix.os}}
  41. run: make geth
  42. # ==============================
  43. # Upload artifacts
  44. # ==============================
  45. - name: Upload Linux Build
  46. uses: actions/upload-artifact@v2
  47. if: matrix.os == 'ubuntu-18.04'
  48. with:
  49. name: linux
  50. path: ./build/bin/geth
  51. - name: Upload MacOS Build
  52. uses: actions/upload-artifact@v2
  53. if: matrix.os == 'macos-11'
  54. with:
  55. name: macos
  56. path: ./build/bin/geth
  57. - name: Upload Windows Build
  58. uses: actions/upload-artifact@v2
  59. if: matrix.os == 'windows-2019'
  60. with:
  61. name: windows
  62. path: ./build/bin/geth.exe
  63. release:
  64. name: Release
  65. needs: build
  66. runs-on: ubuntu-18.04
  67. steps:
  68. - name: Set Env
  69. run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
  70. - name: Checkout Code
  71. uses: actions/checkout@v2
  72. # ==============================
  73. # Download artifacts
  74. # ==============================
  75. - name: Download Artifacts
  76. uses: actions/download-artifact@v2
  77. with:
  78. name: linux
  79. path: ./linux
  80. - name: Download Artifacts
  81. uses: actions/download-artifact@v2
  82. with:
  83. name: macos
  84. path: ./macos
  85. - name: Download Artifacts
  86. uses: actions/download-artifact@v2
  87. with:
  88. name: windows
  89. path: ./windows
  90. - name: Download Config File
  91. run: |
  92. . ./.github/release.env
  93. echo "mainnet.zip url: $MAINNET_FILE_URL"
  94. echo "testnet.zip url: $TESTNET_FILE_URL"
  95. curl -L $MAINNET_FILE_URL -o ./mainnet.zip
  96. curl -L $TESTNET_FILE_URL -o ./testnet.zip
  97. # ==============================
  98. # Create release
  99. # ==============================
  100. - name: Generate Change Log
  101. id: changelog
  102. run: |
  103. chmod 755 ./.github/generate_change_log.sh
  104. CHANGELOG=$(./.github/generate_change_log.sh ${{ env.RELEASE_VERSION}})
  105. echo "CHANGELOG<<EOF" >> $GITHUB_ENV
  106. echo "$CHANGELOG" >> $GITHUB_ENV
  107. echo "EOF" >> $GITHUB_ENV
  108. - name: Create Release
  109. id: create_release
  110. uses: actions/create-release@latest
  111. env:
  112. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
  113. with:
  114. tag_name: ${{ github.ref }}
  115. release_name: ${{ github.ref }}
  116. body: |
  117. ${{ env.CHANGELOG }}
  118. draft: false
  119. prerelease: false
  120. # Check downloaded files
  121. - run: ls
  122. - name: Upload Release Asset - Linux
  123. uses: actions/upload-release-asset@v1
  124. env:
  125. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  126. with:
  127. upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
  128. asset_path: ./linux/geth
  129. asset_name: geth_linux
  130. asset_content_type: application/octet-stream
  131. - name: Upload Release Asset - MacOS
  132. uses: actions/upload-release-asset@v1
  133. env:
  134. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  135. with:
  136. upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
  137. asset_path: ./macos/geth
  138. asset_name: geth_mac
  139. asset_content_type: application/octet-stream
  140. - name: Upload Release Asset - Windows
  141. uses: actions/upload-release-asset@v1
  142. env:
  143. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  144. with:
  145. upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
  146. asset_path: ./windows/geth.exe
  147. asset_name: geth_windows.exe
  148. asset_content_type: application/octet-stream
  149. - name: Upload Release Asset - MAINNET.ZIP
  150. uses: actions/upload-release-asset@v1
  151. env:
  152. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  153. with:
  154. upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
  155. asset_path: ./mainnet.zip
  156. asset_name: mainnet.zip
  157. asset_content_type: application/zip
  158. - name: Upload Release Asset - TESTNET.ZIP
  159. uses: actions/upload-release-asset@v1
  160. env:
  161. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  162. with:
  163. upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
  164. asset_path: ./testnet.zip
  165. asset_name: testnet.zip
  166. asset_content_type: application/zip