release.yml 5.8 KB

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