diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..92d4126 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,23 @@ +# Contributing + +## Requirements + ++ Go 1.21+ ++ Make + + +## Testing + +First ensure tests pass: + +```bash +make test +``` + +## Releasing + +Release a new version: + +```bash +make build +``` \ No newline at end of file diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..821bcea --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: [Halleck45] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..254cf59 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: goreleaser + +on: + push: + # run only against tags + tags: + - "*" + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + # Checkout the repository + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + # Install go dependencies + - uses: actions/setup-go@v4 + with: + go-version: stable + + # run tests + - name: "Test application" + run: go test + + # Build artifacts + - uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..a7c1867 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +name: Go + +on: [push] + +jobs: + test: + + runs-on: ubuntu-latest + strategy: + matrix: + go-version: [ '1.21.x' ] + + steps: + - uses: actions/checkout@v4 + + - name: Setup Go ${{ matrix.go-version }} + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + cache-dependency-path: subdir/go.sum + + - name: Install Go dependencies + run: go get . + + - name: Test with the Go CLI + run: go test \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4f48fc8..725d83d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ env.sh pkg build -bin \ No newline at end of file +bin +dist \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..99473b1 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,30 @@ + +before: + hooks: + - go mod tidy + - go generate ./... + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + +archives: + - format: binary + 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 }} + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" \ No newline at end of file diff --git a/Makefile b/Makefile index 30fba9b..bdfa89e 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,15 @@ REPLACE=`semver tag` - -init: - @export GOPATH=~/go:`pwd` - -install: - go get github.com/mitchellh/gox - go get github.com/dotcypress/phonetics - go get github.com/stretchr/testify +.PHONY: build test: - @go test github.com/halleck45/... - -build: test - @echo "Building release: `semver tag`" - @gox -build-toolchain -ldflags "-X main.version `semver tag`" oss.go - -publish: - @./publish.sh + @go test ./... + +build: + @echo "\e[34m\033[1m-> Building go binaries for supported platforms\033[0m\e[39m\n" + rm -Rf dist || true + go install github.com/goreleaser/goreleaser@latest + GOPATH=$(HOME)/go PATH=$$PATH:$(HOME)/go/bin goreleaser build --snapshot + @echo "\e[34m\033[1mDONE \033[0m\e[39m\n" tag: diff --git a/README.md b/README.md index 9d5c014..2a58ff5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# OSS +# OSS Tool for managing Open Source assets. -## Why ? +## Why ? Managing Open Source assets is a hard task in any project ; we often download awesome librairies, images or medias, but where to keep trace of all theses files ? How can I manage Open Source licenses of medias in my project ? @@ -11,32 +11,30 @@ That's the problem oss try to resolve today. ![simple overview of oss](./doc/overview.gif) -## Installation +## Installation -Download binary for your platform: +Download the binary for your platform from the [latest release](https://github.com/Halleck45/releases/latest). -+ Linux Debian: [64bits](http://dl.bintray.com/halleck45/OSS/oss_linux_amd64), [32bits](http://dl.bintray.com/halleck45/OSS/oss_linux_386) -+ Windows: [64bits](http://dl.bintray.com/halleck45/OSS/oss_windows_amd64.exe), [32bits](http://dl.bintray.com/halleck45/OSS/oss_windows_386.exe) -+ [Others platforms](http://dl.bintray.com/halleck45/OSS/) - -## Usage +## Usage On first run, please execute - oss init +```bash +oss init +``` Then, you can use the following commands: -+ **status**: list assets of the project -+ **add** `` `` `[]`: register new file -+ **rm** ``: unregister file -+ **show** ``: display information about the given file ++ `oss `**`status`**: list assets of the project ++ `oss `**`add`**` []`: register new file ++ `oss `**`rm`**` `: unregister file ++ `oss `**`show`**` `: display information about the given file Or to get information about SPDX licenses : -+ **licenses**: list available licenses (base on the [SPDX license list]((http://spdx.org/licenses/))) -+ **search** ``: Search licenses matching `expression` -+ **update**: update SPDX license list ++ `oss `**`licenses`**: list available licenses (base on the [SPDX license list]((http://spdx.org/licenses/))) ++ `oss `**`search`**` `: Search licenses matching `expression` ++ `oss `**`update`**: update SPDX license list Keep in mind that **the license identifier should be registered in [SPDX License list](http://spdx.org/licenses/)** @@ -44,14 +42,10 @@ Keep in mind that **the license identifier should be registered in [SPDX License MIT License. Copyright (c) Jean-François Lépine. See LICENSE for details. -## Contributing +## Contributing - clone git@github.com:Halleck45/OSS.git - cd OSS - make init && make install - ( ... your development ...) - make build +Cf. [CONTRIBUTING.md](./.github/CONTRIBUTING.md) Remember to keep tests up to date (and, of course, to run them with `make test`) diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..ce51476 --- /dev/null +++ b/go.mod @@ -0,0 +1,14 @@ +module github.com/halleck45/oss + +go 1.21 + +require ( + github.com/dotcypress/phonetics v0.0.0-20141025200009-5cea56e8d200 + github.com/stretchr/testify v1.9.0 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..4ecbd90 --- /dev/null +++ b/go.sum @@ -0,0 +1,12 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dotcypress/phonetics v0.0.0-20141025200009-5cea56e8d200 h1:3y43HNVcW0K++6HB7RsWIdulZ5zzrLYBBtPccYsqTdc= +github.com/dotcypress/phonetics v0.0.0-20141025200009-5cea56e8d200/go.mod h1:nTAuszUNo9dUCKTwDLN9UDcO5UdL/MAOvmu5oM+5ozY= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/oss.go b/oss.go index 86c8b3d..3fbd969 100644 --- a/oss.go +++ b/oss.go @@ -8,17 +8,18 @@ package main import ( "os" - "github.com/halleck45/oss/license" - "github.com/halleck45/oss/spdx" + + "github.com/halleck45/oss/src/license" + "github.com/halleck45/oss/src/spdx" ) func main() { var command string - if(len(os.Args) < 2) { + if len(os.Args) < 2 { command = "help" } else { - command = os.Args[1]; + command = os.Args[1] } spdxService := spdx.Service{LicenseFilename: "./.oss-licenses.json"} diff --git a/src/github.com/halleck45/oss/license/application.go b/src/license/application.go similarity index 99% rename from src/github.com/halleck45/oss/license/application.go rename to src/license/application.go index e0fdb2e..a58bd1c 100644 --- a/src/github.com/halleck45/oss/license/application.go +++ b/src/license/application.go @@ -189,6 +189,6 @@ func (app *Application) Run(command string) { fmt.Printf(" %-20s %s", "version", "Dislay current version\n") fmt.Printf(" %-20s %s", "help", "This help\n") default: - fmt.Println("Command %s not found", command) + fmt.Printf("Command %s not found\n", command) } } diff --git a/src/github.com/halleck45/oss/license/service.go b/src/license/service.go similarity index 91% rename from src/github.com/halleck45/oss/license/service.go rename to src/license/service.go index 11c8aa3..711b2c2 100644 --- a/src/github.com/halleck45/oss/license/service.go +++ b/src/license/service.go @@ -11,20 +11,20 @@ package license import ( "encoding/json" + "errors" "fmt" "io/ioutil" "os" - "errors" - "github.com/halleck45/oss/spdx" -) + "github.com/halleck45/oss/src/spdx" +) /** * Service */ type Service struct { - Filename string - Manif Manifest + Filename string + Manif Manifest SpdxService spdx.Service } @@ -40,7 +40,7 @@ func (c *Service) Init() (err error) { c.Save() } else { err = c.Load() - if(err != nil) { + if err != nil { return err } } @@ -52,7 +52,7 @@ func (c *Service) Init() (err error) { /** * Load current manifest */ -func (c *Service) Load() (err error){ +func (c *Service) Load() (err error) { // file exists ; load it file, err := os.Open(c.Filename) if err != nil { @@ -65,7 +65,6 @@ func (c *Service) Load() (err error){ return err } - /** * Add asset in manifest */ @@ -82,7 +81,7 @@ func (c *Service) Add(a Asset) { */ func (c *Service) Get(file string) (asset Asset, err error) { for _, asset := range c.Manif.Assets { - if(asset.File == file) { + if asset.File == file { return asset, nil } } diff --git a/src/github.com/halleck45/oss/license/service_test.go b/src/license/service_test.go similarity index 100% rename from src/github.com/halleck45/oss/license/service_test.go rename to src/license/service_test.go diff --git a/src/github.com/halleck45/oss/license/types.go b/src/license/types.go similarity index 100% rename from src/github.com/halleck45/oss/license/types.go rename to src/license/types.go diff --git a/src/github.com/halleck45/oss/spdx/service.go b/src/spdx/service.go similarity index 100% rename from src/github.com/halleck45/oss/spdx/service.go rename to src/spdx/service.go diff --git a/src/github.com/halleck45/oss/spdx/service_test.go b/src/spdx/service_test.go similarity index 100% rename from src/github.com/halleck45/oss/spdx/service_test.go rename to src/spdx/service_test.go diff --git a/src/github.com/halleck45/oss/spdx/types.go b/src/spdx/types.go similarity index 100% rename from src/github.com/halleck45/oss/spdx/types.go rename to src/spdx/types.go