Skip to content

Commit

Permalink
Merge pull request #14 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 0.0.4
  • Loading branch information
andyone authored May 10, 2022
2 parents d2c902c + 26744f8 commit ae2fb30
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 51 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:

env:
SRC_DIR: src/github.com/${{ github.repository }}
GO111MODULE: auto

strategy:
matrix:
Expand All @@ -24,13 +23,6 @@ jobs:
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
id: go

- name: Setup PATH
run: |
echo "GOPATH=${{ github.workspace }}" >> "$GITHUB_ENV"
echo "GOBIN=${{ github.workspace }}/bin" >> "$GITHUB_ENV"
echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH"

- name: Checkout
uses: actions/checkout@v3
Expand All @@ -49,6 +41,8 @@ jobs:
name: Hadolint
runs-on: ubuntu-latest

needs: Go

steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -69,7 +63,7 @@ jobs:
uses: actions/checkout@v3

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
if: ${{ env.DOCKERHUB_USERNAME != '' }}
Expand All @@ -80,3 +74,9 @@ jobs:
- name: Build Docker image
run: |
docker build -f Dockerfile -t rsz .
- name: Show info about built Docker image
uses: essentialkaos/docker-info-action@v1
with:
image: rsz
show-labels: true
20 changes: 10 additions & 10 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: go
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: go

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
59 changes: 59 additions & 0 deletions .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "GHCR Publish"

on:
release:
types: [published]

permissions:
packages: write
contents: read

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
GHCR:
name: GHCR Build & Publish
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Login to DockerHub
uses: docker/login-action@v2
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
if: ${{ env.DOCKERHUB_USERNAME != '' }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}
flavor: latest=true

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Show info about built Docker image
uses: essentialkaos/docker-info-action@v1
with:
image: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
show-labels: true
70 changes: 55 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
################################################################################

# This Makefile generated by GoMakeGen 1.5.1 using next command:
# This Makefile generated by GoMakeGen 2.0.0 using next command:
# gomakegen --mod .
#
# More info: https://kaos.sh/gomakegen
Expand All @@ -9,48 +9,88 @@

export GO111MODULE=on

ifdef VERBOSE ## Print verbose information (Flag)
VERBOSE_FLAG = -v
endif

################################################################################

.DEFAULT_GOAL := help
.PHONY = fmt vet all clean deps mod-init mod-update mod-vendor help
.PHONY = fmt vet all clean deps update init vendor mod-init mod-update mod-download mod-vendor help

################################################################################

all: rsz ## Build all binaries

rsz: ## Build rsz binary
go build rsz.go
rsz:
go build $(VERBOSE_FLAG) rsz.go

install: ## Install all binaries
cp rsz /usr/bin/rsz

uninstall: ## Uninstall all binaries
rm -f /usr/bin/rsz

deps: mod-update ## Download dependencies
init: mod-init ## Initialize new module

mod-init: ## Initialize new module
go mod init
go mod tidy
deps: mod-download ## Download dependencies

mod-update: ## Download modules to local cache
update: mod-update ## Update dependencies to the latest versions

vendor: mod-vendor ## Make vendored copy of dependencies

mod-init:
ifdef MODULE_PATH ## Module path for initialization (String)
go mod init $(MODULE_PATH)
else
go mod init
endif

ifdef COMPAT ## Compatible Go version (String)
go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT)
else
go mod tidy $(VERBOSE_FLAG)
endif

mod-update:
ifdef UPDATE_ALL ## Update all dependencies (Flag)
go get -u $(VERBOSE_FLAG) all
else
go get -u $(VERBOSE_FLAG) ./...
endif

ifdef COMPAT
go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT)
else
go mod tidy $(VERBOSE_FLAG)
endif

test -d vendor && go mod vendor $(VERBOSE_FLAG) || :

mod-download:
go mod download

mod-vendor: ## Make vendored copy of dependencies
go mod vendor
mod-vendor:
go mod vendor $(VERBOSE_FLAG)

fmt: ## Format source code with gofmt
find . -name "*.go" -exec gofmt -s -w {} \;

vet: ## Runs go vet over sources
vet: ## Runs 'go vet' over sources
go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./...

clean: ## Remove generated files
rm -f rsz

