Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Actions #201

Open
wants to merge 14 commits into
base: actions-test
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/buildandrelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build and Release

on:
workflow_dispatch:
inputs:
version:
description: 'TimeTrace Version'
required: false
release:
types: [published]

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 18 additions & 0 deletions .github/workflows/formatandtest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Format and Test

on:
push:

jobs:
tests:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: format
run: go fmt ./...
-
name: test
run: go test -v ./...
36 changes: 0 additions & 36 deletions .github/workflows/main.yml

This file was deleted.

61 changes: 61 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Publish Docker

on:
workflow_dispatch:
inputs:
tag:
description: 'docker tag'
required: true
release:
types: [published]

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Set tag
id: set_tag
run: |
if [[ $GITHUB_EVENT_NAME == "workflow_dispatch" ]]; then
echo "VERSION=${{ github.event.inputs.tag }} " >> $GITHUB_ENV
elif [[ $GITHUB_EVENT_NAME == "release" ]]; then
echo "VERSION=$GITHUB_REF_NAME" >> $GITHUB_ENV
else
exit 1
fi
echo ${{ env.VERSION }}
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to Github Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and Push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64
push: true
tags: |
${{ github.repository }}:${{ env.VERSION }}
ghcr.io/${{ github.repository }}:${{ env.VERSION }}
build-args: |
VERSION=${{ env.VERSION }}
35 changes: 35 additions & 0 deletions .github/workflows/release_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release Check

on:
workflow_dispatch:
inputs:
version:
description: 'TimeTrace Version'
required: false
release:
types: [created]

permissions:
contents: write

jobs:
checks:
runs-on: ubuntu-latest
steps:
-
name: Set Tag
run: |
if [[ $GITHUB_EVENT_NAME == "workflow_dispatch" ]]; then
echo "VERSION=${{ github.event.inputs.tag }} " >> $GITHUB_ENV
elif [[ $GITHUB_EVENT_NAME == "release" ]]; then
echo "VERSION=$GITHUB_REF_NAME" >> $GITHUB_ENV
else
exit 1
fi
echo ${{ env.VERSION }}
-
name: Checkout
uses: actions/checkout@v2
-
name: Run Checks
run: python release.py check-changelog --tag=${{ env.Version }}
31 changes: 31 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
16 changes: 6 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# This Dockerfile builds a lightweight distribution image for Docker Hub.
# It only contains the application without any source code.
FROM alpine:3.11.5 AS downloader
FROM golang:latest as builder

# The timetrace release to be downloaded from GitHub.
ARG VERSION
WORKDIR /
COPY *.go go.* ./
RUN CGO_ENABLED=0 go build -mod=mod -a -installsuffix temp -ldflags "-extldflags '-static' -X 'main.version=${VERSION}'" .

RUN apk add --no-cache \
curl \
tar

RUN curl -LO https://github.com/dominikbraun/timetrace/releases/download/${VERSION}/timetrace-linux-amd64.tar.gz && \
tar -xvf timetrace-linux-amd64.tar.gz -C /bin && \
rm -f timetrace-linux-amd64.tar.gz

# The final stage. This is the image that will be distrubuted.
FROM alpine:3.11.5 AS final
Expand All @@ -25,10 +21,10 @@ LABEL org.label-schema.url="https://github.com/dominikbraun/timetrace"
LABEL org.label-schema.vcs-url="https://github.com/dominikbraun/timetrace"
LABEL org.label-schema.version=${VERSION}

COPY --from=downloader ["/bin/timetrace", "/bin/timetrace"]
COPY --from=builder ["/timetrace", "/bin/timetrace"]

# Create a symlink for musl, see https://stackoverflow.com/a/35613430.
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
#RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2

RUN mkdir /etc/timetrace && \
echo "store: '/data'" >> /etc/timetrace/config.yml
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.15

require (
github.com/enescakir/emoji v1.0.0
github.com/fatih/color v1.13.0
github.com/fatih/color v1.17.0
github.com/olekukonko/tablewriter v0.0.5
github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.9.0
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.15.0
)
Loading