Skip to content

Commit

Permalink
Prerelease option added
Browse files Browse the repository at this point in the history
Signed-off-by: Manish Gupta <manish@plane.so>

Updated Release Action

Signed-off-by: Manish Gupta <manish@plane.so>

Updated goreleaser.yml

Signed-off-by: Manish Gupta <manish@plane.so>

Updated goreleaser.yml

Signed-off-by: Manish Gupta <manish@plane.so>

Updated goreleaser.yml

Signed-off-by: Manish Gupta <manish@plane.so>

Updated goreleaser.yml

Signed-off-by: Manish Gupta <manish@plane.so>

fixed prerelease

updated releaser

updated help

personal master outside of original main

added to testcase

modified testcase
  • Loading branch information
mguptahub committed Sep 5, 2024
1 parent 99c6a9a commit 78776d9
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 173 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- main
- master

jobs:
ci:
Expand Down
21 changes: 10 additions & 11 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,35 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@v4.1.7
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
uses: actions/setup-go@v5.0.2
with:
go-version-file: ./go.mod
check-latest: true

- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
uses: docker/setup-qemu-action@v3.2.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
uses: docker/setup-buildx-action@v3.6.1

- name: Install GoReleaser
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
uses: goreleaser/goreleaser-action@v6.0.0
with:
install-only: true

- name: Install cosign
uses: sigstore/cosign-installer@4959ce089c160fddf62f7b42464195ba1a56d382 # v3.6.0
uses: sigstore/cosign-installer@v3.6.0

- name: Install syft
uses: anchore/sbom-action/download-syft@61119d458adab75f756bc0b9e4bde25725f86a7a # v0.17.2
uses: anchore/sbom-action/download-syft@v0.17.2

- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
uses: actions/cache@v4.0.2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand All @@ -54,14 +54,13 @@ jobs:
- uses: chainguard-dev/actions/goimports@main

- name: Login to registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Run Mage
uses: magefile/mage-action@6a5dcb5fe61f43d7c08a98bc3cf9bc63c308c08e # v3.0.0
uses: magefile/mage-action@v3
with:
args: -v release
env:
Expand Down
163 changes: 1 addition & 162 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,10 @@ builds:
- CGO_ENABLED=0
goarch:
- amd64
- arm
- arm64
- s390x
- ppc64le
goarm:
- 7
goos:
- linux
- darwin
- windows
ignore:
- goos: windows
goarch: arm
- goos: windows
goarch: s390x
- goos: windows
goarch: ppc64le
ldflags:
- >-
-X github.com/helm/chart-releaser/cr/cmd.Version={{ .Tag }}
Expand All @@ -55,158 +42,10 @@ checksum:
snapshot:
name_template: "{{ .Tag }}-next"

dockers:
- goos: linux
goarch: amd64
skip_push: "{{ ne .GitURL 'https://github.com/helm/chart-releaser' | toYaml }}"
dockerfile: Dockerfile
use: buildx
image_templates:
- quay.io/helmpack/chart-releaser:{{ .Tag }}-amd64
- quay.io/helmpack/chart-releaser:latest-amd64
- ghcr.io/helm/chart-releaser:{{ .Tag }}-amd64
- ghcr.io/helm/chart-releaser:latest-amd64
build_flag_templates:
- "--platform=linux/amd64"
- --label=org.label-schema.schema-version=1.0
- --label=org.label-schema.version={{ .Version }}
- --label=org.label-schema.name={{ .ProjectName }}
- --label=org.label-schema.build-date={{ .Date }}
- --label=org.label-schema.description='cr - The chart release tool'
- --label=org.label-schema.vendor=Helm

- goos: linux
goarch: arm64
skip_push: "{{ ne .GitURL 'https://github.com/helm/chart-releaser' | toYaml }}"
dockerfile: Dockerfile
use: buildx
image_templates:
- quay.io/helmpack/chart-releaser:{{ .Tag }}-arm64
- quay.io/helmpack/chart-releaser:latest-arm64
- ghcr.io/helm/chart-releaser:{{ .Tag }}-arm64
- ghcr.io/helm/chart-releaser:latest-arm64
build_flag_templates:
- "--platform=linux/arm64"
- --label=org.label-schema.schema-version=1.0
- --label=org.label-schema.version={{ .Version }}
- --label=org.label-schema.name={{ .ProjectName }}
- --label=org.label-schema.build-date={{ .Date }}
- --label=org.label-schema.description='cr - The chart release tool'
- --label=org.label-schema.vendor=Helm

- goos: linux
goarch: arm
goarm: 7
skip_push: "{{ ne .GitURL 'https://github.com/helm/chart-releaser' | toYaml }}"
dockerfile: Dockerfile
use: buildx
image_templates:
- quay.io/helmpack/chart-releaser:{{ .Tag }}-armv7
- quay.io/helmpack/chart-releaser:latest-armv7
- ghcr.io/helm/chart-releaser:{{ .Tag }}-armv7
- ghcr.io/helm/chart-releaser:latest-armv7
build_flag_templates:
- "--platform=linux/arm/v7"
- --label=org.label-schema.schema-version=1.0
- --label=org.label-schema.version={{ .Version }}
- --label=org.label-schema.name={{ .ProjectName }}
- --label=org.label-schema.build-date={{ .Date }}
- --label=org.label-schema.description='cr - The chart release tool'
- --label=org.label-schema.vendor=Helm

