release_esoctl.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. - name: Checkout
  25. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  26. with:
  27. fetch-depth: 0
  28. ref: ${{ github.event.inputs.source_ref }}
  29. - name: Setup Go
  30. uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
  31. id: setup-go
  32. with:
  33. go-version-file: "go.mod"
  34. - name: Download Go modules
  35. if: ${{ steps.setup-go.outputs.cache-hit != 'true' }}
  36. run: go mod download
  37. - name: Install Syft
  38. uses: anchore/sbom-action/download-syft@f325610c9f50a54015d37c8d16cb3b0e2c8f4de0 # v0.18.0
  39. - name: Import GPG key
  40. id: import_gpg
  41. uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0
  42. with:
  43. gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
  44. passphrase: ${{ secrets.GPG_PASSPHRASE }}
  45. - name: Check if Tag Exists
  46. id: check_tag
  47. run: |
  48. if git rev-parse "${{ github.event.inputs.version }}" >/dev/null 2>&1; then
  49. echo "Tag exists."
  50. exit 1
  51. fi
  52. - name: Create Tag if Not Exists
  53. if: success()
  54. run: |
  55. TAG="${{ github.event.inputs.version }}"
  56. git tag $TAG
  57. git push origin $TAG
  58. - name: Run GoReleaser
  59. uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
  60. with:
  61. version: '~> v2'
  62. args: release --clean
  63. workdir: cmd/esoctl
  64. env:
  65. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  66. GORELEASER_CURRENT_TAG: ${{ github.event.inputs.version }}
  67. GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}