diff --git a/.github/workflows/plugin.yaml b/.github/workflows/plugin.yaml index 2ae1fa255d..8301f8d294 100644 --- a/.github/workflows/plugin.yaml +++ b/.github/workflows/plugin.yaml @@ -10,6 +10,7 @@ permissions: jobs: release-plugin: runs-on: ubuntu-latest + if: ${{ startsWith(github.ref, 'refs/tags/controller-') }} steps: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -25,26 +26,30 @@ jobs: go-version: ${{ env.GOLANG_VERSION }} check-latest: true - - name: Run GoReleaser Snapshot - if: ${{ ! startsWith(github.ref, 'refs/tags/') }} + - name: Set a SemVer tag for goreleaser + run: echo "GORELEASER_CURRENT_TAG=${{ github.ref }}" | sed 's/refs\/tags\/controller-//' >> $GITHUB_ENV + + # GoReleaser requires a SemVer tag to be present in the git repository + - name: Create a local SemVer tag + run: git tag "${{ env.GORELEASER_CURRENT_TAG }}" + + - name: Run GoReleaser uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0 with: version: "~> v2" - args: release --snapshot --clean + args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GORELEASER_CURRENT_TAG: ${{ env.GORELEASER_CURRENT_TAG }} - - name: Run GoReleaser - if: ${{ startsWith(github.ref, 'refs/tags/') }} - uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0 + - name: Upload artifacts to release + uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1 with: - version: "~> v2" - args: release --clean + files: dist/kubectl-ingress-nginx_* env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Update new version in krew-index - if: ${{ startsWith(github.ref, 'refs/tags/') }} uses: rajatjindal/krew-release-bot@3d9faef30a82761d610544f62afddca00993eef9 # v0.0.47 with: - krew_template_file: cmd/plugin/krew.yaml + krew_template_file: dist/krew/ingress-nginx.yaml diff --git a/.gitignore b/.gitignore index 5eac1a800c..693afad691 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,6 @@ cmd/plugin/release/LICENSE tmp/ test/junitreports/ tests/__snapshot__ + +# goreleaser artifacts +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml index a0ef6eb3d2..3894b04248 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,8 +1,11 @@ +version: 2 + project_name: ingress-nginx + release: - github: - owner: kubernetes - name: ingress-nginx + # Disable uploading release assets to GitHub as it requires SemVer tags + disable: true + builds: - id: ingress-nginx goos: @@ -21,9 +24,21 @@ builds: -s -w -X k8s.io/ingress-nginx/version.COMMIT={{ .Commit }} -X k8s.io/ingress-nginx/version.RELEASE={{ .Tag }} + archives: - id: ingress-nginx - builds: + ids: - ingress-nginx name_template: "kubectl-{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}" - format: tar.gz + formats: + - tar.gz + +checksum: + name_template: "kubectl-{{ .ProjectName }}_checksums.txt" + +krews: + - skip_upload: true + homepage: "https://kubernetes.github.io/ingress-nginx/kubectl-plugin/" + description: "The official kubectl plugin for ingress-nginx." + short_description: "Interact with ingress-nginx" + url_template: "http://github.com/kubernetes/ingress-nginx/releases/download/controller-{{ .Tag }}/{{ .ArtifactName }}" diff --git a/cmd/plugin/krew.yaml b/cmd/plugin/krew.yaml deleted file mode 100644 index 0ef537d342..0000000000 --- a/cmd/plugin/krew.yaml +++ /dev/null @@ -1,41 +0,0 @@ -apiVersion: krew.googlecontainertools.github.com/v1alpha2 -kind: Plugin -metadata: - name: ingress-nginx -spec: - shortDescription: Interact with ingress-nginx - description: | - The official kubectl plugin for ingress-nginx. - version: {{ .TagName }} - homepage: https://kubernetes.github.io/ingress-nginx/kubectl-plugin/ - platforms: - - selector: - matchLabels: - os: darwin - arch: arm64 - {{addURIAndSha "https://github.com/kubernetes/ingress-nginx/releases/download/{{ .TagName }}/kubectl-ingress-nginx_darwin_arm64.tar.gz" .TagName }} - bin: kubectl-ingress-nginx - - selector: - matchLabels: - os: darwin - arch: amd64 - {{addURIAndSha "https://github.com/kubernetes/ingress-nginx/releases/download/{{ .TagName }}/kubectl-ingress-nginx_darwin_amd64.tar.gz" .TagName }} - bin: kubectl-ingress-nginx - - selector: - matchLabels: - os: linux - arch: amd64 - {{addURIAndSha "https://github.com/kubernetes/ingress-nginx/releases/download/{{ .TagName }}/kubectl-ingress-nginx_linux_amd64.tar.gz" .TagName }} - bin: kubectl-ingress-nginx - - selector: - matchLabels: - os: linux - arch: arm64 - {{addURIAndSha "https://github.com/kubernetes/ingress-nginx/releases/download/{{ .TagName }}/kubectl-ingress-nginx_linux_arm64.tar.gz" .TagName }} - bin: kubectl-ingress-nginx - - selector: - matchLabels: - os: windows - arch: amd64 - {{addURIAndSha "https://github.com/kubernetes/ingress-nginx/releases/download/{{ .TagName }}/kubectl-ingress-nginx_windows_amd64.tar.gz" .TagName }} - bin: kubectl-ingress-nginx.exe