Skip to content

Commit

Permalink
updated project for releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
Halleck45 committed Mar 11, 2024
1 parent 5032056 commit f925b9b
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 54 deletions.
23 changes: 23 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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
```
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [Halleck45]
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
env.sh
pkg
build
bin
bin
dist
30 changes: 30 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -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:"
25 changes: 9 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
40 changes: 17 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 ?
Expand All @@ -11,47 +11,41 @@ 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** `<license>` `<file>` `[<description>]`: register new file
+ **rm** `<file>`: unregister file
+ **show** `<file>`: display information about the given file
+ `oss `**`status`**: list assets of the project
+ `oss `**`add`**` <license> <file> [<description>]`: register new file
+ `oss `**`rm`**` <file>`: unregister file
+ `oss `**`show`**` <file>`: 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** `<expression>`: 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`**` <expression>`: 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/)**

## Copyright

MIT License. Copyright (c) Jean-François Lépine. See LICENSE for details.

## Contributing
## Contributing


clone [email protected]: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`)

Expand Down
14 changes: 14 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
)
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
9 changes: 5 additions & 4 deletions oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -40,7 +40,7 @@ func (c *Service) Init() (err error) {
c.Save()
} else {
err = c.Load()
if(err != nil) {
if err != nil {
return err
}
}
Expand All @@ -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 {
Expand All @@ -65,7 +65,6 @@ func (c *Service) Load() (err error){
return err
}


/**
* Add asset in manifest
*/
Expand All @@ -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
}
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f925b9b

Please sign in to comment.