From 7f3748c39d4ceb127f93dfa8f0dd9f441d7cc6c2 Mon Sep 17 00:00:00 2001
From: pete911
Date: Fri, 10 Sep 2021 19:42:26 +0100
Subject: [PATCH] migrate from travis to github actions and remove docker
---
.dockerignore | 3 ---
.github/dependabot.yml | 5 ----
.github/workflows/release.yml | 36 ++++++++++++++++++++++++++++
.gitignore | 3 ++-
.goreleaser.yml | 37 ++++++++++++++++++++++++++++
.travis.yml | 45 -----------------------------------
Dockerfile | 13 ----------
Makefile | 29 +++-------------------
README.md | 21 +++++++++++++---
releases/README.md | 1 -
10 files changed, 96 insertions(+), 97 deletions(-)
delete mode 100644 .dockerignore
create mode 100644 .github/workflows/release.yml
create mode 100644 .goreleaser.yml
delete mode 100644 .travis.yml
delete mode 100644 Dockerfile
delete mode 100644 releases/README.md
diff --git a/.dockerignore b/.dockerignore
deleted file mode 100644
index d23e522..0000000
--- a/.dockerignore
+++ /dev/null
@@ -1,3 +0,0 @@
-ipcalc
-.git
-releases/*
\ No newline at end of file
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index c743e1e..d921d0f 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -5,8 +5,3 @@ updates:
schedule:
interval: daily
open-pull-requests-limit: 10
-- package-ecosystem: docker
- directory: "/"
- schedule:
- interval: daily
- open-pull-requests-limit: 10
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..2fbe954
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,36 @@
+name: goreleaser
+
+on:
+ push:
+ tags:
+ - '*'
+
+permissions:
+ contents: write
+
+jobs:
+ goreleaser:
+ runs-on: ubuntu-latest
+ steps:
+ -
+ name: Checkout
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+ -
+ name: Set up Go
+ uses: actions/setup-go@v2
+ with:
+ go-version: 1.17
+ -
+ name: Run tests
+ run: make test
+ -
+ name: Run GoReleaser
+ uses: goreleaser/goreleaser-action@v2
+ with:
+ distribution: goreleaser
+ version: latest
+ args: release --rm-dist
+ env:
+ GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_TOKEN }}
diff --git a/.gitignore b/.gitignore
index 7c0787c..ea52f7d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-/ipcalc
\ No newline at end of file
+/ipcalc
+/releases/*
diff --git a/.goreleaser.yml b/.goreleaser.yml
new file mode 100644
index 0000000..da3ff6b
--- /dev/null
+++ b/.goreleaser.yml
@@ -0,0 +1,37 @@
+builds:
+ -
+ goos:
+ - linux
+ - darwin
+ - windows
+ goarch:
+ - amd64
+ - arm64
+ ldflags:
+ - -X main.Version={{.Version}}
+checksum:
+ name_template: 'checksums.txt'
+dist: releases
+changelog:
+ sort: asc
+ filters:
+ exclude:
+ - '^docs:'
+ - '^test:'
+release:
+ github:
+ owner: pete911
+ name: ipcalc
+brews:
+ - tap:
+ owner: pete911
+ name: homebrew-tap
+ token: "{{ .Env.GITHUB_TOKEN }}"
+ name: ipcalc
+ homepage: "https://github.com/pete911/ipcalc"
+ description: "IP calculator"
+ folder: Formula
+ install: |
+ bin.install "ipcalc"
+ test: |
+ assert_match /version/, shell_output("#{bin}/ipcalc", 0)
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 151ebfd..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,45 +0,0 @@
-language: go
-
-env:
- - VERSION="0.$TRAVIS_BUILD_NUMBER"
-
-go:
- - 1.16.x
-
-git:
- depth: false
- quiet: true
- submodules: false
-
-branches:
- only:
- - main
-
-services:
- - docker
-
-script:
- - "make test"
- - "VERSION=$VERSION make image"
- - "make release"
-
-before_deploy:
- - git config --local user.name "pete911"
- - git config --local user.email "p.reisinger@gmail.com"
- - git tag $VERSION
-
-deploy:
- provider: releases
- api_key: $GITHUB_TOKEN
- file:
- - "releases/ipcalc_darwin_amd64.tar.gz"
- - "releases/ipcalc_darwin_arm64.tar.gz"
- - "releases/ipcalc_linux_amd64.tar.gz"
- - "releases/ipcalc_windows_amd64.tar.gz"
- skip_cleanup: true
- on:
- branch: main
-
-after_success:
- - echo "$DOCKER_PASSWORD" | docker login --username $DOCKER_USERNAME --password-stdin
- - VERSION=$VERSION make push-image
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index dc325ad..0000000
--- a/Dockerfile
+++ /dev/null
@@ -1,13 +0,0 @@
-FROM golang:1.17.1-alpine AS build
-RUN apk add --no-cache gcc libc-dev
-
-WORKDIR /go/src/app
-COPY . .
-RUN go test ./...
-ARG version=dev
-RUN go build -ldflags "-X main.Version=$version" -o /bin/ipcalc
-
-FROM alpine:3.14.2
-
-COPY --from=build /bin/ipcalc /usr/local/bin/ipcalc
-ENTRYPOINT ["ipcalc"]
diff --git a/Makefile b/Makefile
index 07bee2a..ffdb0d9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,3 @@
-NAME := ipcalc
-IMAGE := pete911/${NAME}
VERSION ?= dev
test:
@@ -10,27 +8,6 @@ build: test
go build -ldflags "-X main.Version=${VERSION}"
.PHONY:build
-image:
- docker build --build-arg version=${VERSION} -t ${IMAGE}:${VERSION} .
- docker tag ${IMAGE}:${VERSION} ${IMAGE}:latest
-.PHONY:image
-
-push-image:
- docker push ${IMAGE}:${VERSION}
- docker push ${IMAGE}:latest
-.PHONY:push-image
-
-release:
- # amd64
- for GOOS in "linux" "darwin" "windows"; do \
- BUILD_CMD="GOOS=$$GOOS GOARCH=amd64 go build -ldflags \"-X main.Version=${VERSION}\" -o releases/${NAME}" ; \
- TAR_CMD="tar -czvf releases/${NAME}_$${GOOS}_amd64.tar.gz -C releases/ ${NAME} && rm releases/${NAME}" ; \
- docker run --rm -it -v "${PWD}":/usr/src/app -w /usr/src/app -e CGO_ENABLED=0 golang:1.16-alpine sh -c "$$BUILD_CMD && $$TAR_CMD" ; \
- done
- # arm64
- for GOOS in "darwin"; do \
- BUILD_CMD="GOOS=$$GOOS GOARCH=arm64 go build -ldflags \"-X main.Version=${VERSION}\" -o releases/${NAME}" ; \
- TAR_CMD="tar -czvf releases/${NAME}_$${GOOS}_arm64.tar.gz -C releases/ ${NAME} && rm releases/${NAME}" ; \
- docker run --rm -it -v "${PWD}":/usr/src/app -w /usr/src/app -e CGO_ENABLED=0 golang:1.16-alpine sh -c "$$BUILD_CMD && $$TAR_CMD" ; \
- done
-.PHONY:release
+install: test
+ go install -ldflags "-X main.Version=${VERSION}"
+.PHONY:install
diff --git a/README.md b/README.md
index 2db7ef3..e451e63 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,3 @@
-[![Build Status](https://travis-ci.com/pete911/ipcalc.svg?branch=main)](https://travis-ci.com/pete911/ipcalc)
-
# ipcalc
Go implementation of ipcalc command.
@@ -11,7 +9,24 @@ Go implementation of ipcalc command.
## download
- [binary](https://github.com/pete911/ipcalc/releases)
-- [docker](https://hub.docker.com/repository/docker/pete911/ipcalc)
+
+## build/install
+
+### brew
+
+- add tap `brew tap pete911/tap`
+- install `brew install ipcalc`
+
+### go
+
+[go](https://golang.org/dl/) has to be installed.
+- build `make build`
+- install `make install`
+
+## release
+
+Releases are published when the new tag is created e.g.
+`git tag -m "add super cool feature" v1.0.0 && git push --follow-tags`
## run
diff --git a/releases/README.md b/releases/README.md
deleted file mode 100644
index 4c4bbf1..0000000
--- a/releases/README.md
+++ /dev/null
@@ -1 +0,0 @@
-output directory for `make release` command
\ No newline at end of file