release_esoctl.yml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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'
  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@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
  25. with:
  26. egress-policy: audit
  27. - name: Checkout
  28. uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
  29. with:
  30. fetch-depth: 0
  31. ref: ${{ github.event.inputs.source_ref }}
  32. - name: Setup Go
  33. uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.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@fbfd9c6c189226748411491745178e0c2017392d # v0.20.10
  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. env:
  51. VERSION: ${{ github.event.inputs.version }}
  52. run: |
  53. if git rev-parse "$VERSION" >/dev/null 2>&1; then
  54. echo "Tag exists."
  55. exit 1
  56. fi
  57. - name: Create Tag if Not Exists
  58. if: success()
  59. env:
  60. TAG: ${{ github.event.inputs.version }}
  61. run: |
  62. git tag $TAG
  63. git push origin $TAG
  64. - name: Run GoReleaser
  65. uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
  66. with:
  67. version: '~> v2'
  68. args: release --clean
  69. workdir: cmd/esoctl
  70. env:
  71. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  72. GORELEASER_CURRENT_TAG: ${{ github.event.inputs.version }}
  73. GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}