release.yaml 15 KB

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