Skip to content

Commit

Permalink
Merge pull request #386 from bodji/bodji/dev
Browse files Browse the repository at this point in the history
fix: no more hardcoded version in code
  • Loading branch information
bodji authored Dec 22, 2021
2 parents 6d0d738 + 7c5e962 commit e0659a7
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 25 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ jobs:
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Fetch tags
run: |
git fetch --prune --unshallow --tags
- name: Login to Docker Hub
uses: docker/login-action@v1
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Fetch tags
run: |
git fetch --prune --unshallow --tags
- name: Run linter
run: make lint

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ lint:
# Run fmt
###
fmt:
@goimports -w -l -local "github.com/root-gg/plik" $(shell find . -type f -name '*.go' -not -path "./vendor/*")
@gofmt -w -s $(shell find . -type f -name '*.go' -not -path "./vendor/*" )

###
# Run tests
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ Plik is a scalable & friendly temporary file upload system (Wetransfer like) in
- [Filelink for Plik](https://gitlab.com/joendres/filelink-plik) : Thunderbird Addon to upload attachments to Plik

### Version
1.3.2
1.3.3

### Installation

##### From release
To run plik, it's very simple :
```sh
$ wget https://github.com/root-gg/plik/releases/download/1.3.2/plik-1.3.2-linux-amd64.tar.gz
$ tar xzvf plik-1.3.2-linux-64bits.tar.gz
$ cd plik-1.3.2/server
$ wget https://github.com/root-gg/plik/releases/download/1.3.2/plik-1.3.3-linux-amd64.tar.gz
$ tar xzvf plik-1.3.3-linux-64bits.tar.gz
$ cd plik-1.3.3/server
$ ./plikd
```
Et voilà ! You now have a fully functional instance of Plik running on http://127.0.0.1:8080.
Expand Down
23 changes: 23 additions & 0 deletions changelog/1.3.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Plik 1.3.3

Hi, today we're releasing Plik 1.3.3 !

Here is the changelog :

New
- New metadata backend : MySQL / MariaDB \o/
- Update gorm and go-sqlite3 libraries
- Provide a usage example for docker-compose

Fixed
- Improve clean and logging
- Swift|S3 data backend: DO not fail when removing missing file
- Simplify GCS backend
- Properly remove uploading files
- Fix transaction issue in DeleteUser
- Fix export of soft deleted uploads / Add import --ignore-error parameter
- Properly close metadata backend during tests


Faithfully,
The plik team
2 changes: 1 addition & 1 deletion plik/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewClient(url string) (c *Client) {

// Default values for X-ClientApp and X-ClientVersion HTTP Headers
c.ClientName = "plik_client"
c.ClientVersion = runtime.GOOS + "-" + runtime.GOARCH + "-" + common.GetVersion()
c.ClientVersion = runtime.GOOS + "-" + runtime.GOARCH + "-" + common.GetBuildInfo().Version

// Create a new default HTTP client. Override it if may you have more specific requirements
transport := &http.Transport{
Expand Down
13 changes: 3 additions & 10 deletions server/common/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,15 @@ import (
"github.com/jinzhu/copier"
)

const version = "1.3.2"

// GetVersion return the current package version
func GetVersion() string {
return version
}

// This variable content is meant to be passed the output of the gen_build_info.sh script at compile time using -ldflags
var buildInfoString string

var buildInfo *BuildInfo

func init() {
buildInfo = &BuildInfo{}
buildInfo = &BuildInfo{
Version: "0.0.0",
}

if buildInfoString != "" {
jsonString, err := base64.StdEncoding.DecodeString(buildInfoString)
Expand All @@ -36,8 +31,6 @@ func init() {
panic(fmt.Errorf("Unable to parse build info json string : %s", err))
}
}

buildInfo.Version = GetVersion()
}

// BuildInfo export build related variables
Expand Down
8 changes: 1 addition & 7 deletions server/common/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ func TestValidateVersionRegex(t *testing.T) {
validateVersion(t, "1.1-rc1", false)
}

func TestGetVersion(t *testing.T) {
version := GetVersion()
require.NotZero(t, version, "missing version")
validateVersion(t, version, true)
}

func TestGetBuildInfo(t *testing.T) {
buildInfo := GetBuildInfo()
require.NotNil(t, buildInfo, "missing build info")
Expand All @@ -56,5 +50,5 @@ func TestGetBuildInfoStringSanitize(t *testing.T) {
buildInfo := GetBuildInfo()
buildInfo.Sanitize()
v := buildInfo.String()
require.Equal(t, fmt.Sprintf("v%s", GetVersion()), v, "invalid build string")
require.Equal(t, fmt.Sprintf("v%s", buildInfo.Version), v, "invalid build string")
}
2 changes: 1 addition & 1 deletion server/gen_build_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if [[ ! -f "$FILE" ]]; then
exit 1
fi

version=${VERSION:-$(cat "$FILE" | sed -n 's/^const version = "\(.*\)"/\1/p')}
version=${VERSION:-$(git describe --tags --abbrev=0)}
if [[ -z "$version" ]]; then
echo "version not found"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion server/handlers/create_upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func TestCreateInvalidRequestBody(t *testing.T) {
type NeverEndingReader struct{}

func (r *NeverEndingReader) Read(p []byte) (n int, err error) {
for i, _ := range p {
for i := range p {
p[i] = byte('x')
}
return len(p), nil
Expand Down

0 comments on commit e0659a7

Please sign in to comment.