From b8795f965d0f3dace95100cfeb87e6651c769b1c Mon Sep 17 00:00:00 2001 From: mdm-code Date: Sun, 4 Feb 2024 15:54:58 +0100 Subject: [PATCH 1/7] Aligned Makefile with the release in Github remote --- Makefile | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 8764bad..d65c46c 100644 --- a/Makefile +++ b/Makefile @@ -1,45 +1,38 @@ GO=go -GOFLAGS=-race -DEV_BIN=bin -COV_PROFILE=cp.out +GOFLAGS= +COV_PROFILE=coverage.txt -export CGO_ENABLED = 1 +export CGO_ENABLED=0 .DEFAULT_GOAL := build +.PHONY: fmt vet lint test install build cover clean + fmt: - $(GO) fmt ./... -.PHONY: fmt + @$(GO) fmt ./... vet: fmt - $(GO) vet ./... -.PHONY: vet + @$(GO) vet ./... lint: vet - golint -set_exit_status=1 ./... -.PHONY: lint + @golint -set_exit_status=1 ./... test: lint - $(GO) clean -testcache - $(GO) test ./... -v -.PHONY: test + @$(GO) clean -testcache + @$(GO) test ./... -v install: test - $(GO) install ./... -.PHONY: install + @$(GO) install ./... build: test - $(GO) build $(GOFLAGS) github.com/mdm-code/termcols/... -.PHONY: build + @$(GO) build $(GOFLAGS) github.com/mdm-code/termcols/... cover: - $(GO) test -coverprofile=$(COV_PROFILE) -covermode=atomic ./... - $(GO) tool cover -html=$(COV_PROFILE) -.PHONY: cover + @$(GO) test -coverprofile=$(COV_PROFILE) -covermode=atomic ./... + @$(GO) tool cover -html=$(COV_PROFILE) clean: - $(GO) clean github.com/mdm-code/termcols/... - $(GO) mod tidy - $(GO) clean -testcache - rm -f $(COV_PROFILE) -.PHONY: clean + @$(GO) clean github.com/mdm-code/termcols/... + @$(GO) mod tidy + @$(GO) clean -testcache + @rm -f $(COV_PROFILE) From 96b3aaababcf4fbceb2ad2b93e16f3edb9520eca Mon Sep 17 00:00:00 2001 From: mdm-code Date: Sun, 4 Feb 2024 15:56:50 +0100 Subject: [PATCH 2/7] Included goreleaser configuration file in repo --- .goreleaser.yaml | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .goreleaser.yaml diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..a06efc9 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,73 @@ +before: + hooks: + - go mod tidy + - go fmt ./... + - go test ./... + +builds: + - id: tcols + main: ./cmd/tcols + binary: tcols + env: + - CGO_ENABLED=0 + flags: + - -trimpath + ldflags: + - -X main.version={{ .Version }} -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }} + mod_timestamp: '{{ .CommitTimestamp }}' + targets: + - linux_amd64 + - linux_arm64 + - linux_arm + - linux_riscv64 + - windows_amd64 + - windows_arm64 + - windows_arm + - darwin_amd64 + - darwin_arm64 + +universal_binaries: + - id: tcols + replace: true + name_template: tcols + +archives: +- id: tcols + format: tar.gz + builds: + - tcols + files: + - none* + name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + +dockers: + - id: tools + goos: linux + goarch: amd64 + ids: + - tcols + image_templates: + - "ghcr.io/mdm-code/tcols:latest" + - "ghcr.io/mdm-code/tcols:{{ .Tag }}" + - "ghcr.io/mdm-code/tcols:v{{ .Major }}" + skip_push: false + +checksum: + name_template: 'sha256sums.txt' + +snapshot: + name_template: "{{ incpatch .Version }}-next" + +release: + github: + owner: mdm-code + name: tcols + draft: true + prerelease: auto + mode: replace + +changelog: + use: github-native + +announce: + skip: true From 3588612658bf0095d044ba8c5a48b6e52644595a Mon Sep 17 00:00:00 2001 From: mdm-code Date: Sun, 4 Feb 2024 15:57:20 +0100 Subject: [PATCH 3/7] Added release Github action to the termcols --- .github/workflows/release.yaml | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..25e9ae0 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,43 @@ +name: release + +on: + push: + tags: + - '*' + workflow_call: + inputs: + args: + description: 'Extra arguments to pass to goreleaser' + default: '' + required: false + type: string + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.21' + + - name: Login to Github container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Release + uses: goreleaser/goreleaser-action@v3 + with: + distribution: goreleaser + version: latest + args: release ${{ inputs.args }} --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 74b625f49b770edde21f0b11b413681dab0561bb Mon Sep 17 00:00:00 2001 From: mdm-code Date: Sun, 4 Feb 2024 15:57:52 +0100 Subject: [PATCH 4/7] Adjusted CI action in termcols to new practices --- .github/workflows/go.yaml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index 4585373..8427260 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -10,18 +10,21 @@ jobs: build: strategy: matrix: - go-version: [ '1.19', '1.21' ] - os: [ ubuntu-latest, macos-latest ] + go: [ '1.21' ] + os: [ windows-latest, ubuntu-latest, macos-latest ] runs-on: ${{ matrix.os }} + name: ${{ matrix.go }}/${{ matrix.os }} steps: - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: - go-version: ${{ matrix.go-version }} + go-version: ${{ matrix.go }} - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Install dependencies run: | @@ -32,10 +35,15 @@ jobs: run: make build - name: Test - run: go test -v -coverprofile coverage.txt -covermode atomic ./... + run: go test -v -coverprofile='coverage.txt' -covermode='atomic' ./... - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} verbose: true + + release-check: + uses: ./.github/workflows/release.yaml + with: + args: --snapshot From ef9226847a4696b3e2ea6b1861dbce8d35782c34 Mon Sep 17 00:00:00 2001 From: mdm-code Date: Sun, 4 Feb 2024 16:05:51 +0100 Subject: [PATCH 5/7] Added Dockerfile used by the releaser --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bed0d91 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +ENV PATH "$PATH:/bin" +COPY tcols /bin/tcols From 9c4e595f116d8ad35f6924048888daeabbcb4ea1 Mon Sep 17 00:00:00 2001 From: mdm-code Date: Sun, 4 Feb 2024 16:06:17 +0100 Subject: [PATCH 6/7] Updated date of the license --- LICENSE | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 1b41b11..a43a025 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Michał Adamczyk +Copyright (c) 2024 Michał Adamczyk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 75ec086..d70296c 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ This will give you ns/op value for the setup it's been benchmarked on. ## License -Copyright (c) 2022 Michał Adamczyk. +Copyright (c) 2024 Michał Adamczyk. This project is licensed under the [MIT license](https://opensource.org/licenses/MIT). See [LICENSE](LICENSE) for more details. From edf814ddfb3cada6f0973168a9bd2e7a1bdb5ecb Mon Sep 17 00:00:00 2001 From: mdm-code Date: Sun, 4 Feb 2024 16:12:28 +0100 Subject: [PATCH 7/7] Mentioned Docker image release in the README file --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index d70296c..5e80ac4 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,13 @@ Type `tcols -h` to get a list of styles and colors to (1) see what is implemente and (2) what is supported by your terminal. +Alternatively, `tcols` can be run from inside of the Docker container: + +```sh +docker run -i ghcr.io/mdm-code/tcols:latest tcols -s 'redfg bluebg' < <(echo -n 'Hello, world!') +``` + + ## Development Consult [Makefile](Makefile) to see how to format, examine code with `go vet`,