Skip to content
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
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.26'

- name: Download dependencies
run: go mod download

- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...

- name: Upload coverage
uses: codecov/codecov-action@v4
with:
files: coverage.out

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.26'

- name: golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: v2.11.3

build-docker:
name: Build Docker image (test)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

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

- name: Build
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: gitmeout:test
132 changes: 132 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write
packages: write

jobs:
build-binaries:
name: Build binaries
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, darwin, windows]
goarch: [amd64, arm64]
exclude:
- goos: windows
goarch: arm64
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.26'

- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
VERSION=${GITHUB_REF_NAME#v}
BINARY_NAME=gitmeout
if [ "$GOOS" = "windows" ]; then
BINARY_NAME=gitmeout.exe
fi
go build -ldflags="-s -w -X main.version=${VERSION}" -o bin/${GOOS}_${GOARCH}/${BINARY_NAME} ./cmd/gitmeout

- name: Create archive
run: |
cd bin/${{ matrix.goos }}_${{ matrix.goarch }}
if [ "${{ matrix.goos }}" = "windows" ]; then
zip -r ../../gitmeout-${{ matrix.goos }}-${{ matrix.goarch }}.zip .
else
tar -czvf ../../gitmeout-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz .
fi

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: gitmeout-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
gitmeout-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
gitmeout-${{ matrix.goos }}-${{ matrix.goarch }}.zip
if-no-files-found: ignore

build-docker:
name: Build Docker image
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 GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Forgejo Container Registry
uses: docker/login-action@v3
with:
registry: code.decastro.me
username: ${{ secrets.FORGEJO_REGISTRY_USER }}
password: ${{ secrets.FORGEJO_REGISTRY_TOKEN }}

- name: Get version
id: version
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/gitmeout:latest
ghcr.io/${{ github.repository_owner }}/gitmeout:${{ steps.version.outputs.VERSION }}
code.decastro.me/guilherme/gitmeout:latest
code.decastro.me/guilherme/gitmeout:${{ steps.version.outputs.VERSION }}
build-args: |
VERSION=${{ steps.version.outputs.VERSION }}

release:
name: Create release
needs: [build-binaries, build-docker]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: gitmeout-*
merge-multiple: true

- name: List artifacts
run: ls -la artifacts/

- name: Create release
uses: softprops/action-gh-release@v1
with:
files: |
artifacts/*.tar.gz
artifacts/*.zip
generate_release_notes: true
49 changes: 49 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Binaries
*.exe
*.exe~
*.dll
*.so
*.dylib
bin/

# Test binary
*.test

# Output of go coverage
*.out
coverage.txt
coverage.html

# Go workspace file
go.work
go.work.sum

# Dependency directories
vendor/

# Build artifacts
dist/
.build/

# IDE
.idea/
.vscode/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db

# Secrets and config
.env
.env.*
!.env.example
config.local.yaml
*.local.yaml

# Debug
debug
__debug_bin*
config.yaml
9 changes: 9 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "2"

linters:
enable:
- errcheck
- govet
- ineffassign
- staticcheck
- unused
Loading
Loading