Skip to content

Commit

Permalink
Merge pull request #15 from funbox/develop
Browse files Browse the repository at this point in the history
Version 0.12.0
  • Loading branch information
andyone authored Mar 10, 2023
2 parents 3c9ccb0 + d22b459 commit aa32f5e
Show file tree
Hide file tree
Showing 8 changed files with 243 additions and 156 deletions.
30 changes: 30 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 2

updates:
- package-ecosystem: "gomod"
directory: "/"
target-branch: "develop"
schedule:
interval: "daily"
timezone: "Europe/Moscow"
time: "15:00"
labels:
- "PR • MAINTENANCE"
assignees:
- "andyone"
reviewers:
- "andyone"

- package-ecosystem: "github-actions"
directory: "/"
target-branch: "develop"
schedule:
interval: "daily"
timezone: "Europe/Moscow"
time: "15:00"
labels:
- "PR • MAINTENANCE"
assignees:
- "andyone"
reviewers:
- "andyone"
62 changes: 28 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,40 @@ on:
branches: [master, develop]
pull_request:
branches: [master]
workflow_dispatch:
inputs:
force_run:
description: 'Force workflow run'
required: true
type: choice
options: [yes, no]

permissions:
actions: read
contents: read
statuses: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

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

jobs:
Go:
name: Go
runs-on: ubuntu-latest

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

strategy:
matrix:
go: [ '1.17.x', '1.18.x' ]
go: [ '1.19.x', '1.20.x' ]

steps:
- name: Set up Go
uses: actions/setup-go@v2
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 @@ -39,8 +47,7 @@ jobs:

- name: Download dependencies
working-directory: ${{env.SRC_DIR}}
run: |
make deps
run: make deps

- name: Build binaries
working-directory: ${{env.SRC_DIR}}
Expand All @@ -52,22 +59,11 @@ jobs:

needs: Go

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

steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.17.x'
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"
go-version: '1.19.x'

- name: Checkout
uses: actions/checkout@v3
Expand All @@ -94,16 +90,14 @@ jobs:
- name: Code checkout
uses: actions/checkout@v3

- name: Login to DockerHub
uses: docker/login-action@v1
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
if: ${{ env.DOCKERHUB_USERNAME != '' }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Check specs with Perfecto
uses: essentialkaos/perfecto-action@v1
uses: essentialkaos/perfecto-action@v2
with:
files: common/init-exporter-converter.spec
71 changes: 57 additions & 14 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.2.0 using next command:
# gomakegen --mod .
#
# More info: https://kaos.sh/gomakegen
Expand All @@ -9,48 +9,91 @@

export GO111MODULE=on

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

MAKEDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD)

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

.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: init-exporter-converter ## Build all binaries

init-exporter-converter: ## Build init-exporter-converter binary
go build init-exporter-converter.go
init-exporter-converter:
go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" init-exporter-converter.go

install: ## Install all binaries
cp init-exporter-converter /usr/bin/init-exporter-converter

uninstall: ## Uninstall all binaries
rm -f /usr/bin/init-exporter-converter

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

update: mod-update ## Update dependencies to the latest versions

mod-update: ## Download modules to local cache
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 && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :

mod-download:
go mod download

