release.yaml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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. 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 ./docker/Dockerfile
  35. - name: Push
  36. run: |
  37. docker push porter1/porter:${{steps.tag_name.outputs.tag}}
  38. build:
  39. name: Build 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.15
  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 -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: Build and zip Darwin binaries
  94. run: |
  95. docker build . --file ./build/Dockerfile.osx -t osx
  96. docker run \
  97. --mount type=bind,source="$(pwd)"/release,target=/release \
  98. osx:latest ${{steps.tag_name.outputs.tag}}
  99. - name: Build and zip Windows binaries
  100. run: |
  101. docker build . --file ./build/Dockerfile.win -t win
  102. docker run \
  103. --mount type=bind,source="$(pwd)"/release,target=/release \
  104. win:latest ${{steps.tag_name.outputs.tag}}
  105. - name: Upload binaries
  106. uses: actions/upload-artifact@v2
  107. with:
  108. path: ./release
  109. name: binaries
  110. retention-days: 1
  111. notarize:
  112. name: Notarize Darwin binaries
  113. runs-on: macos-latest
  114. needs: build
  115. steps:
  116. - name: Get tag name
  117. id: tag_name
  118. run: |
  119. tag=${GITHUB_TAG/refs\/tags\//}
  120. echo ::set-output name=tag::$tag
  121. env:
  122. GITHUB_TAG: ${{ github.ref }}
  123. - name: Download binaries
  124. uses: actions/download-artifact@v2
  125. with:
  126. name: binaries
  127. path: release/
  128. - name: Unzip Darwin binaries
  129. run: |
  130. unzip ./release/darwin/UNSIGNED_porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  131. unzip ./release/darwin/UNSIGNED_portersvr_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  132. unzip ./release/darwin/UNSIGNED_docker-credential-porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  133. - name: Import Code-Signing Certificates
  134. uses: Apple-Actions/import-codesign-certs@v1
  135. with:
  136. # The certificates in a PKCS12 file encoded as a base64 string
  137. p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
  138. # The password used to import the PKCS12 file.
  139. p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
  140. - name: Install gon via HomeBrew for code signing and app notarization
  141. run: |
  142. brew tap mitchellh/gon
  143. brew install mitchellh/gon/gon
  144. - name: Create a porter.gon.json file
  145. run: |
  146. echo "
  147. {
  148. \"source\": [\"./porter\"],
  149. \"bundle_id\": \"cli.porter\",
  150. \"apple_id\": {
  151. \"password\": \"@env:AC_PASSWORD\"
  152. },
  153. \"sign\": {
  154. \"application_identity\": \"${{ secrets.AC_APPLICATION_IDENTITY }}\"
  155. },
  156. \"zip\": {
  157. \"output_path\": \"./release/darwin/porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip\"
  158. }
  159. }
  160. " > ./porter.gon.json
  161. - name: Create a portersvr.gon.json file
  162. run: |
  163. echo "
  164. {
  165. \"source\": [\"./portersvr\"],
  166. \"bundle_id\": \"cli.portersvr\",
  167. \"apple_id\": {
  168. \"password\": \"@env:AC_PASSWORD\"
  169. },
  170. \"sign\": {
  171. \"application_identity\": \"${{ secrets.AC_APPLICATION_IDENTITY }}\"
  172. },
  173. \"zip\": {
  174. \"output_path\": \"./release/darwin/portersvr_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip\"
  175. }
  176. }
  177. " > ./portersvr.gon.json
  178. - name: Create a docker-credential-porter.gon.json file
  179. run: |
  180. echo "
  181. {
  182. \"source\": [\"./docker-credential-porter\"],
  183. \"bundle_id\": \"cli.docker-credential-porter\",
  184. \"apple_id\": {
  185. \"password\": \"@env:AC_PASSWORD\"
  186. },
  187. \"sign\": {
  188. \"application_identity\": \"${{ secrets.AC_APPLICATION_IDENTITY }}\"
  189. },
  190. \"zip\": {
  191. \"output_path\": \"./release/darwin/docker-credential-porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip\"
  192. }
  193. }
  194. " > ./docker-credential-porter.gon.json
  195. - name: Sign the mac binaries with Gon
  196. env:
  197. AC_USERNAME: ${{ secrets.AC_USERNAME }}
  198. AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
  199. run: |
  200. gon ./porter.gon.json &
  201. gon ./portersvr.gon.json &
  202. gon ./docker-credential-porter.gon.json &
  203. wait
  204. - name: Upload binaries
  205. uses: actions/upload-artifact@v2
  206. with:
  207. path: ./release
  208. name: binaries
  209. retention-days: 1
  210. release:
  211. name: Zip binaries, create release and upload assets
  212. runs-on: ubuntu-latest
  213. needs: notarize
  214. steps:
  215. - name: Get tag name
  216. id: tag_name
  217. run: |
  218. tag=${GITHUB_TAG/refs\/tags\//}
  219. echo ::set-output name=tag::$tag
  220. env:
  221. GITHUB_TAG: ${{ github.ref }}
  222. - name: Download binaries
  223. uses: actions/download-artifact@v2
  224. with:
  225. name: binaries
  226. path: release/
  227. - name: Create Release
  228. id: create_release
  229. uses: actions/create-release@v1
  230. env:
  231. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  232. with:
  233. tag_name: ${{ github.ref }}
  234. release_name: Release ${{ github.ref }}
  235. draft: false
  236. prerelease: true
  237. - name: Upload Linux CLI Release Asset
  238. id: upload-linux-cli-release-asset
  239. uses: actions/upload-release-asset@v1
  240. env:
  241. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  242. GITHUB_TAG: ${{ github.ref }}
  243. with:
  244. upload_url: ${{ steps.create_release.outputs.upload_url }}
  245. asset_path: ./release/linux/porter_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip
  246. asset_name: porter_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip
  247. asset_content_type: application/zip
  248. - name: Upload Linux Server Release Asset
  249. id: upload-linux-server-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/portersvr_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip
  257. asset_name: portersvr_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip
  258. asset_content_type: application/zip
  259. - name: Upload Linux Docker Credential Release Asset
  260. id: upload-linux-docker-cred-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/docker-credential-porter_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip
  268. asset_name: docker-credential-porter_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip
  269. asset_content_type: application/zip
  270. - name: Upload Darwin CLI Release Asset
  271. id: upload-darwin-cli-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/darwin/porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  279. asset_name: porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  280. asset_content_type: application/zip
  281. - name: Upload Darwin Server Release Asset
  282. id: upload-darwin-server-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/portersvr_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  290. asset_name: portersvr_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  291. asset_content_type: application/zip
  292. - name: Upload Darwin Docker Credential Release Asset
  293. id: upload-darwin-docker-cred-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/docker-credential-porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  301. asset_name: docker-credential-porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip
  302. asset_content_type: application/zip
  303. - name: Upload Windows CLI Release Asset
  304. id: upload-windows-cli-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/windows/porter_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip
  312. asset_name: porter_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip
  313. asset_content_type: application/zip
  314. - name: Upload Windows Server Release Asset
  315. id: upload-windows-server-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/portersvr_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip
  323. asset_name: portersvr_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip
  324. asset_content_type: application/zip
  325. - name: Upload Windows Docker Credential Release Asset
  326. id: upload-windows-docker-cred-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/docker-credential-porter_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip
  334. asset_name: docker-credential-porter_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip
  335. asset_content_type: application/zip
  336. - name: Upload Static Release Asset
  337. id: upload-static-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/static/static_${{steps.tag_name.outputs.tag}}.zip
  345. asset_name: static_${{steps.tag_name.outputs.tag}}.zip
  346. asset_content_type: application/zip
  347. build-push-docker-cli:
  348. name: Build a new porter-cli docker image
  349. runs-on: ubuntu-latest
  350. needs: release
  351. steps:
  352. - name: Get tag name
  353. id: tag_name
  354. run: |
  355. tag=${GITHUB_TAG/refs\/tags\//}
  356. echo ::set-output name=tag::$tag
  357. env:
  358. GITHUB_TAG: ${{ github.ref }}
  359. - name: Checkout
  360. uses: actions/checkout@v2.3.4
  361. - name: Configure AWS credentials
  362. uses: aws-actions/configure-aws-credentials@v1
  363. with:
  364. aws-access-key-id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
  365. aws-secret-access-key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
  366. aws-region: us-east-2
  367. - name: Login to ECR public
  368. id: login-ecr
  369. run: |
  370. aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/o1j4x7p4
  371. - name: Build
  372. run: |
  373. docker build ./services/porter_cli_container \
  374. -t public.ecr.aws/o1j4x7p4/porter-cli:${{steps.tag_name.outputs.tag}} \
  375. -t public.ecr.aws/o1j4x7p4/porter-cli:latest \
  376. -f ./services/porter_cli_container/Dockerfile \
  377. --build-arg VERSION=${{steps.tag_name.outputs.tag}}
  378. - name: Push
  379. run: |
  380. docker push public.ecr.aws/o1j4x7p4/porter-cli:${{steps.tag_name.outputs.tag}}
  381. docker push public.ecr.aws/o1j4x7p4/porter-cli:latest