release_esoctl.yml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. name: Create Release for esoctl
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. version:
  6. description: 'version to release, e.g. v0.1.0-esoctl'
  7. required: true
  8. default: 'v0.1.0-esoctl'
  9. source_ref:
  10. description: 'source ref to publish from. E.g.: main or release-x.y'
  11. required: true
  12. default: 'main'
  13. # this is required for security check even though we immediately set it to
  14. # write in the release job.
  15. permissions:
  16. contents: read
  17. jobs:
  18. release:
  19. name: Create Release for esoctl
  20. runs-on: ubuntu-latest
  21. permissions:
  22. contents: write # for publishing the release
  23. steps:
  24. - uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
  25. with:
  26. egress-policy: audit
  27. - name: Checkout
  28. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  29. with:
  30. fetch-depth: 0
  31. ref: ${{ github.event.inputs.source_ref }}
  32. - name: Setup Go
  33. uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
  34. id: setup-go
  35. with:
  36. go-version-file: "go.mod"
  37. - name: Download Go modules
  38. if: ${{ steps.setup-go.outputs.cache-hit != 'true' }}
  39. run: go mod download
  40. - name: Install Syft
  41. uses: anchore/sbom-action/download-syft@cee1b8e05ae5b2593a75e197229729eabaa9f8ec # v0.20.2
  42. - name: Import GPG key
  43. id: import_gpg
  44. uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0
  45. with:
  46. gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
  47. passphrase: ${{ secrets.GPG_PASSPHRASE }}
  48. - name: Check if Tag Exists
  49. id: check_tag
  50. run: |
  51. if git rev-parse "${{ github.event.inputs.version }}" >/dev/null 2>&1; then
  52. echo "Tag exists."
  53. exit 1
  54. fi
  55. - name: Create Tag if Not Exists
  56. if: success()
  57. run: |
  58. TAG="${{ github.event.inputs.version }}"
  59. git tag $TAG
  60. git push origin $TAG
  61. - name: Run GoReleaser
  62. uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
  63. with:
  64. version: '~> v2'
  65. args: release --clean
  66. workdir: cmd/esoctl
  67. env:
  68. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  69. GORELEASER_CURRENT_TAG: ${{ github.event.inputs.version }}
  70. GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}