mod-vendor: ## Make vendored copy of dependencies
go mod vendor
mod-vendor:
rm -rf 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 init-exporter-converter

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%-25s\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.2.0\033[0m\n'

################################################################################
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,16 @@ Utility for converting [`init-exporter`](https://github.com/funbox/init-exporter

#### From sources

To build the `init-exporter-converter` from scratch, make sure you have a working Go 1.16+ workspace ([instructions](https://golang.org/doc/install)), then:
To build the `init-exporter-converter` from scratch, make sure you have a working Go 1.18+ workspace ([instructions](https://golang.org/doc/install)), then:

```
go get github.com/funbox/init-exporter-converter
```

If you want to update `init-exporter-converter` to latest stable release, do:

```
go get -u github.com/funbox/init-exporter-converter
go install github.com/funbox/init-exporter-converter@latest
```

#### From [ESSENTIAL KAOS Public Repository](https://yum.kaos.st)

```
sudo yum install -y https://yum.kaos.st/get/$(uname -r).rpm
sudo yum install -y https://yum.kaos.st/kaos-repo-latest.el$(grep 'CPE_NAME' /etc/os-release | tr -d '"' | cut -d':' -f5).noarch.rpm
sudo yum install init-exporter-converter
```

Expand Down
80 changes: 27 additions & 53 deletions common/init-exporter-converter.spec
Original file line number Diff line number Diff line change
@@ -1,60 +1,24 @@
################################################################################

# rpmbuilder:relative-pack true
%define debug_package %{nil}

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

%define _posixroot /
%define _root /root
%define _bin /bin
%define _sbin /sbin
%define _srv /srv
%define _home /home
%define _lib32 %{_posixroot}lib
%define _lib64 %{_posixroot}lib64
%define _libdir32 %{_prefix}%{_lib32}
%define _libdir64 %{_prefix}%{_lib64}
%define _logdir %{_localstatedir}/log
%define _rundir %{_localstatedir}/run
%define _lockdir %{_localstatedir}/lock/subsys
%define _cachedir %{_localstatedir}/cache
%define _spooldir %{_localstatedir}/spool
%define _crondir %{_sysconfdir}/cron.d
%define _loc_prefix %{_prefix}/local
%define _loc_exec_prefix %{_loc_prefix}
%define _loc_bindir %{_loc_exec_prefix}/bin
%define _loc_libdir %{_loc_exec_prefix}/%{_lib}
%define _loc_libdir32 %{_loc_exec_prefix}/%{_lib32}
%define _loc_libdir64 %{_loc_exec_prefix}/%{_lib64}
%define _loc_libexecdir %{_loc_exec_prefix}/libexec
%define _loc_sbindir %{_loc_exec_prefix}/sbin
%define _loc_bindir %{_loc_exec_prefix}/bin
%define _loc_datarootdir %{_loc_prefix}/share
%define _loc_includedir %{_loc_prefix}/include
%define _rpmstatedir %{_sharedstatedir}/rpm-state
%define _pkgconfigdir %{_libdir}/pkgconfig
Summary: Utility for converting init-exporter procfiles from v1 to v2 format
Name: init-exporter-converter
Version: 0.12.0
Release: 0%{?dist}
Group: Development/Tools
License: MIT
URL: https://github.com/funbox/init-exporter-converter

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

%define debug_package %{nil}

################################################################################
Source0: %{name}-%{version}.tar.gz

Summary: Utility for converting init-exporter procfiles from v1 to v2 format
Name: init-exporter-converter
Version: 0.11.2
Release: 0%{?dist}
Group: Development/Tools
License: MIT
URL: https://github.com/funbox/init-exporter-converter
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

Source0: %{name}-%{version}.tar.gz
BuildRequires: golang >= 1.19

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires: golang >= 1.17

Provides: %{name} = %{version}-%{release}
Provides: %{name} = %{version}-%{release}

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

Expand All @@ -67,17 +31,21 @@ Utility for exporting services described by Procfile to init system.
%setup -q

%build
export GOPATH=$(pwd)
pushd src/github.com/funbox/%{name}
go build -mod vendor %{name}.go
if [[ ! -d "%{name}/vendor" ]] ; then
echo "This package requires vendored dependencies"
exit 1
fi

pushd %{name}
%{__make} %{?_smp_mflags} all
cp LICENSE ..
popd

%install
rm -rf %{buildroot}

install -dm 755 %{buildroot}%{_bindir}
install -pm 755 src/github.com/funbox/%{name}/%{name} \
%{buildroot}%{_bindir}/
install -pm 755 %{name}/%{name} %{buildroot}%{_bindir}/

%clean
rm -rf %{buildroot}
Expand All @@ -86,11 +54,17 @@ rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%doc LICENSE
%{_bindir}/init-exporter-converter

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

%changelog
* Fri Mar 10 2023 Anton Novojilov <[email protected]> - 0.12.0-0
- Added verbose version output
- Dependencies update
- Code refactoring

* Fri Apr 01 2022 Anton Novojilov <[email protected]> - 0.11.2-0
- Removed pkg.re usage
- Added module info
Expand Down
Loading

0 comments on commit aa32f5e

Please sign in to comment.