release.yaml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. on:
  2. push:
  3. tags:
  4. - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
  5. name: Create release w/ binaries and docker image
  6. jobs:
  7. docker-build-push:
  8. runs-on: ubuntu-latest
  9. steps:
  10. - name: Get tag name
  11. id: tag_name
  12. run: |
  13. tag=${GITHUB_TAG/refs\/tags\//}
  14. echo ::set-output name=tag::$tag
  15. env:
  16. GITHUB_TAG: ${{ github.ref }}
  17. - name: Checkout
  18. uses: actions/checkout@v2.3.4
  19. - name: Setup docker
  20. uses: docker/login-action@v1
  21. with:
  22. username: ${{ secrets.DOCKERHUB_USERNAME }}
  23. password: ${{ secrets.DOCKERHUB_TOKEN }}
  24. - name: Write Dashboard Environment Variables
  25. run: |
  26. cat >./dashboard/.env <<EOL
  27. NODE_ENV=production
  28. API_SERVER=dashboard.getporter.dev
  29. FULLSTORY_ORG_ID=${{secrets.FULLSTORY_ORG_ID}}
  30. DISCORD_KEY=${{secrets.DISCORD_KEY}}
  31. DISCORD_CID=${{secrets.DISCORD_CID}}
  32. FEEDBACK_ENDPOINT=${{secrets.FEEDBACK_ENDPOINT}}
  33. EOL
  34. cat ./dashboard/.env
  35. - name: Build
  36. run: |
  37. DOCKER_BUILDKIT=1 docker build . -t porter1/porter:${{steps.tag_name.outputs.tag}} -f ./docker/Dockerfile
  38. - name: Push
  39. run: |
  40. docker push porter1/porter:${{steps.tag_name.outputs.tag}}
  41. build:
  42. name: Build binaries
  43. runs-on: ubuntu-latest
  44. steps:
  45. - name: Get tag name
  46. id: tag_name
  47. run: |
  48. tag=${GITHUB_TAG/refs\/tags\//}
  49. echo ::set-output name=tag::$tag
  50. env:
  51. GITHUB_TAG: ${{ github.ref }}
  52. - name: Checkout code
  53. uses: actions/checkout@v2
  54. - name: Set up Go
  55. uses: actions/setup-go@v2
  56. with:
  57. go-version: 1.15
  58. - name: Write Dashboard Environment Variables
  59. run: |
  60. cat >./dashboard/.env <<EOL
  61. NODE_ENV=production
  62. API_SERVER=dashboard.getporter.dev
  63. FULLSTORY_ORG_ID=${{secrets.FULLSTORY_ORG_ID}}
  64. DISCORD_KEY=${{secrets.DISCORD_KEY}}
  65. DISCORD_CID=${{secrets.DISCORD_CID}}
  66. FEEDBACK_ENDPOINT=${{secrets.FEEDBACK_ENDPOINT}}
  67. POSTHOG_API_KEY=${{secrets.POSTHOG_API_KEY}}
  68. POSTHOG_HOST=${{secrets.POSTHOG_HOST}}
  69. EOL
  70. - name: Build and zip static folder
  71. run: |
  72. mkdir -p ./release/static
  73. cd dashboard
  74. npm i --production=false
  75. npm run build
  76. cd ..
  77. zip --junk-paths ./release/static/static_${{steps.tag_name.outputs.tag}}.zip ./dashboard/build/*
  78. env:
  79. NODE_ENV: production
  80. - name: Build Linux binaries
  81. run: |
  82. go build -ldflags="-w -s -X 'github.com/porter-dev/porter/cli/cmd.Version=${{steps.tag_name.outputs.tag}}'" -a -tags cli -o ./porter ./cli &
  83. go build -ldflags="-w -s -X 'main.Version=${{steps.tag_name.outputs.tag}}'" -a -o ./docker-credential-porter ./cmd/docker-credential-porter/ &
  84. go build -ldflags="-w -s" -a -o ./portersvr ./cmd/app/ &
  85. wait
  86. env:
  87. GOOS: linux
  88. GOARCH: amd64
  89. CGO_ENABLED: 1
  90. # Note: we have to zip all binaries before uploading them as artifacts --
  91. # without this step, the binaries will be uploaded but the file metadata will
  92. # be listed as plaintext after downloading the artifact in a later step
  93. #
  94. # TODO: investigate
  95. - name: Zip Linux binaries
  96. run: |
  97. mkdir -p ./release/linux
  98. zip --junk-paths ./release/linux/porter_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip ./porter
  99. zip --junk-paths ./release/linux/portersvr_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip ./portersvr
  100. zip --junk-paths ./release/linux/docker-credential-porter_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip ./docker-credential-porter
  101. - name: Build and zip Darwin binaries
  102. run: |
  103. docker build . --file ./build/Dockerfile.osx -t osx
  104. docker run \
  105. --mount type=bind,source="$(pwd)"/release,target=/release \
  106. osx:latest ${{steps.tag_name.outputs.tag}}
  107. - name: Build and zip Windows binaries
  108. run: |
  109. docker build . --file ./build/Dockerfile.win -t win
  110. docker run \
  111. --mount type=bind,source="$(pwd)"/release,target=/release \
  112. win:latest ${{steps.tag_name.outputs.tag}}
  113. - name: Upload binaries
  114. uses: actions/upload-artifact@v2
  115. with:
  116. path: ./release
  117. name: binaries
  118. retention-days: 1
  119. notarize:
  120. name: Notarize Darwin binaries
  121. runs-on: macos-latest
  122. needs: build
  123. steps:
  124. - name: Get tag name
  125. id: tag_name
  126. run: |
  127. tag=${GITHUB_TAG/refs\/tags\//}
  128. echo ::set-output name=tag::$tag
  129. env:
  130. GITHUB_TAG: ${{ github.ref }}
  131. - name: Download binaries
  132. uses: actions/download-artifact@v2
  133. with:
  134. name: binaries
  135. path: release/
  136. - name: Unzip Darwin binaries
  137. run: |
  138. unzip ./release/darwin/UNSIGNED_porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  139. unzip ./release/darwin/UNSIGNED_portersvr_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  140. unzip ./release/darwin/UNSIGNED_docker-credential-porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  141. - name: Import Code-Signing Certificates
  142. uses: Apple-Actions/import-codesign-certs@v1
  143. with:
  144. # The certificates in a PKCS12 file encoded as a base64 string
  145. p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
  146. # The password used to import the PKCS12 file.
  147. p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
  148. - name: Install gon via HomeBrew for code signing and app notarization
  149. run: |
  150. brew tap mitchellh/gon
  151. brew install mitchellh/gon/gon
  152. - name: Create a porter.gon.json file
  153. run: |
  154. echo "
  155. {
  156. \"source\": [\"./porter\"],
  157. \"bundle_id\": \"cli.porter\",
  158. \"apple_id\": {
  159. \"password\": \"@env:AC_PASSWORD\"
  160. },
  161. \"sign\": {
  162. \"application_identity\": \"${{ secrets.AC_APPLICATION_IDENTITY }}\"
  163. },
  164. \"zip\": {
  165. \"output_path\": \"./release/darwin/porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip\"
  166. }
  167. }
  168. " > ./porter.gon.json
  169. - name: Create a portersvr.gon.json file
  170. run: |
  171. echo "
  172. {
  173. \"source\": [\"./portersvr\"],
  174. \"bundle_id\": \"cli.portersvr\",
  175. \"apple_id\": {
  176. \"password\": \"@env:AC_PASSWORD\"
  177. },
  178. \"sign\": {
  179. \"application_identity\": \"${{ secrets.AC_APPLICATION_IDENTITY }}\"
  180. },
  181. \"zip\": {
  182. \"output_path\": \"./release/darwin/portersvr_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip\"
  183. }
  184. }
  185. " > ./portersvr.gon.json
  186. - name: Create a docker-credential-porter.gon.json file
  187. run: |
  188. echo "
  189. {
  190. \"source\": [\"./docker-credential-porter\"],
  191. \"bundle_id\": \"cli.docker-credential-porter\",
  192. \"apple_id\": {
  193. \"password\": \"@env:AC_PASSWORD\"
  194. },
  195. \"sign\": {
  196. \"application_identity\": \"${{ secrets.AC_APPLICATION_IDENTITY }}\"
  197. },
  198. \"zip\": {
  199. \"output_path\": \"./release/darwin/docker-credential-porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip\"
  200. }
  201. }
  202. " > ./docker-credential-porter.gon.json
  203. - name: Sign the mac binaries with Gon
  204. env:
  205. AC_USERNAME: ${{ secrets.AC_USERNAME }}
  206. AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
  207. run: |
  208. gon ./porter.gon.json &
  209. gon ./portersvr.gon.json &
  210. gon ./docker-credential-porter.gon.json &
  211. wait
  212. - name: Upload binaries
  213. uses: actions/upload-artifact@v2
  214. with:
  215. path: ./release
  216. name: binaries
  217. retention-days: 1
  218. release:
  219. name: Zip binaries, create release and upload assets
  220. runs-on: ubuntu-latest
  221. needs: notarize
  222. steps:
  223. - name: Get tag name
  224. id: tag_name
  225. run: |
  226. tag=${GITHUB_TAG/refs\/tags\//}
  227. echo ::set-output name=tag::$tag
  228. env:
  229. GITHUB_TAG: ${{ github.ref }}
  230. - name: Download binaries
  231. uses: actions/download-artifact@v2
  232. with:
  233. name: binaries
  234. path: release/
  235. - name: Create Release
  236. id: create_release
  237. uses: actions/create-release@v1
  238. env:
  239. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  240. with:
  241. tag_name: ${{ github.ref }}
  242. release_name: Release ${{ github.ref }}
  243. draft: false
  244. prerelease: true
  245. - name: Upload Linux CLI Release Asset
  246. id: upload-linux-cli-release-asset
  247. uses: actions/upload-release-asset@v1
  248. env:
  249. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  250. GITHUB_TAG: ${{ github.ref }}
  251. with:
  252. upload_url: ${{ steps.create_release.outputs.upload_url }}
  253. asset_path: ./release/linux/porter_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip
  254. asset_name: porter_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip
  255. asset_content_type: application/zip
  256. - name: Upload Linux Server Release Asset
  257. id: upload-linux-server-release-asset
  258. uses: actions/upload-release-asset@v1
  259. env:
  260. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  261. GITHUB_TAG: ${{ github.ref }}
  262. with:
  263. upload_url: ${{ steps.create_release.outputs.upload_url }}
  264. asset_path: ./release/linux/portersvr_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip
  265. asset_name: portersvr_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip
  266. asset_content_type: application/zip
  267. - name: Upload Linux Docker Credential Release Asset
  268. id: upload-linux-docker-cred-release-asset
  269. uses: actions/upload-release-asset@v1
  270. env:
  271. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  272. GITHUB_TAG: ${{ github.ref }}
  273. with:
  274. upload_url: ${{ steps.create_release.outputs.upload_url }}
  275. asset_path: ./release/linux/docker-credential-porter_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip
  276. asset_name: docker-credential-porter_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip
  277. asset_content_type: application/zip
  278. - name: Upload Darwin CLI Release Asset
  279. id: upload-darwin-cli-release-asset
  280. uses: actions/upload-release-asset@v1
  281. env:
  282. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  283. GITHUB_TAG: ${{ github.ref }}
  284. with:
  285. upload_url: ${{ steps.create_release.outputs.upload_url }}
  286. asset_path: ./release/darwin/porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  287. asset_name: porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  288. asset_content_type: application/zip
  289. - name: Upload Darwin Server Release Asset
  290. id: upload-darwin-server-release-asset
  291. uses: actions/upload-release-asset@v1
  292. env:
  293. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  294. GITHUB_TAG: ${{ github.ref }}
  295. with:
  296. upload_url: ${{ steps.create_release.outputs.upload_url }}
  297. asset_path: ./release/darwin/portersvr_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  298. asset_name: portersvr_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  299. asset_content_type: application/zip
  300. - name: Upload Darwin Docker Credential Release Asset
  301. id: upload-darwin-docker-cred-release-asset
  302. uses: actions/upload-release-asset@v1
  303. env:
  304. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  305. GITHUB_TAG: ${{ github.ref }}
  306. with:
  307. upload_url: ${{ steps.create_release.outputs.upload_url }}
  308. asset_path: ./release/darwin/docker-credential-porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  309. asset_name: docker-credential-porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  310. asset_content_type: application/zip
  311. - name: Upload Windows CLI Release Asset
  312. id: upload-windows-cli-release-asset
  313. uses: actions/upload-release-asset@v1
  314. env:
  315. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  316. GITHUB_TAG: ${{ github.ref }}
  317. with:
  318. upload_url: ${{ steps.create_release.outputs.upload_url }}
  319. asset_path: ./release/windows/porter_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip
  320. asset_name: porter_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip
  321. asset_content_type: application/zip
  322. - name: Upload Windows Server Release Asset
  323. id: upload-windows-server-release-asset
  324. uses: actions/upload-release-asset@v1
  325. env:
  326. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  327. GITHUB_TAG: ${{ github.ref }}
  328. with:
  329. upload_url: ${{ steps.create_release.outputs.upload_url }}
  330. asset_path: ./release/windows/portersvr_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip
  331. asset_name: portersvr_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip
  332. asset_content_type: application/zip
  333. - name: Upload Windows Docker Credential Release Asset
  334. id: upload-windows-docker-cred-release-asset
  335. uses: actions/upload-release-asset@v1
  336. env:
  337. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  338. GITHUB_TAG: ${{ github.ref }}
  339. with:
  340. upload_url: ${{ steps.create_release.outputs.upload_url }}
  341. asset_path: ./release/windows/docker-credential-porter_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip
  342. asset_name: docker-credential-porter_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip
  343. asset_content_type: application/zip
  344. - name: Upload Static Release Asset
  345. id: upload-static-release-asset
  346. uses: actions/upload-release-asset@v1
  347. env:
  348. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  349. GITHUB_TAG: ${{ github.ref }}
  350. with:
  351. upload_url: ${{ steps.create_release.outputs.upload_url }}
  352. asset_path: ./release/static/static_${{steps.tag_name.outputs.tag}}.zip
  353. asset_name: static_${{steps.tag_name.outputs.tag}}.zip
  354. asset_content_type: application/zip