🎣 Open-Source Phishing Toolkit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
5.8 KiB

  1. name: Build Gophish Release
  2. on:
  3. release:
  4. types: [created]
  5. jobs:
  6. build:
  7. name: Build Binary
  8. runs-on: ${{ matrix.os }}
  9. strategy:
  10. matrix:
  11. os: [windows-latest, ubuntu-latest, macos-latest]
  12. arch: ['386', amd64]
  13. # We sometimes use different verbiage for things (e.g. "darwin"
  14. # for the GOOS build flag and "osx" in the actual release ZIP).
  15. # We need to specify those here.
  16. include:
  17. - os: windows-latest
  18. goos: windows
  19. bin: 'gophish.exe'
  20. releaseos: windows
  21. - os: ubuntu-latest
  22. goos: linux
  23. bin: 'gophish'
  24. releaseos: linux
  25. - os: macos-latest
  26. goos: darwin
  27. bin: 'gophish'
  28. releaseos: osx
  29. # Don't build windows-32bit due to missing MinGW dependencies
  30. # Don't build osx-32bit due to eventual drop in Go support
  31. exclude:
  32. - os: windows-latest
  33. arch: '386'
  34. - os: macos-latest
  35. arch: '386'
  36. steps:
  37. - name: Set up Go
  38. uses: actions/setup-go@v2
  39. with:
  40. go-version: 1.14
  41. - if: matrix.os == 'ubuntu-latest'
  42. run: sudo apt-get update && sudo apt-get install -y gcc-multilib
  43. - if: matrix.arch == '386'
  44. run: echo "::set-env name=RELEASE::gophish-${{ github.event.release.tag_name }}-${{ matrix.releaseos}}-32bit"
  45. - if: matrix.arch == 'amd64'
  46. run: echo "::set-env name=RELEASE::gophish-${{ github.event.release.tag_name}}-${{ matrix.releaseos}}-64bit"
  47. - uses: actions/checkout@v2
  48. - name: Build ${{ matrix.goos }}/${{ matrix.arch }}
  49. run: go build -o ${{ matrix.bin }}
  50. env:
  51. GOOS: ${{ matrix.goos }}
  52. GOARCH: ${{ matrix.arch }}
  53. CGO_ENABLED: 1
  54. - name: Upload to artifacts
  55. uses: actions/upload-artifact@v2
  56. with:
  57. name: ${{ env.RELEASE }}
  58. path: ${{ matrix.bin }}
  59. package:
  60. name: Package Assets
  61. runs-on: ubuntu-latest
  62. needs: build
  63. steps:
  64. - uses: actions/checkout@v2
  65. - uses: actions/download-artifact@v2
  66. with:
  67. path: bin
  68. - name: Package Releases
  69. run: |
  70. mkdir releases;
  71. for RELEASE_DIR in bin/*
  72. do
  73. echo "Creating release $RELEASE_DIR"
  74. for BINARY in $RELEASE_DIR/*
  75. do
  76. cp $BINARY .;
  77. zip -r releases/$(basename $RELEASE_DIR).zip \
  78. $(basename ${BINARY}) \
  79. static/js/dist \
  80. static/js/src/vendor/ckeditor \
  81. static/css/dist \
  82. static/images \
  83. static/font \
  84. static/db \
  85. db \
  86. templates \
  87. README.md \
  88. VERSION \
  89. LICENSE \
  90. config.json;
  91. rm $BINARY;
  92. done
  93. done
  94. - name: Upload to artifacts
  95. uses: actions/upload-artifact@v2
  96. with:
  97. name: releases
  98. path: releases/*.zip
  99. upload:
  100. name: Upload to the Release
  101. runs-on: ubuntu-latest
  102. needs: package
  103. steps:
  104. - uses: actions/download-artifact@v2
  105. with:
  106. name: releases
  107. path: releases/
  108. # I would love to use @actions/upload-release-asset, but they don't
  109. # support wildcards in the asset path. Ref #9, #24, and #47
  110. - name: Upload Archives to Release
  111. env:
  112. UPLOAD_URL: ${{ github.event.release.upload_url }}
  113. API_HEADER: "Accept: application/vnd.github.v3+json"
  114. AUTH_HEADER: "Authorization: token ${{ secrets.GITHUB_TOKEN }}"
  115. run: |
  116. UPLOAD_URL=$(echo -n $UPLOAD_URL | sed s/\{.*//g)
  117. for FILE in releases/*
  118. do
  119. echo "Uploading ${FILE}";
  120. curl \
  121. -H "${API_HEADER}" \
  122. -H "${AUTH_HEADER}" \
  123. -H "Content-Type: $(file -b --mime-type ${FILE})" \
  124. --data-binary "@${FILE}" \
  125. "${UPLOAD_URL}?name=$(basename ${FILE})";
  126. done
  127. - name: Generate SHA256 Hashes
  128. env:
  129. API_HEADER: "Accept: application/vnd.github.v3+json"
  130. AUTH_HEADER: "Authorization: token ${{ secrets.GITHUB_TOKEN }}"
  131. RELEASE_URL: ${{ github.event.release.url }}
  132. run: |
  133. HASH_TABLE="| SHA256 Hash | Filename |"
  134. HASH_TABLE="${HASH_TABLE}\n|-----|-----|\n"
  135. for FILE in releases/*
  136. do
  137. FILENAME=$(basename ${FILE})
  138. HASH=$(sha256sum ${FILE} | cut -d ' ' -f 1)
  139. HASH_TABLE="${HASH_TABLE}|${HASH}|${FILENAME}|\n"
  140. done
  141. echo "${HASH_TABLE}"
  142. curl \
  143. -XPATCH \
  144. -H "${API_HEADER}" \
  145. -H "${AUTH_HEADER}" \
  146. -H "Content-Type: application/json" \
  147. -d "{\"body\": \"${HASH_TABLE}\"}" \
  148. "${RELEASE_URL}";