release_esoctl.yml 2.2 KB

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