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

Refactor #5

Merged
merged 10 commits into from
Jun 21, 2024
Merged
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
8 changes: 4 additions & 4 deletions .air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ tmp_dir = "tmp"

[build]
args_bin = []
bin = "./tmp/main"
cmd = "make run"
bin = "./main"
cmd = "make build"
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_regex = ["_test.go", ".*_templ.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_ext = ["go", "tpl", "tmpl", "html", "templ"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
Expand Down
1 change: 0 additions & 1 deletion .env

This file was deleted.

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

on:
push:
branches:
- master
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Install yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq

- name: Run docker tag sh and export var from config.yml
run: |
chmod +x ./docker_tag.sh
./docker_tag.sh

- name: Export env variabels
uses: cardinalby/export-env-action@v2
with:
envFile: '.env'

- name: Build and push
if: ${{ env.PUSH_TO_DOCKER == 'true' }}
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ env.DOCKER_HUB_USERNAME }}/${{ env.DOCKER_REPO_NAME }}:${{ env.NEW_TAG }}
target: prod
17 changes: 0 additions & 17 deletions .github/workflows/go-test.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/goreleasaer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: goreleaser

on:
push:
tags:
- "v*.*.*"

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.0'

- name: Install dependencies
run: |
go install github.com/a-h/templ/cmd/templ@latest
templ generate

- name: Run GoReleaser
uses: goreleaser/[email protected]
with:
distribution: goreleaser
version: ${{ env.GITHUB_REF_NAME }}
args: release --clean
workdir: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

23 changes: 10 additions & 13 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
name: Linting
name: continuous integration

on:
push:
paths:
- '**.go'
- go.sum
- go.mod
branches-ignore:
- main
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.22.1'
go-version: '1.22.2'

- name: Deps cache
id: cache-go-deps
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: go-deps-cache
with:
Expand All @@ -33,14 +27,17 @@ jobs:
${{ runner.os }}-build-${{ env.cache-name }}-

- if: ${{ steps.cache-go-deps.outputs.cache-hit != 'true' }}
name: List the state of node modules
name: List the state of go modules
continue-on-error: true
run: go mod graph

- name: Install dependencies
run: |
go mod tidy
go mod download
go install github.com/golangci/golangci-lint/cmd/[email protected]
go install github.com/a-h/templ/cmd/templ@latest
templ generate

- name: Run golangci-lint
uses: golangci/golangci-lint[email protected]
run: golangci-lint run
9 changes: 2 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
tmp/
*templ.go

# IDE specific files
.vscode
.idea
main
42 changes: 42 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
before:
hooks:
- go mod tidy

env:
- PACKAGE_PATH=github.com/ujstor/portfolio-web/cmd

builds:
- binary: "{{ .ProjectName }}"
main: ./cmd/api
goos:
- darwin
- linux
- windows
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X {{.Env.PACKAGE_PATH}}={{.Version}}
release:
prerelease: auto

universal_binaries:
- replace: true

archives:
- name_template: >
{{- .ProjectName }}_{{- .Version }}_{{- title .Os }}_{{- if eq .Arch "amd64" }}x86_64{{- else if eq .Arch "386" }}i386{{- else }}{{ .Arch }}{{ end }}{{- if .Arm }}v{{ .Arm }}{{ end -}}
format_overrides:
- goos: windows
format: zip
builds_info:
group: root
owner: root
files:
- README.md

checksum:
name_template: 'checksums.txt'

11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ COPY . .

FROM base as dev
RUN make build
EXPOSE ${PORT}
EXPOSE 5000
CMD [ "sh", "-c", "echo 'y' | make watch" ]

FROM base as build
RUN go build -o main cmd/api/main.go
RUN make build

FROM alpine:3.19.0 as prod
FROM alpine:3.20.1 as prod
WORKDIR /app
COPY --from=build /app/main /app/main
COPY cmd/web cmd/web
EXPOSE ${PORT}
CMD ["./main"]
EXPOSE 5000
CMD ["./main"]
112 changes: 0 additions & 112 deletions Jenkinsfile

This file was deleted.

Loading
Loading