help: ## Show this info
@echo -e '\n\033[1mSupported targets:\033[0m\n'
@echo -e '\n\033[1mTargets:\033[0m\n'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-12s\033[0m %s\n", $$1, $$2}'
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-14s\033[0m %s\n", $$1, $$2}'
@echo -e '\n\033[1mVariables:\033[0m\n'
@grep -E '^ifdef [A-Z_]+ .*?## .*$$' $(abspath $(lastword $(MAKEFILE_LIST))) \
| sed 's/ifdef //' \
| awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-14s\033[0m %s\n", $$1, $$2}'
@echo -e ''
@echo -e '\033[90mGenerated by GoMakeGen 1.5.1\033[0m\n'
@echo -e '\033[90mGenerated by GoMakeGen 2.0.0\033[0m\n'

################################################################################
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<a href="#license"><img src="https://gh.kaos.st/apache2.svg"></a>
</p>

<p align="center"><a href="#installation">Installation</a> • <a href="#command-line-completion">Command-line completion</a> • <a href="#man-documentation">Man documentation</a> • <a href="#usage">Usage</a> • <a href="#build-status">Build Status</a> • <a href="#contributing">Contributing</a> • <a href="#license">License</a></p>
<p align="center"><a href="#installation">Installation</a> • <a href="#command-line-completion">Command-line completion</a> • <a href="#man-documentation">Man documentation</a> • <a href="#usage">Usage</a> • <a href="#ci-status">CI Status</a> • <a href="#contributing">Contributing</a> • <a href="#license">License</a></p>

<br/>

Expand All @@ -21,7 +21,7 @@
To build the `rsz` from scratch, make sure you have a working Go 1.17+ workspace (_[instructions](https://golang.org/doc/install)_), then:

```
go install github.com/essentialkaos/rsz
go install github.com/essentialkaos/rsz@latest
```

#### Prebuilt binaries
Expand All @@ -32,6 +32,22 @@ You can download prebuilt binaries for Linux and macOS from [EK Apps Repository]
bash <(curl -fsSL https://apps.kaos.st/get) rsz
```

#### Docker Image

The latest version of `rsz` also available as Docker image on [Docker Hub](https://kaos.sh/d/rsz) and [GitHub Container Registry](https://kaos.sh/p/rsz):

```bash
docker pull essentialkaos/rsz:latest
docker run --rm -it essentialkaos/rsz:latest image.png 0.55 thumbnail.png
```

or

```bash
docker pull ghcr.io/essentialkaos/rsz:latest
docker run --rm -it ghcr.io/essentialkaos/rsz:latest image.png 0.55 thumbnail.png
```

### Command-line completion

You can generate completion for `bash`, `zsh` or `fish` shell.
Expand Down Expand Up @@ -85,13 +101,12 @@ Examples
rsz image.png 0.55 thumbnail.png
Convert image to relative size (55% of original)
```

### Build Status
### CI Status

| Branch | Status |
|--------|----------|
|--------|--------|
| `master` | [![CI](https://kaos.sh/w/rsz/ci.svg?branch=master)](https://kaos.sh/w/rsz/ci?query=branch:master) |
| `develop` | [![CI](https://kaos.sh/w/rsz/ci.svg?branch=develop)](https://kaos.sh/w/rsz/ci?query=branch:develop) |

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ go 1.17

require (
github.com/disintegration/imaging v1.6.2
github.com/essentialkaos/ek/v12 v12.43.0
github.com/essentialkaos/ek/v12 v12.45.0
)

require (
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
)
17 changes: 10 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/essentialkaos/check v1.2.1 h1:avvyFy/1acUNwfxwuOLsHeCjfXtMygtbu0lVDr3nxFs=
github.com/essentialkaos/check v1.2.1/go.mod h1:PhxzfJWlf5L/skuyhzBLIvjMB5Xu9TIyDIsqpY5MvB8=
github.com/essentialkaos/ek/v12 v12.43.0 h1:lnwrfGYQFJ3EjEF4ydW2qnshDcXCR2OnNRk0kwlFpFE=
github.com/essentialkaos/ek/v12 v12.43.0/go.mod h1:Cv/tOZshmFg4pMJnBkg4aW/WyYhzzc41qzZIfk5RSi4=
github.com/essentialkaos/check v1.3.0 h1:ria+8o22RCLdt2D/1SHQsEH5Mmy5S+iWHaGHrrbPUc0=
github.com/essentialkaos/check v1.3.0/go.mod h1:PhxzfJWlf5L/skuyhzBLIvjMB5Xu9TIyDIsqpY5MvB8=
github.com/essentialkaos/ek/v12 v12.45.0 h1:5KVZl5MAsPwxfjda+wb+cCxneQ747lU9zA5mjCA5Fyg=
github.com/essentialkaos/ek/v12 v12.45.0/go.mod h1:uQUkpvaZHWR9aI8GfknZqOG5FC+G2PYJLFyMw9fdjbo=
github.com/essentialkaos/go-linenoise/v3 v3.3.5/go.mod h1:g4X3LhT83XT4h7xwrCLclAdMkJvS9qWBQTGNdS6y4vo=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
Expand All @@ -13,17 +14,19 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg=
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
8 changes: 5 additions & 3 deletions rsz.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
// Basic utility info
const (
APP = "rsz"
VER = "0.0.3"
VER = "0.0.4"
DESC = "Simple utility for image resizing"
)

Expand Down Expand Up @@ -176,8 +176,10 @@ func listFilters() {
}

// process starts image processing
func process(args []string) {
srcImage, size, outImage := args[0], args[1], args[2]
func process(args options.Arguments) {
srcImage := args.Get(0).Clean().String()
size := args.Get(1).String()
outImage := args.Get(2).Clean().String()

err := checkSrcImage(srcImage)

Expand Down

0 comments on commit ae2fb30

Please sign in to comment.