- goos: linux
goarch: s390x
skip_push: "{{ ne .GitURL 'https://github.com/helm/chart-releaser' | toYaml }}"
dockerfile: Dockerfile
use: buildx
image_templates:
- quay.io/helmpack/chart-releaser:{{ .Tag }}-s390x
- quay.io/helmpack/chart-releaser:latest-s390x
- ghcr.io/helm/chart-releaser:{{ .Tag }}-s390x
- ghcr.io/helm/chart-releaser:latest-s390x
build_flag_templates:
- "--platform=linux/s390x"
- --label=org.label-schema.schema-version=1.0
- --label=org.label-schema.version={{ .Version }}
- --label=org.label-schema.name={{ .ProjectName }}
- --label=org.label-schema.build-date={{ .Date }}
- --label=org.label-schema.description='cr - The chart release tool'
- --label=org.label-schema.vendor=Helm

- goos: linux
goarch: ppc64le
skip_push: "{{ ne .GitURL 'https://github.com/helm/chart-releaser' | toYaml }}"
dockerfile: Dockerfile
use: buildx
image_templates:
- quay.io/helmpack/chart-releaser:{{ .Tag }}-ppc64le
- quay.io/helmpack/chart-releaser:latest-ppc64le
- ghcr.io/helm/chart-releaser:{{ .Tag }}-ppc64le
- ghcr.io/helm/chart-releaser:latest-ppc64le
build_flag_templates:
- "--platform=linux/ppc64le"
- --label=org.label-schema.schema-version=1.0
- --label=org.label-schema.version={{ .Version }}
- --label=org.label-schema.name={{ .ProjectName }}
- --label=org.label-schema.build-date={{ .Date }}
- --label=org.label-schema.description='cr - The chart release tool'
- --label=org.label-schema.vendor=Helm

docker_manifests:
- name_template: quay.io/helmpack/chart-releaser:{{ .Tag }}
image_templates:
- quay.io/helmpack/chart-releaser:{{ .Tag }}-amd64
- quay.io/helmpack/chart-releaser:{{ .Tag }}-arm64
- quay.io/helmpack/chart-releaser:{{ .Tag }}-armv7
- quay.io/helmpack/chart-releaser:{{ .Tag }}-s390x
- quay.io/helmpack/chart-releaser:{{ .Tag }}-ppc64le
- name_template: ghcr.io/helm/chart-releaser:{{ .Tag }}
image_templates:
- ghcr.io/helm/chart-releaser:{{ .Tag }}-amd64
- ghcr.io/helm/chart-releaser:{{ .Tag }}-arm64
- ghcr.io/helm/chart-releaser:{{ .Tag }}-armv7
- ghcr.io/helm/chart-releaser:{{ .Tag }}-s390x
- ghcr.io/helm/chart-releaser:{{ .Tag }}-ppc64le
- name_template: quay.io/helmpack/chart-releaser:latest
image_templates:
- quay.io/helmpack/chart-releaser:latest-amd64
- quay.io/helmpack/chart-releaser:latest-arm64
- quay.io/helmpack/chart-releaser:latest-armv7
- quay.io/helmpack/chart-releaser:latest-s390x
- quay.io/helmpack/chart-releaser:latest-ppc64le
- name_template: ghcr.io/helm/chart-releaser:latest
image_templates:
- ghcr.io/helm/chart-releaser:latest-amd64
- ghcr.io/helm/chart-releaser:latest-arm64
- ghcr.io/helm/chart-releaser:latest-armv7
- ghcr.io/helm/chart-releaser:latest-s390x
- ghcr.io/helm/chart-releaser:latest-ppc64le

signs:
- id: all
signature: "${artifact}.sig"
certificate: "${artifact}.pem"
cmd: cosign
args: ["sign-blob", "--output-signature", "${artifact}.sig", "--output-certificate", "${artifact}.pem", "${artifact}"]
artifacts: all

docker_signs:
- id: images
cmd: cosign
args: ["sign", "${artifact}"]
artifacts: manifests

brews:
- repository:
owner: helm
name: homebrew-tap
commit_author:
name: helm-bot
email: helm-bot@users.noreply.github.com
directory: Formula
homepage: "{{ .GitURL }}"
description: Hosting Helm Charts via GitHub Pages and Releases
install: |
bin.install "cr"
test: |
system "#{bin}/cr version"
artifacts: all
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Flags:
-t, --token string GitHub Auth Token
--make-release-latest bool Mark the created GitHub release as 'latest' (default "true")
--packages-with-index Host the package files in the GitHub Pages branch
--prerelease Mark this as 'Pre-release' (default: false)

