Skip to content

Commit

Permalink
feat: add goreleaser+linting for CI (and fixes)
Browse files Browse the repository at this point in the history
  • Loading branch information
tulilirockz committed Dec 4, 2024
1 parent 5423cb4 commit e997466
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint
on:
push:
pull_request:

permissions:
contents: read
pull-requests: read
checks: write

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
only-new-issues: true
version: v1.60
35 changes: 35 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: goreleaser

on:
pull_request:
push:
tags:
- "*"

permissions:
contents: write
packages: write
issues: write
id-token: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser # goreleaser-pro
version: "latest"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ output/*
*.key
*.private
*.log

dist/
29 changes: 29 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
version: 2

before:
hooks:
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
goos:
- linux

archives:
- format: tar.gz
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 }}
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
17 changes: 14 additions & 3 deletions cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ func Update(cmd *cobra.Command, args []string) {
slog.Error(fmt.Sprintf("%v, is uupd already running?", err))
return
}
defer lib.ReleaseLock(lock)
defer func() {
err := lib.ReleaseLock(lock)
if err != nil {
slog.Error("Failed releasing lock")
}
}()

hwCheck, err := cmd.Flags().GetBool("hw-check")
if err != nil {
Expand Down Expand Up @@ -61,7 +66,10 @@ func Update(cmd *cobra.Command, args []string) {
if err != nil {
systemUpdater.Config.Enabled = false
} else {
systemUpdater.Check()
_, err := systemUpdater.Check()
if err != nil {
slog.Error("Failed checking for system updates")
}
}

brewUpdater, err := drv.BrewUpdater{}.New(*initConfiguration)
Expand Down Expand Up @@ -108,7 +116,10 @@ func Update(cmd *cobra.Command, args []string) {

if systemUpdater.Outdated {
const OUTDATED_WARNING = "There hasn't been an update in over a month. Consider rebooting or running updates manually"
lib.Notify("System Warning", OUTDATED_WARNING)
err := lib.Notify("System Warning", OUTDATED_WARNING)
if err != nil {
slog.Error("Failed showing warning notification")
}
slog.Warn(OUTDATED_WARNING)
}

Expand Down
10 changes: 10 additions & 0 deletions distrobox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[golang-fedora-uupd]
additional_packages="git go gopls"
image=fedora:rawhide
init=false
nvidia=false
pull=true
root=false
replace=true
start_now=false

6 changes: 6 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,9 @@ container-test:
podman rm -f uupd-test
clean:
rm -rf "$UBLUE_ROOT"

lint:
golangci-lint run

release:
goreleaser
3 changes: 2 additions & 1 deletion lib/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type User struct {

func RunUID(uid int, command []string, env map[string]string) ([]byte, error) {
// Just fork systemd-run, using the systemd API gave me a massive headache
// FIXME: use the systemd api instead
cmdArgs := []string{
"/usr/bin/systemd-run",
"--machine",
Expand Down Expand Up @@ -77,7 +78,7 @@ func Notify(summary string, body string) error {
}
for _, user := range users {
// we don't care if these exit
RunUID(user.UID, []string{"/usr/bin/notify-send", "--app-name", "uupd", summary, body}, nil)
_, _ = RunUID(user.UID, []string{"/usr/bin/notify-send", "--app-name", "uupd", summary, body}, nil)
}
return nil
}

0 comments on commit e997466

Please sign in to comment.