Skip to content

Commit

Permalink
Release version 0.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed May 2, 2024
2 parents ed72e4a + bb1b784 commit 00c1a68
Show file tree
Hide file tree
Showing 34 changed files with 361 additions and 14 deletions.
5 changes: 4 additions & 1 deletion .bumpversion.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT

[tool.bumpversion]
current_version = "0.3.3"
current_version = "0.3.4"

[[tool.bumpversion.files]]
filename = "cmd/glzip/cli.go"

[[tool.bumpversion.files]]
filename = "cmd/glzip/testdata/version.ct"

[[tool.bumpversion.files]]
filename = "docs/man/man1/glzip.1.adoc"
60 changes: 60 additions & 0 deletions .github/workflows/CD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# SPDX-FileCopyrightText: 2024 Shun Sakai
#
# SPDX-License-Identifier: Apache-2.0 OR MIT

name: CD

on:
pull_request:
push:
branches:
- "develop"
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

permissions:
contents: write

jobs:
release:
name: Release
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: "stable"
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
- name: Install Asciidoctor
run: |
gem install asciidoctor
asciidoctor -V
- name: Check `.goreleaser.yaml`
uses: goreleaser/goreleaser-action@v5.0.0
with:
distribution: "goreleaser"
version: "latest"
args: check
- name: Check GoReleaser
uses: goreleaser/goreleaser-action@v5.0.0
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
with:
distribution: "goreleaser"
version: "latest"
args: release --clean --snapshot
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5.0.0
if: startsWith(github.ref, 'refs/tags/')
with:
distribution: "goreleaser"
version: "latest"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
os:
- ubuntu-22.04
- macos-12
- macos-14
- windows-2022
go-version:
- "1.22" # Go version
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
with:
go-version: "stable"
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v4.0.0
uses: golangci/golangci-lint-action@v5.1.0
with:
version: "latest"
args: -E gofmt,goimports -v
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
*.dll
*.so
*.dylib
/glzip

# Test binary, built with `go test -c`
*.test

# Generated man page
glzip.1

# GoReleaser
dist/
50 changes: 50 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# SPDX-FileCopyrightText: 2024 Shun Sakai
#
# SPDX-License-Identifier: Apache-2.0 OR MIT

version: 1

before:
hooks:
- go mod tidy
- asciidoctor -b manpage docs/man/man1/glzip.1.adoc

builds:
- main: ./cmd/glzip
binary: glzip
flags:
- -trimpath
ldflags:
- -s -w
env:
- CGO_ENABLED=0
goos:
- darwin
- freebsd
- linux
- openbsd
- windows
goarch:
- amd64
- arm64

