Skip to content

Commit a4d5d13

Browse files
committed
Update versions
1 parent 2da9331 commit a4d5d13

11 files changed

+235
-312
lines changed

.github/workflows/docker-publish.yml

+35-62
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,48 @@
1-
name: Docker
1+
name: Docker Publish
22

33
on:
4+
pull_request: {}
45
push:
5-
# Publish `master` as Docker `latest` image.
66
branches:
7-
- master
8-
9-
# Publish `v1.2.3` tags as releases.
7+
- main
108
tags:
119
- v*
1210

13-
# Run tests for any PRs.
14-
pull_request:
15-
1611
env:
17-
IMAGE_NAME: sort-it
12+
IMAGE_NAME: ${{ github.repository }}
13+
REGISTRY: ghcr.io
1814

1915
jobs:
20-
# Run tests.
21-
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
22-
test:
23-
runs-on: ubuntu-latest
24-
25-
steps:
26-
- uses: actions/checkout@v2
27-
28-
- name: Run tests
29-
run: |
30-
if [ -f docker-compose.test.yml ]; then
31-
docker-compose --file docker-compose.test.yml build
32-
docker-compose --file docker-compose.test.yml run sut
33-
else
34-
docker build . --file Dockerfile
35-
fi
36-
37-
# Push image to GitHub Packages.
38-
# See also https://docs.docker.com/docker-hub/builds/
3916
push:
40-
# Ensure test job passes before pushing image.
41-
needs: test
42-
17+
name: Push Docker image to GitHub container registry
4318
runs-on: ubuntu-latest
44-
if: github.event_name == 'push'
45-
4619
steps:
47-
- uses: actions/checkout@v2
48-
49-
- name: Build image
50-
run: docker build . --file Dockerfile --tag $IMAGE_NAME
51-
52-
- name: Log into registry
53-
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
54-
55-
- name: Push image
56-
run: |
57-
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
58-
59-
# Change all uppercase to lowercase
60-
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
61-
62-
# Strip git ref prefix from version
63-
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
64-
65-
# Strip "v" prefix from tag name
66-
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
67-
68-
# Use Docker `latest` tag convention
69-
[ "$VERSION" == "master" ] && VERSION=latest
70-
71-
echo IMAGE_ID=$IMAGE_ID
72-
echo VERSION=$VERSION
73-
74-
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
75-
docker push $IMAGE_ID:$VERSION
20+
# Check out repository
21+
- name: Check out repository
22+
uses: actions/checkout@v2
23+
# Log in to container registry
24+
- name: Log in to the container registry
25+
uses: docker/login-action@v1
26+
with:
27+
registry: ${{ env.REGISTRY }}
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
# Generate tags/labels
31+
- id: docker_meta
32+
name: Docker meta
33+
uses: docker/metadata-action@v3
34+
with:
35+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
36+
tags: |
37+
type=ref,event=branch
38+
type=ref,event=pr
39+
type=semver,pattern={{version}}
40+
type=semver,pattern={{major}}.{{minor}}
41+
# Build and push container image
42+
- name: Build and push
43+
uses: docker/build-push-action@v2
44+
with:
45+
context: .
46+
labels: ${{ steps.docker_meta.outputs.labels }}
47+
push: ${{ github.event_name != 'pull_request' }}
48+
tags: ${{ steps.docker_meta.outputs.tags }}

.github/workflows/gitlint.yml

-21
This file was deleted.

.github/workflows/goreleaser.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: GoReleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
steps:
12+
# Checkout code
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
# Set up go
18+
- name: Set up Go
19+
uses: actions/setup-go@v3
20+
with:
21+
go-version: 1.18.1
22+
# Run GoReleaser
23+
- name: Run GoReleaser
24+
uses: goreleaser/goreleaser-action@v2
25+
with:
26+
args: release --rm-dist
27+
distribution: goreleaser
28+
version: latest
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/linter.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Lint Code Base
2+
3+
on:
4+
pull_request: {}
5+
push: {}
6+
7+
jobs:
8+
# Git lint (only for pull requests)
9+
gitlint:
10+
if: github.event_name == 'pull_request'
11+
name: Git Lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Lint commits, branches, and pull requests
15+
uses: aschbacd/gitlint-action@v1.0.2
16+
with:
17+
commit-message-body-max-length: 72
18+
commit-message-subject-max-length: 50
19+
prohibit-unknown-commit-authors: true
20+
prohibit-unknown-commit-committers: true
21+
re-branch-name: ^(feature|bug|hotfix|release)\/([A-Z]+\-[0-9]+|[a-z\-0-9]+)$
22+
re-commit-message-subject: ^(\[[A-Z]+\-[0-9]+\] )?[A-Z].*((?!\.).)$
23+
re-pull-request-title: ^(\[[A-Z]+\-[0-9]+\] )?[A-Z].*((?!\.).)$
24+
# Markdown lint
25+
markdown-lint:
26+
name: Markdown Lint
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v2
31+
- name: Lint files
32+
uses: docker://avtodev/markdown-lint:v1
33+
with:
34+
args: ./
35+
config: .markdown-lint.yaml
36+
# YAML lint
37+
yamllint:
38+
name: YAML Lint
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v2
43+
- name: Lint yaml files
44+
uses: ibiqlik/action-yamllint@v3
45+
with:
46+
config_data: .yamllint.yaml

.goreleaser.yaml

