Skip to content

Commit

Permalink
relax version requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
wg committed Jun 5, 2020
1 parent a60f06b commit 8a44c62
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 37 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pkg
name: Build Linux Packages
description: |
Build a Linux .deb or .rpm package
inputs:
Expand Down
14 changes: 1 addition & 13 deletions args.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import (
"strconv"
"strings"

"github.com/Masterminds/semver/v3"
"github.com/jessevdk/go-flags"
"github.com/pkg/errors"
"gopkg.in/yaml.v2"
)

type Args struct {
Name string `long:"name" description:"package name" required:"true"`
Version Version `long:"version" description:"package version" required:"true"`
Version string `long:"version" description:"package version" required:"true"`
Arch Arch `long:"arch" description:"package arch" `
Deb bool `long:"deb" description:"build a .deb package" `
RPM bool `long:"rpm" description:"build a .rpm package" `
Expand Down Expand Up @@ -99,17 +98,6 @@ func (a *Args) Packages() []Package {
return pkgs
}

func (v *Version) UnmarshalFlag(value string) error {
version, err := semver.NewVersion(value)
if err != nil {
return err
}

*v = Version{version}

return nil
}

func (a *Arch) UnmarshalFlag(value string) error {
switch strings.ToLower(value) {
case "x86_64", "amd64":
Expand Down
3 changes: 1 addition & 2 deletions args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package main
import (
"testing"

"github.com/Masterminds/semver/v3"
"github.com/stretchr/testify/assert"
)

func testArgs() *Args {
return &Args{
Name: "test",
Version: Version{semver.MustParse("1.0.0")},
Version: "1.0.0",
Arch: X86_64,
Deb: true,
RPM: false,
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.14

require (
github.com/Knetic/govaluate v3.0.0+incompatible
github.com/Masterminds/semver/v3 v3.1.0
github.com/goreleaser/nfpm v1.3.0
github.com/jessevdk/go-flags v1.4.0
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kentik/nfpm v1.3.1-0.20200529022637-4f43e41f673c h1:hK2RuIE4R48wxLvlCesPJaAToxbnbltfuG7TtEX9pRg=
github.com/kentik/nfpm v1.3.1-0.20200529022637-4f43e41f673c/go.mod h1:w0p7Kc9TAUgWMyrub63ex3M2Mgw88M4GZXoTq5UCb40=
github.com/kentik/nfpm v1.3.1-0.20200603061442-01c78ea84f94 h1:kGDvMNtaafLfTZo1S/o51CONr2tDphs/an1V782p1rU=
github.com/kentik/nfpm v1.3.1-0.20200603061442-01c78ea84f94/go.mod h1:w0p7Kc9TAUgWMyrub63ex3M2Mgw88M4GZXoTq5UCb40=
github.com/kentik/nfpm v1.3.1-0.20200603061708-988e1152d67c h1:zKaIwBDgW0NiM32OrVPzCIOneGp8Hi/CJlAu1xNWj68=
github.com/kentik/nfpm v1.3.1-0.20200603061708-988e1152d67c/go.mod h1:bOV6C+s6FuF0NHPg+a0LVlk/d0r9T2UCeQD+f9p/4Yk=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
Expand Down
22 changes: 7 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@ import (
"os"

"github.com/Knetic/govaluate"
"github.com/Masterminds/semver/v3"
"github.com/goreleaser/nfpm"
_ "github.com/goreleaser/nfpm/deb"
_ "github.com/goreleaser/nfpm/rpm"
"github.com/pkg/errors"
)

type (
Arch string
Format string
Version struct {
*semver.Version
}
Arch string
Format string
)

const (
Expand All @@ -38,7 +34,7 @@ var (
type Package struct {
Format Format
Name string
Version Version
Version string
Arch Arch
Meta Meta
Files map[string]File
Expand Down Expand Up @@ -129,9 +125,9 @@ func (p *Package) Filename() string {
xlated := p.Format.Translate(p.Arch)
switch p.Format {
case DEB:
return fmt.Sprintf("%s_%s-1_%s.deb", p.Name, p.Version.String(), xlated)
return fmt.Sprintf("%s_%s-1_%s.deb", p.Name, p.Version, xlated)
case RPM:
return fmt.Sprintf("%s-%s-1.%s.rpm", p.Name, p.Version.String(), xlated)
return fmt.Sprintf("%s-%s-1.%s.rpm", p.Name, p.Version, xlated)
}
return ""

Expand All @@ -153,7 +149,7 @@ func (p *Package) Info() (*nfpm.Info, error) {

parameters := map[string]interface{}{
"arch": string(p.Arch),
"version": p.Version.String(),
"version": p.Version,
"format": string(p.Format),
}

Expand Down Expand Up @@ -191,7 +187,7 @@ func (p *Package) Info() (*nfpm.Info, error) {
Name: p.Name,
Arch: p.Format.Translate(p.Arch),
Platform: "",
Version: p.Version.String(),
Version: p.Version,
Description: p.Meta.Description,
Vendor: p.Meta.Vendor,
Maintainer: p.Meta.Maintainer,
Expand Down Expand Up @@ -226,7 +222,3 @@ func (f Format) Translate(arch Arch) string {
}
return xlate[f][arch]
}

func (v *Version) String() string {
return v.Version.String()
}
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestPackageInfo(t *testing.T) {
ConfigFiles: map[string]string{},
},
Name: args.Name,
Version: args.Version.String(),
Version: args.Version,
Arch: pkg.Format.Translate(args.Arch),
Platform: "linux",
Maintainer: args.Inputs.Config.Meta.Maintainer,
Expand Down

0 comments on commit 8a44c62

Please sign in to comment.