Skip to content

Commit

Permalink
ci: setup release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Madh93 committed Dec 28, 2024
1 parent dc594d9 commit f4a0236
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ tmp_dir = "tmp"

[build]
cmd = "task build:debug"
bin = "./bin/hoarder-debug server"
full_bin = "dlv exec ./bin/hoarder-debug server --listen=127.0.0.1:2345 --headless=true --api-version=2 --accept-multiclient --continue --log -- "
bin = "./bin/hoarderbot-debug"
full_bin = "dlv exec ./bin/hoarderbot-debug --listen=127.0.0.1:2345 --headless=true --api-version=2 --accept-multiclient --continue --log --"
include_ext = ["go"]
exclude_dir = [".vscode", ".devcontainer", "bin", "tmp"]
exclude_regex = ["_test.go"]
Expand Down
4 changes: 3 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"customizations": {
"vscode": {
"extensions": [
"EditorConfig.EditorConfig"
"EditorConfig.EditorConfig",
"tamasfe.even-better-toml",
"redhat.vscode-yaml"
]
}
}
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/check-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Check Pull Request

on:
pull_request:
branches: [main]

jobs:
check-pr:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Install dependencies
run: go get .

- name: Build
run: go build -v

- name: Test
run: go test ./...

- name: Linter
uses: golangci/golangci-lint-action@v6
with:
version: v1.62.2
44 changes: 44 additions & 0 deletions .github/workflows/release-hoarderbot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Release Hoarderbot

on:
push:
tags: ["v*"]

permissions:
contents: write
packages: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ github.token }}
17 changes: 17 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
linters:
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- gofmt
- godot
run:
timeout: 5m
modules:
enable: true
output:
formats:
- format: colored-line-number
105 changes: 105 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

before:
hooks:
- go mod tidy

builds:
- id: binary
env:
- CGO_ENABLED=0
flags:
- -trimpath
ldflags:
- -s -w
- -X github.com/Madh93/hoarderbot/internal/version.appVersion={{ .Version }}
- -X github.com/Madh93/hoarderbot/internal/version.commitHash={{ .FullCommit }}
goos:
- linux
- darwin
- windows
goarch:
- '386'
- amd64
- arm
- arm64
ignore:
- goos: darwin
goarch: '386'
- goos: darwin
goarch: arm
- goos: windows
goarch: arm

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip

kos:
- build: binary
repositories:
- "ghcr.io/Madh93/{{ .ProjectName }}"
- "madh93/{{ .ProjectName }}"
tags:
- "{{ .Version }}"
- latest
labels:
org.opencontainers.image.authors: Madh93
org.opencontainers.image.created: "{{ .Date }}"
org.opencontainers.image.description: Telegram Bot for saving bookmarks to Hoarder
org.opencontainers.image.licenses: MIT
org.opencontainers.image.source: "{{ .GitURL }}"
org.opencontainers.image.revision: "{{ .FullCommit }}"
org.opencontainers.image.title: "{{ .ProjectName }}"
org.opencontainers.image.url: "{{ .GitURL }}"
org.opencontainers.image.vendor: Madh93
org.opencontainers.image.version: "{{ .Version }}"
bare: true
preserve_import_paths: false
platforms:
- linux/amd64
- linux/arm64
- linux/arm/v7

checksum:
name_template: 'checksums.txt'

snapshot:
version_template: "{{ .Version }}-next"

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

release:
draft: true
github:
owner: Madh93
name: "{{ .ProjectName }}"
footer: >-
---
Released by [GoReleaser](https://github.com/goreleaser/goreleaser).
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
air 1.61.1
task 3.40.0
air 1.61.5
task 3.40.1
13 changes: 13 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Package main is the entry point of the application. It initializes the
// configuration, sets up logging, and starts the Hoarderbot.
package main

import (
"fmt"
)

// main initializes the configuration, sets up logging, and starts the
// Hoarderbot.
func main() {
fmt.Println("Hello World!")
}

0 comments on commit f4a0236

Please sign in to comment.