archives:
- format: tar.gz
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
files:
- AUTHORS.adoc
- CHANGELOG.adoc
- CONTRIBUTING.adoc
- docs/man/man1/glzip.1
- LICENSES/*
- README.md

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
6 changes: 6 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ All notable changes to this project will be documented in this file.
The format is based on https://keepachangelog.com/[Keep a Changelog], and this
project adheres to https://semver.org/[Semantic Versioning].

== {compare-url}/v0.3.3\...v0.3.4[0.3.4] - 2024-05-02

=== Changed

* Change to provide pre-built binaries ({pull-request-url}/21[#21])

== {compare-url}/v0.3.2\...v0.3.3[0.3.3] - 2024-04-16

=== Changed
Expand Down
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,26 @@ See the [documentation][reference-url] for more details.
This package includes a simple command-line utility for reading and writing of
lzip format compressed files.

To install:
### Installation

#### From source

```sh
go install github.com/sorairolake/lzip-go/cmd/glzip@latest
```

To build:
#### Via a package manager

| OS | Package manager | Command |
| ----- | --------------- | ------------------------------------ |
| _Any_ | [Homebrew] | `brew install sorairolake/tap/glzip` |

#### From binaries

The [release page] contains pre-built binaries for Linux, macOS, Windows and
others.

#### How to build

```sh
# command-line utility
Expand All @@ -52,7 +65,9 @@ just build-cmd
just build-man
```

See [`glzip(1)`] for details.
### Usage

Please see [`glzip(1)`].

## Minimum Go version

Expand Down Expand Up @@ -92,6 +107,8 @@ licensing information.
[lzip compressed format]: https://www.nongnu.org/lzip/manual/lzip_manual.html#File-format
[Go]: https://go.dev/
[`example_test.go`]: example_test.go
[Homebrew]: https://brew.sh/
[release page]: https://github.com/sorairolake/lzip-go/releases
[`glzip(1)`]: docs/man/man1/glzip.1.adoc
[CHANGELOG.adoc]: CHANGELOG.adoc
[CONTRIBUTING.adoc]: CONTRIBUTING.adoc
Expand Down
2 changes: 1 addition & 1 deletion cmd/glzip/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/sorairolake/lzip-go"
)

const version = "0.3.3"
const version = "0.3.4"

type options struct {
version bool
Expand Down
7 changes: 4 additions & 3 deletions cmd/glzip/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package main
import (
"flag"
"fmt"
"log"
"os"
)

Expand All @@ -34,13 +33,15 @@ func main() {
if !opt.decompress {
for _, file := range args {
if err := compress(file, output, opt); err != nil {
log.Fatal(err)
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
} else {
for _, file := range args {
if err := uncompress(file, output, opt); err != nil {
log.Fatal(err)
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
}
Expand Down
84 changes: 84 additions & 0 deletions cmd/glzip/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// SPDX-FileCopyrightText: 2024 Shun Sakai
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

package main

import (
"io"
"os"
"os/exec"
"path/filepath"
"runtime"
"testing"

"github.com/google/go-cmdtest"
)

var testFiles = []string{
"foo.txt",
"fox.lz",
"fox_bm.lz",
"fox_das46.lz",
"fox_de20.lz",
"fox_s11.lz",
"fox_v2.lz",
}

func copyFile(srcFile, dstFile string) error {
src, err := os.Open(srcFile)
if err != nil {
return err
}
defer src.Close()

dst, err := os.Create(dstFile)
if err != nil {
return err
}
defer dst.Close()

_, err = io.Copy(dst, src)
if err != nil {
return err
}

return nil
}

func TestCLI(t *testing.T) {
t.Parallel()

if runtime.GOOS == "windows" {
t.SkipNow()
}

wd, err := os.Getwd()
if err != nil {
t.Fatal(err)
}

if err := exec.Command("go", "build").Run(); err != nil {
t.Fatal(err)
}

defer os.Remove("glzip")

ts, err := cmdtest.Read("testdata")
if err != nil {
t.Fatal(err)
}

ts.Setup = func(rootDir string) error {
for _, testFile := range testFiles {
err := copyFile(filepath.Join(wd, "testdata", testFile), filepath.Join(rootDir, testFile))
if err != nil {
return err
}
}

return nil
}
ts.Commands["glzip"] = cmdtest.Program("glzip")
ts.Run(t, false)
}
11 changes: 11 additions & 0 deletions cmd/glzip/testdata/compress.ct
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2024 Shun Sakai
#
# SPDX-License-Identifier: Apache-2.0 OR MIT

$ glzip foo.txt
$ cat foo.txt --> FAIL
$ glzip -decompress foo.txt.lz
$ cat foo.txt
Hello, world!

$ glzip -keep foo.txt
15 changes: 15 additions & 0 deletions cmd/glzip/testdata/compress_dictionary_size.ct
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: 2024 Shun Sakai
#
# SPDX-License-Identifier: Apache-2.0 OR MIT

$ glzip -dictionary-size 4194304 foo.txt
$ cat foo.txt --> FAIL
$ glzip -decompress foo.txt.lz
$ cat foo.txt
Hello, world!

$ glzip -dictionary-size 4095 foo.txt --> FAIL
lzip: dictionary size is too small

$ glzip -dictionary-size 536870913 foo.txt --> FAIL
lzip: dictionary size is too large
1 change: 1 addition & 0 deletions cmd/glzip/testdata/foo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, world!
3 changes: 3 additions & 0 deletions cmd/glzip/testdata/foo.txt.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2024 Shun Sakai

SPDX-License-Identifier: Apache-2.0 OR MIT
1 change: 1 addition & 0 deletions cmd/glzip/testdata/fox.lz
1 change: 1 addition & 0 deletions cmd/glzip/testdata/fox_bcrc.lz
1 change: 1 addition & 0 deletions cmd/glzip/testdata/fox_bm.lz
1 change: 1 addition & 0 deletions cmd/glzip/testdata/fox_crc0.lz
1 change: 1 addition & 0 deletions cmd/glzip/testdata/fox_das46.lz
1 change: 1 addition & 0 deletions cmd/glzip/testdata/fox_de20.lz
1 change: 1 addition & 0 deletions cmd/glzip/testdata/fox_mes81.lz
1 change: 1 addition & 0 deletions cmd/glzip/testdata/fox_s11.lz

0 comments on commit 00c1a68

Please sign in to comment.