prerelease.yaml 16 KB

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