Global Flags:
--config string Config file (default is $HOME/.cr.yaml)
Expand Down
1 change: 1 addition & 0 deletions cr/cmd/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ func init() {
uploadCmd.Flags().Bool("push", false, "Push the chart package to the GitHub Pages branch (must not be set if --pr is set)")
uploadCmd.Flags().Bool("pr", false, "Create a pull request for the chart package against the GitHub Pages branch (must not be set if --push is set)")
uploadCmd.Flags().Bool("packages-with-index", false, "Host the package files in the GitHub Pages branch")
uploadCmd.Flags().Bool("prerelease", false, "Mark this as 'Pre-release' (default: false)")
}
1 change: 1 addition & 0 deletions doc/cr_upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ cr upload [flags]
--packages-with-index Host the package files in the GitHub Pages branch
--pages-branch string The GitHub pages branch (default "gh-pages")
--pr Create a pull request for the chart package against the GitHub Pages branch (must not be set if --push is set)
--prerelease Mark this as 'Pre-release' (default: false)
--push Push the chart package to the GitHub Pages branch (must not be set if --pr is set)
--release-name-template string Go template for computing release names, using chart metadata (default "{{ .Name }}-{{ .Version }}")
--release-notes-file string Markdown file with chart release notes. If it is set to empty string, or the file is not found, the chart description will be used instead. The file is read from the chart package
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type Options struct {
GenerateReleaseNotes bool `mapstructure:"generate-release-notes"`
MakeReleaseLatest bool `mapstructure:"make-release-latest"`
PackagesWithIndex bool `mapstructure:"packages-with-index"`
Prerelease bool `mapstructure:"prerelease"`
}

func LoadConfiguration(cfgFile string, cmd *cobra.Command, requiredFlags []string) (*Options, error) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Release struct {
Commit string
GenerateReleaseNotes bool
MakeLatest string
Prerelease bool
}

type Asset struct {
Expand Down Expand Up @@ -111,6 +112,7 @@ func (c *Client) CreateRelease(_ context.Context, input *Release) error {
TargetCommitish: &input.Commit,
GenerateReleaseNotes: &input.GenerateReleaseNotes,
MakeLatest: &input.MakeLatest,
Prerelease: &input.Prerelease,
}

release, _, err := c.Repositories.CreateRelease(context.TODO(), c.owner, c.repo, req)
Expand Down
1 change: 1 addition & 0 deletions pkg/releaser/releaser.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ func (r *Releaser) CreateReleases() error {
Commit: r.config.Commit,
GenerateReleaseNotes: r.config.GenerateReleaseNotes,
MakeLatest: strconv.FormatBool(r.config.MakeReleaseLatest),
Prerelease: r.config.Prerelease,
}
provFile := fmt.Sprintf("%s.prov", p)
if _, err := os.Stat(provFile); err == nil {
Expand Down
7 changes: 7 additions & 0 deletions pkg/releaser/releaser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func (f *FakeGitHub) GetRelease(ctx context.Context, tag string) (*github.Releas
URL: "https://myrepo/charts/third-party-file-0.1.0.txt",
},
},
Prerelease: false,
}
return release, nil
}
Expand Down Expand Up @@ -362,6 +363,7 @@ func TestReleaser_CreateReleases(t *testing.T) {
version string
commit string
latest string
prerelease bool
Releaser *Releaser
error bool
}{
Expand All @@ -378,6 +380,7 @@ func TestReleaser_CreateReleases(t *testing.T) {
Commit: "",
PackagesWithIndex: false,
MakeReleaseLatest: true,
Prerelease: false,
},
},
error: true,
Expand All @@ -395,6 +398,7 @@ func TestReleaser_CreateReleases(t *testing.T) {
Commit: "",
PackagesWithIndex: false,
MakeReleaseLatest: true,
Prerelease: false,
},
},
error: false,
Expand All @@ -412,6 +416,7 @@ func TestReleaser_CreateReleases(t *testing.T) {
Commit: "5e239bd19fbefb9eb0181ecf0c7ef73b8fe2753c",
PackagesWithIndex: false,
MakeReleaseLatest: true,
Prerelease: false,
},
},
error: false,
Expand All @@ -430,6 +435,7 @@ func TestReleaser_CreateReleases(t *testing.T) {
PackagesWithIndex: true,
Push: true,
MakeReleaseLatest: true,
Prerelease: false,
},
},
error: false,
Expand Down Expand Up @@ -466,6 +472,7 @@ func TestReleaser_CreateReleases(t *testing.T) {
assert.Equal(t, assetPath, fakeGitHub.release.Assets[0].Path)
assert.Equal(t, tt.commit, fakeGitHub.release.Commit)
assert.Equal(t, tt.latest, fakeGitHub.release.MakeLatest)
assert.Equal(t, tt.prerelease, fakeGitHub.release.Prerelease)
assert.Equal(t, tt.Releaser.config.Commit, fakeGitHub.release.Commit)
fakeGitHub.AssertNumberOfCalls(t, "CreateRelease", 1)
}
Expand Down

0 comments on commit 78776d9

Please sign in to comment.