From b4fbea2b2def727a100dd1a2ca27a2a7a49ac1a4 Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Thu, 6 Jul 2023 22:16:08 +0200 Subject: [PATCH] fixed go releaser --- .github/workflows/release.yaml | 75 +++++++++++++++++----------------- .goreleaser.yml | 50 +++++++++++------------ 2 files changed, 62 insertions(+), 63 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fc758362f..51f1b9021 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -2,12 +2,11 @@ on: push: # Sequence of patterns matched against refs/tags tags: - - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 name: Create Release jobs: - cli: name: Release the CLI runs-on: ubuntu-latest @@ -16,17 +15,17 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - + - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: 1.18 + go-version: stable - name: GoReleaser - uses: goreleaser/goreleaser-action@v3 + uses: goreleaser/goreleaser-action@v4 with: version: latest - args: release --rm-dist + args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -36,38 +35,38 @@ jobs: runs-on: ubuntu-latest steps: - - name: Set up Go 1.18.x - uses: actions/setup-go@v3 - with: - go-version: 1.18.x + - name: Set up Go 1.19.x + uses: actions/setup-go@v4 + with: + go-version: 1.19.x - # will install latest ko version and default login/configure - # KO_DOCKER_REPO to ghcr.io - - name: Setup ko for ghcr.io - uses: imjasonh/setup-ko@v0.6 - - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 1 + # will install latest ko version and default login/configure + # KO_DOCKER_REPO to ghcr.io + - name: Setup ko for ghcr.io + uses: imjasonh/setup-ko@v0.6 - - name: Get Release URL - id: get_release_url - uses: bruceadams/get-release@v1.2.3 - env: - GITHUB_TOKEN: ${{ github.token }} + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 1 - - name: Build and Publish images, Produce release artifact. - run: | - ko resolve --platform=all --tags $(basename "${{ github.ref }}" ) -BRf config/ > release.yaml + - name: Get Release URL + id: get_release_url + uses: bruceadams/get-release@v1.2.3 + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Build and Publish images, Produce release artifact. + run: | + ko resolve --platform=all --tags $(basename "${{ github.ref }}" ) -BRf config/ > release.yaml - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.get_release_url.outputs.upload_url }} - asset_path: ./release.yaml - asset_name: release.yaml - asset_content_type: text/plain + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_release_url.outputs.upload_url }} + asset_path: ./release.yaml + asset_name: release.yaml + asset_content_type: text/plain diff --git a/.goreleaser.yml b/.goreleaser.yml index 8f93ee64f..3346eb624 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -5,39 +5,39 @@ before: # you may remove this if you don't need go generate - go generate ./... builds: -- id: "kn-vsphere-build" - binary: kn-vsphere - main: ./plugins/vsphere/cmd/vsphere/main.go - env: - - CGO_ENABLED=0 - flags: - - -mod=vendor - ldflags: - - -X 'github.com/vmware-tanzu/sources-for-knative/plugins/vsphere/pkg/command/version.BuildDate={{.Date}}' - - -X 'github.com/vmware-tanzu/sources-for-knative/plugins/vsphere/pkg/command/version.Version={{.Version}}' - - -X 'github.com/vmware-tanzu/sources-for-knative/plugins/vsphere/pkg/command/version.GitRevision={{.Commit}}' + - id: "kn-vsphere-build" + binary: kn-vsphere + main: ./plugins/vsphere/cmd/vsphere/main.go + env: + - CGO_ENABLED=0 + flags: + - -mod=vendor + ldflags: + - -X 'github.com/vmware-tanzu/sources-for-knative/plugins/vsphere/pkg/command/version.BuildDate={{.Date}}' + - -X 'github.com/vmware-tanzu/sources-for-knative/plugins/vsphere/pkg/command/version.Version={{.Version}}' + - -X 'github.com/vmware-tanzu/sources-for-knative/plugins/vsphere/pkg/command/version.GitRevision={{.Commit}}' archives: -- replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 - name_template: "kn-vsphere_{{ .Version }}_{{ .Os }}_{{ .Arch }}" - files: - - LICENSE - - ./plugins/vsphere/README.adoc - wrap_in_directory: true + - id: foo + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + files: + - LICENSE + - ./plugins/vsphere/README.adoc + wrap_in_directory: true checksum: - name_template: 'checksums.txt' + name_template: "checksums.txt" snapshot: name_template: "{{ .Tag }}-next" changelog: sort: asc filters: exclude: - - '^docs:' - - '^test:' + - "^docs:" + - "^test:" release: draft: false prerelease: false