+28-22
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
1-
env:
2-
- GO111MODULE=on
1+
archives:
2+
- format_overrides:
3+
- format: zip
4+
goos: windows
5+
replacements:
6+
386: i386
7+
38
before:
49
hooks:
5-
- go mod download
10+
- go mod tidy
11+
- go generate ./...
12+
613
builds:
7-
- env:
8-
- CGO_ENABLED=0
9-
goos:
10-
- linux
11-
- darwin
12-
- windows
13-
goarch:
14+
- goarch:
1415
- 386
1516
- amd64
1617
- arm
1718
- arm64
19+
goos:
20+
- linux
21+
- windows
22+
- darwin
1823
ignore:
19-
- goos: darwin
20-
goarch: 386
21-
checksum:
22-
name_template: "checksums.txt"
24+
- goarch: arm
25+
goos: windows
26+
2327
changelog:
2428
filters:
2529
exclude:
2630
- "^docs:"
2731
- "^test:"
2832
- Merge pull request
2933
- Merge branch
30-
archives:
31-
- name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
32-
replacements:
33-
386: i386
34-
format_overrides:
35-
- goos: windows
36-
format: zip
34+
35+
checksum:
36+
name_template: checksums.txt
37+
38+
dist: goreleaser
39+
3740
release:
38-
prerelease: auto
3941
name_template: "{{ .ProjectName }} {{ .Tag }}"
42+
prerelease: auto
43+
44+
snapshot:
45+
name_template: "{{ incpatch .Version }}-next"

.markdown-lint.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Line length <https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md013>
2+
MD013:
3+
line_length: 100
4+
tables: false
5+
6+
# Fenced code blocks should have a language specified
7+
# <https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md040>
8+
MD040: false
9+
10+
default: true # includes/excludes all rules by default

.yamllint.yaml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
rules:
2+
braces:
3+
max-spaces-inside: 1
4+
max-spaces-inside-empty: 0
5+
min-spaces-inside: 1
6+
min-spaces-inside-empty: 0
7+
brackets:
8+
max-spaces-inside: 0
9+
max-spaces-inside-empty: 0
10+
min-spaces-inside: 0
11+
min-spaces-inside-empty: 0
12+
colons:
13+
max-spaces-after: 1
14+
max-spaces-before: 0
15+
commas:
16+
max-spaces-after: 1
17+
max-spaces-before: 0
18+
min-spaces-after: 1
19+
comments:
20+
min-spaces-from-content: 1
21+
require-starting-space: true
22+
comments-indentation: {}
23+
document-end:
24+
present: false
25+
empty-lines:
26+
max: 1
27+
max-end: 0
28+
max-start: 0
29+
empty-values:
30+
forbid-in-block-mappings: true
31+
forbid-in-flow-mappings: true
32+
hyphens:
33+
max-spaces-after: 1
34+
indentation:
35+
check-multi-line-strings: false
36+
indent-sequences: true
37+
spaces: 2
38+
key-duplicates: {}
39+
key-ordering:
40+
level: warning
41+
line-length:
42+
allow-non-breakable-inline-mappings: true
43+
allow-non-breakable-words: true
44+
ignore: .github/workflows/publish.yaml
45+
max: 100
46+
new-line-at-end-of-file: {}
47+
new-lines:
48+
type: unix
49+
octal-values:
50+
forbid-explicit-octal: false
51+
forbid-implicit-octal: true
52+
quoted-strings:
53+
quote-type: double
54+
required: only-when-needed
55+
trailing-spaces: {}

Dockerfile

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
# Build
2-
FROM golang:1.14-alpine3.11 AS base
3-
COPY . /go/src/sort-it
4-
5-
WORKDIR /go/src/sort-it
6-
RUN apk add git gcc
7-
8-
# Go modules
9-
ENV GO111MODULE=on
10-
RUN go mod download
11-
12-
# Compile
13-
RUN go build -a -tags netgo -ldflags '-w' -o /go/bin/sort-it /go/src/sort-it/main.go
2+
FROM golang:1.18.1-alpine3.15 AS base
3+
RUN apk add alpine-sdk
4+
COPY . /go/src/github.com/aschbacd/sort-it
5+
WORKDIR /go/src/github.com/aschbacd/sort-it
6+
RUN go build -a -tags netgo -ldflags '-w' -o /go/bin/sort-it /go/src/github.com/aschbacd/sort-it
147

158
# Package
16-
FROM alpine:3.11
9+
FROM alpine:3.15.4
1710
COPY --from=base /go/bin/sort-it /sort-it
1811
RUN apk add exiftool
19-
ENTRYPOINT ["/sort-it"]
12+
ENTRYPOINT ["/sort-it"]

go.mod

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
module github.com/aschbacd/sort-it
22

3-
go 1.14
3+
go 1.18
44

55
require (
6-
github.com/fatih/color v1.9.0
7-
github.com/mattn/go-colorable v0.1.6 // indirect
8-
github.com/spf13/cobra v0.0.7
6+
github.com/fatih/color v1.13.0
7+
github.com/spf13/cobra v1.4.0
8+
)
9+
10+
require (
11+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
12+
github.com/mattn/go-colorable v0.1.9 // indirect
13+
github.com/mattn/go-isatty v0.0.14 // indirect
914
github.com/spf13/pflag v1.0.5 // indirect
10-
golang.org/x/sys v0.0.0-20200409092240-59c9f1ba88fa // indirect
15+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
1116
)

0 commit comments

Comments
 (0)