Skip to content

Commit

Permalink
add release
Browse files Browse the repository at this point in the history
  • Loading branch information
joelee2012 committed Aug 26, 2024
1 parent 14ca129 commit 240c031
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 13 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# .github/workflows/release.yml
name: goreleaser

on:
pull_request:
push:
# run only against tags
tags:
- '*'
- "*"

permissions:
contents: write
# packages: write
# issues: write

jobs:
goreleaser:
Expand All @@ -13,17 +21,21 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
go-version: stable
# More assembly might be required: Docker logins, GPG, etc.
# It all depends on your needs.
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
uses: goreleaser/goreleaser-action@v6
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
# 'latest', 'nightly', or a semver
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GLOBAL_GITHUB_TOKEN: ${{ secrets.GLOBAL_GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@
# Go workspace file
go.work
go.work.sum

dist/
51 changes: 51 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
- sed -ri 's/dev/{{.Version}}/g' plugin.yaml

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
# name_template: >-
# {{ .ProjectName }}_
# {{- title .Os }}_
# {{- if eq .Arch "amd64" }}x86_64
# {{- else if eq .Arch "386" }}i386
# {{- else }}{{ .Arch }}{{ end }}
# {{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
files:
- "LICENSE*"
- "README*"
- plugin.yaml

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
8 changes: 4 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import (
"github.com/spf13/cobra"
)

func newRootCmd() *cobra.Command {
func newRootCmd(version string) *cobra.Command {
var clean = Clean{}
var rootCmd = &cobra.Command{
Use: "clean",
Short: "A helm plugin to clean release by date",
Long: `A helm plugin to clean release by date`,
Version: "0.0.1",
Version: version,
RunE: func(cmd *cobra.Command, args []string) error {
return clean.Run(os.Stdout)
},
Expand All @@ -34,8 +34,8 @@ func newRootCmd() *cobra.Command {
return rootCmd
}

func Execute() {
err := newRootCmd().Execute()
func Execute(version string) {
err := newRootCmd(version).Execute()
if err != nil {
os.Exit(1)
}
Expand Down
21 changes: 18 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
/*
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
*/
package main

import "github.com/joelee2012/helm-clean/cmd"
import (
"fmt"

"github.com/joelee2012/helm-clean/cmd"
)

var (
version = "dev"
commit = "none"
date = "unknown"
)

type BuildInfo struct {
Version string
Commit string
BuildDate string
}

func main() {
cmd.Execute()
cmd.Execute(fmt.Sprintf("%#v", BuildInfo{Version: version, Commit: commit, BuildDate: date}))
}
6 changes: 6 additions & 0 deletions plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: "clean"
version: "dev"
usage: "plugin to clean no updated release"
description: "plugin to clean no updated release"
useTunnel: true
command: "$HELM_PLUGIN_DIR/helm-clean"

0 comments on commit 240c031

Please sign in to comment.