release.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. name: Create Release
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. version:
  6. description: 'version to release, e.g. v1.5.13'
  7. required: true
  8. default: 'v0.1.0'
  9. source_ref:
  10. description: 'source ref to publish from. E.g.: main or release-x.y'
  11. required: true
  12. default: 'main'
  13. env:
  14. IMAGE_NAME: ghcr.io/${{ github.repository }}
  15. permissions:
  16. contents: read
  17. jobs:
  18. check-docs-for-release:
  19. name: Check Docs for release
  20. runs-on: ubuntu-latest
  21. permissions:
  22. contents: read
  23. steps:
  24. - name: Harden the runner (Audit all outbound calls)
  25. uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
  26. with:
  27. egress-policy: audit
  28. - name: Checkout
  29. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  30. with:
  31. fetch-depth: 0
  32. ref: ${{ github.event.inputs.source_ref }}
  33. - name: check-docs
  34. run: |
  35. DOCS_VERSION=${{ github.event.inputs.version }} make docs.check
  36. release:
  37. name: Create Release
  38. runs-on: ubuntu-latest
  39. permissions:
  40. contents: write # to create a release and push new docs
  41. steps:
  42. - name: Harden the runner (Audit all outbound calls)
  43. uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
  44. with:
  45. egress-policy: audit
  46. - name: Checkout
  47. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  48. with:
  49. fetch-depth: 0
  50. ref: ${{ github.event.inputs.source_ref }}
  51. - name: Create Release
  52. uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2
  53. with:
  54. tag_name: ${{ github.event.inputs.version }}
  55. target_commitish: ${{ github.event.inputs.source_ref }}
  56. generate_release_notes: true
  57. body: |
  58. Image: `${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}`
  59. Image: `${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}-ubi`
  60. Image: `${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}-ubi-boringssl`
  61. env:
  62. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  63. - name: Configure Git
  64. run: |
  65. git config user.name "$GITHUB_ACTOR"
  66. git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
  67. - name: Update Docs
  68. if: github.ref == 'refs/heads/main'
  69. run: make docs.publish DOCS_VERSION=${{ github.event.inputs.version }} DOCS_ALIAS=latest
  70. env:
  71. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  72. promote:
  73. name: Promote Container Image
  74. runs-on: ubuntu-latest
  75. strategy:
  76. matrix:
  77. include:
  78. - tag_suffix: "" # distroless image
  79. - tag_suffix: "-ubi" # ubi image
  80. - tag_suffix: "-ubi-boringssl" # ubi image
  81. permissions:
  82. contents: write #to update the github release
  83. id-token: write #for keyless sign
  84. packages: write #to update packages with added SBOMs.
  85. env:
  86. SOURCE_TAG: ${{ github.event.inputs.source_ref }}${{ matrix.tag_suffix }}
  87. RELEASE_TAG: ${{ github.event.inputs.version }}${{ matrix.tag_suffix }}
  88. steps:
  89. - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
  90. with:
  91. egress-policy: audit
  92. - name: Checkout
  93. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  94. with:
  95. fetch-depth: 0
  96. - name: Setup Go
  97. uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
  98. id: setup-go
  99. with:
  100. go-version-file: "go.mod"
  101. - name: Download Go modules
  102. if: ${{ steps.setup-go.outputs.cache-hit != 'true' }}
  103. run: go mod download
  104. - name: Login to Docker
  105. uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
  106. with:
  107. registry: ghcr.io
  108. username: ${{ github.actor }}
  109. password: ${{ secrets.GITHUB_TOKEN }}
  110. - name: Promote Container Image
  111. run: make docker.promote
  112. - name: Build release manifests
  113. run: |
  114. # temporarily patch the version so we generate manifests with the new version
  115. yq e -i '.version = "${{ github.event.inputs.version }}"' ./deploy/charts/external-secrets/Chart.yaml
  116. yq e -i '.appVersion = "${{ github.event.inputs.version }}"' ./deploy/charts/external-secrets/Chart.yaml
  117. make manifests
  118. - name: Sign promoted image
  119. id: sign
  120. uses: ./.github/actions/sign
  121. with:
  122. image-name: ${{ env.IMAGE_NAME }}
  123. image-tag: ${{ env.RELEASE_TAG }}
  124. - name: Update Release
  125. uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2
  126. with:
  127. tag_name: ${{ github.event.inputs.version }}
  128. files: |
  129. provenance.${{ env.RELEASE_TAG }}.intoto.jsonl
  130. sbom.${{ env.RELEASE_TAG }}.spdx.json
  131. bin/deploy/manifests/external-secrets.yaml
  132. env:
  133. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"