release.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. name: Release
  2. on:
  3. release:
  4. types: [created]
  5. env:
  6. REGISTRY: ghcr.io
  7. IMAGE_NAME: ${{ github.repository }}
  8. jobs:
  9. build:
  10. runs-on: ubuntu-latest
  11. permissions:
  12. contents: write
  13. packages: write
  14. steps:
  15. - uses: actions/checkout@v4
  16. - uses: docker/setup-qemu-action@v3
  17. - uses: docker/setup-buildx-action@v3
  18. - uses: docker/login-action@v3
  19. with:
  20. registry: ${{ env.REGISTRY }}
  21. username: ${{ github.actor }}
  22. password: ${{ secrets.GITHUB_TOKEN }}
  23. - uses: docker/metadata-action@v5
  24. id: meta
  25. with:
  26. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  27. tags: |
  28. type=ref,event=branch
  29. type=ref,event=pr
  30. type=semver,pattern={{version}}
  31. - uses: docker/build-push-action@v5
  32. with:
  33. context: .
  34. platforms: linux/amd64,linux/arm64
  35. push: true
  36. tags: ${{ steps.meta.outputs.tags }}
  37. labels: ${{ steps.meta.outputs.labels }}
  38. build-args: |
  39. VERSION=${{ steps.meta.outputs.version }}
  40. - name: extract amd64 binary from the image
  41. run: |
  42. docker create --platform linux/amd64 --name amd64 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }} &&
  43. docker cp amd64:/usr/bin/coroot-node-agent /tmp/coroot-node-agent-amd64
  44. - name: extract arm64 binary from the image
  45. run: |
  46. docker create --platform linux/arm64 --name arm64 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }} &&
  47. docker cp arm64:/usr/bin/coroot-node-agent /tmp/coroot-node-agent-arm64
  48. - name: upload amd64 binary
  49. uses: actions/upload-release-asset@v1
  50. env:
  51. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  52. with:
  53. upload_url: ${{ github.event.release.upload_url }}
  54. asset_path: /tmp/coroot-node-agent-amd64
  55. asset_name: coroot-node-agent-amd64
  56. asset_content_type: application/octet-stream
  57. - name: upload arm64 binary
  58. uses: actions/upload-release-asset@v1
  59. env:
  60. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  61. with:
  62. upload_url: ${{ github.event.release.upload_url }}
  63. asset_path: /tmp/coroot-node-agent-arm64
  64. asset_name: coroot-node-agent-arm64
  65. asset_content_type: application/octet-stream
  66. - uses: actions/github-script@v7
  67. env:
  68. RELEASE_ID: ${{ github.event.release.id }}
  69. with:
  70. script: |
  71. const { RELEASE_ID } = process.env
  72. github.rest.repos.updateRelease({
  73. owner: context.repo.owner,
  74. repo: context.repo.repo,
  75. release_id: `${RELEASE_ID}`,
  76. prerelease: false,
  77. make_latest: true
  78. })