Skip to content

Commit

Permalink
feat(build): adding build output for new mac processor (#4)
Browse files Browse the repository at this point in the history
* feat(build): adding build output for mac m1

* fix(lint): remove unnecessary lint and lock linter version

* fix(pipeline): fixing version

* fix(deprecations): remove usage of deprecated std lib
  • Loading branch information
iomarmochtar authored May 13, 2024
1 parent 9747acf commit ea197b4
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 33 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- v*

env:
GO_VERSION: 1.17
GO_VERSION: 1.22

jobs:
release:
Expand All @@ -16,8 +16,6 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: install upx
run: sudo apt install upx-ucl -y
- name: GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: tests
on: [pull_request, workflow_dispatch]

env:
GO_VERSION: 1.17
GO_VERSION: 1.22
GOLANGCI_VERSION: 1.58
CGO_ENABLED: 0

jobs:
Expand All @@ -16,7 +17,7 @@ jobs:
go-version: ${{ env.GO_VERSION }}
- uses: golangci/golangci-lint-action@v2
with:
version: latest
version: v${{ env.GOLANGCI_VERSION }}

unit-test:
name: unit-test
Expand Down
4 changes: 1 addition & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ linters-settings:

linters:
enable:
- megacheck
- govet
- revive
- gocyclo
Expand All @@ -27,9 +26,8 @@ linters:
- goimports
- whitespace
- misspell
- depguard
- importas
- contextcheck
- nolintlint
- revive

- staticcheck
26 changes: 11 additions & 15 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,21 @@ builds:
goos:
- darwin
- linux
- windows
goarch:
- amd64
hooks:
post:
- upx --brute "{{ .Path }}"
- arm64
ignore:
- goos: linux
goarch: arm64
ldflags:
- -s -w -X github.com/iomarmochtar/content-plus-totp/app.Version={{.Version}}

checksum:
name_template: 'checksums.txt'

archives:
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}_{{ .Version }}'
format: tar.gz
replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
format_overrides:
- goos: windows
format: zip
- files:
# Only include built binary in archive
- 'none*'
format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 0.2.0

## Features and enhancements

- add build target for Mac M1 processor.
- dynamic version injection in compilation process.
- bump go version to 1.22 .

## Bug Fixes

- remove the usage of upx due problematic in resulting macos binary ([ref](https://github.com/upx/upx/issues/424)).
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ lint:
.PHONY: test-all
test-all: test lint

.PHONY: compile
compile:
.PHONY: compile-linux
compile-linux:
GOARCH=amd64 CGO_ENABLED=0 GOOS=linux go build -o dist/${NAME} main.go

# default compile target to linux
.PHONY: compile
compile: compile-linux
2 changes: 1 addition & 1 deletion app/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func NewCmd() cli.App {
return cli.App{
Name: "content-plus-totp",
Usage: "an easy way to combine static content such as password with totp token",
Version: VERSION,
Version: Version,
Compiled: time.Now(),
EnableBashCompletion: true,
Flags: []cli.Flag{
Expand Down
4 changes: 3 additions & 1 deletion app/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package app

const VERSION = "0.1.0"
var (
Version = "dev"
)
3 changes: 1 addition & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package config
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
)

Expand All @@ -20,7 +19,7 @@ func NewByPath(path string) (*Config, error) {
return nil, fmt.Errorf("%s is a directory", path)
}

jsonContent, err := ioutil.ReadFile(path)
jsonContent, err := os.ReadFile(path)
if err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package config_test

import (
"fmt"
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -45,7 +44,7 @@ func TestReadConfig(t *testing.T) {

func TestReadConfigByPath(t *testing.T) {
getTmpFile := func() string {
tempFile, err := ioutil.TempFile(os.TempDir(), "test_read_path")
tempFile, err := os.CreateTemp(os.TempDir(), "test_read_path")
if err != nil {
panic(err)
}
Expand All @@ -61,7 +60,7 @@ func TestReadConfigByPath(t *testing.T) {
preExec: func() string {
tmpFile := getTmpFile()
jsonContent := `{"content_enc": "aGVsbG8K", "totp_master_enc": "d29ybGQK"}`
if err := ioutil.WriteFile(tmpFile, []byte(jsonContent), 0600); err != nil {
if err := os.WriteFile(tmpFile, []byte(jsonContent), 0600); err != nil {
panic(err)
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/iomarmochtar/content-plus-totp

go 1.17
go 1.22

require (
github.com/atotto/clipboard v0.1.4
Expand Down

0 comments on commit ea197b4

Please sign in to comment.