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

build: update actions workflows #3

Merged
merged 8 commits into from
Dec 10, 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
4 changes: 3 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
github: l3uddz
github:
- l3uddz
- zze0s
138 changes: 75 additions & 63 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,88 +3,100 @@ name: Build
on:
push:
branches:
- '*'
- "master"
tags:
- 'v*'
paths-ignore:
- '.github/ISSUE_TEMPLATE/**'
- '.github/images/**'
- 'config.yaml'
- 'docker-compose.yml'
- 'Makefile'
- '**.md'
pull_request:
paths-ignore:
- '.github/ISSUE_TEMPLATE/**'
- '.github/images/**'
- 'config.yaml'
- 'docker-compose.yml'
- 'Makefile'
- '**.md'

env:
REGISTRY: ghcr.io
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
GO_VERSION: '1.23'

permissions:
contents: write
packages: write

jobs:
build:
test:
name: Test
runs-on: ubuntu-latest
steps:
# dependencies
- name: goreleaser
uses: goreleaser/goreleaser-action@v2
with:
install-only: true
version: 1.7.0

- name: goreleaser version
run: goreleaser -v

# checkout
- name: checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

# setup go
- name: go
uses: actions/setup-go@v1
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: ${{ env.GO_VERSION }}
cache: true

- name: go info
run: |
go version
go env
- name: Test
run: go run gotest.tools/gotestsum@latest --junitfile unit-tests.xml --format pkgname -- ./...

# cache
- name: cache
uses: actions/cache@v1
- name: Test Summary
uses: test-summary/action@v2
with:
path: vendor
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

# vendor
- name: vendor
run: |
make vendor
paths: "unit-tests.xml"
if: always()

# git status
- name: git status
run: git status
goreleaser:
name: Build and publish Go binaries
runs-on: ubuntu-latest
needs: [test]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

# build
- name: build
if: startsWith(github.ref, 'refs/tags/') == false
run: |
make snapshot
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true

# publish
- name: publish
if: startsWith(github.ref, 'refs/tags/') == true
- name: Run GoReleaser build
if: github.event_name == 'pull_request'
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean --skip=validate,publish --parallelism 5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
make publish

# artifacts
- name: artifact_linux
uses: actions/upload-artifact@v2-preview
- name: Run GoReleaser build and publish tags
if: startsWith(github.ref, 'refs/tags/')
uses: goreleaser/goreleaser-action@v6
with:
name: build_linux
path: dist/*linux*

- name: artifact_darwin
uses: actions/upload-artifact@v2-preview
with:
name: build_darwin
path: dist/*darwin*
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: artifact_windows
uses: actions/upload-artifact@v2-preview
- name: Upload assets
uses: actions/upload-artifact@v4
with:
name: build_windows
path: dist/*windows*
name: tqm
path: |
dist/*.tar.gz
dist/*.json
dist/*.yaml
17 changes: 0 additions & 17 deletions .github/workflows/remove_old_artifacts.yml

This file was deleted.

90 changes: 63 additions & 27 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,86 @@
# https://goreleaser.com
version: 2
project_name: tqm

before:
hooks:
- go mod tidy

# Build
builds:
-
- id: tqm
env:
- CGO_ENABLED=0
flags:
- -trimpath
ldflags:
- -s -w
- -X "github.com/autobrr/tqm/runtime.Version={{ .Version }}"
- -X "github.com/autobrr/tqm/runtime.GitCommit={{ .ShortCommit }}"
- -X "github.com/autobrr/tqm/runtime.Timestamp={{ .Timestamp }}"
goos:
- linux
- darwin
- windows
- darwin
- freebsd
goarch:
- amd64
- arm
- arm64
ldflags:
- -s -w
- -X "github.com/autobrr/tqm/runtime.Version={{ .Version }}"
- -X "github.com/autobrr/tqm/runtime.GitCommit={{ .ShortCommit }}"
- -X "github.com/autobrr/tqm/runtime.Timestamp={{ .Timestamp }}"
flags:
- -trimpath
goarm:
- 6
ignore:
- goos: windows
goarch: arm
- goos: windows
goarch: arm64
- goos: darwin
goarch: arm
- goos: freebsd
goarch: arm
- goos: freebsd
goarch: arm64
main: main.go
binary: tqm

# MacOS Universal Binaries
universal_binaries:
-
replace: true

# Archive
archives:
-
name_template: "{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}"
format: "binary"
- id: tqm
builds:
- tqm
format_overrides:
- goos: windows
format: zip

# Checksum
checksum:
name_template: "checksums.txt"
algorithm: sha512
name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt'

# Snapshot
snapshot:
name_template: "{{ .Major }}.{{ .Minor }}.{{ .Patch }}-dev+{{ .ShortCommit }}"
version_template: "{{ .Major }}.{{ .Minor }}.{{ .Patch }}-dev+{{ .ShortCommit }}"

release:
prerelease: auto
footer: |
**Full Changelog**: https://github.com/autobrr/tqm/compare/{{ .PreviousTag }}...{{ .Tag }}

## What to do next?

- Read the [documentation](https://autobrr.com)
- Join our [Discord server](https://discord.gg/WQ2eUycxyT)

# Changelog
changelog:
sort: asc
use: github
filters:
exclude:
- "^docs:"
- "^test:"
- "^Merge branch"
- Merge pull request
- Merge remote-tracking branch
- Merge branch
groups:
- title: 'New Features'
regexp: "^.*feat[(\\w)]*:+.*$"
order: 0
- title: 'Bug fixes'
regexp: "^.*fix[(\\w)]*:+.*$"
order: 10
- title: Other work
order: 999
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ fetch: ## Fetch vendor files

.PHONY: release
release: check_goreleaser ## Generate a release, but don't publish
goreleaser --skip-validate --skip-publish --rm-dist
goreleaser --skip=validate --skip=publish --clean

.PHONY: publish
publish: check_goreleaser ## Generate a release, and publish
goreleaser --rm-dist
goreleaser --clean

.PHONY: snapshot
snapshot: check_goreleaser ## Generate a snapshot release
goreleaser --snapshot --skip-publish --rm-dist
goreleaser --snapshot --skip=publish --clean

.PHONY: help
help:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ require (
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/scylladb/go-set v1.0.2
github.com/scylladb/go-set v1.0.3-0.20200225121959-cc7b2070d91e
github.com/spf13/pflag v1.0.5 // indirect
github.com/tcnksm/go-gitconfig v0.1.2 // indirect
golang.org/x/text v0.21.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
github.com/sanity-io/litter v1.2.0/go.mod h1:JF6pZUFgu2Q0sBZ+HSV35P8TVPI1TTzEwyu9FXAw2W4=
github.com/scylladb/go-set v1.0.2 h1:SkvlMCKhP0wyyct6j+0IHJkBkSZL+TDzZ4E7f7BCcRE=
github.com/scylladb/go-set v1.0.2/go.mod h1:DkpGd78rljTxKAnTDPFqXSGxvETQnJyuSOQwsHycqfs=
github.com/scylladb/go-set v1.0.3-0.20200225121959-cc7b2070d91e h1:7q6NSFZDeGfvvtIRwBrU/aegEYJYmvev0cHAwo17zZQ=
github.com/scylladb/go-set v1.0.3-0.20200225121959-cc7b2070d91e/go.mod h1:DkpGd78rljTxKAnTDPFqXSGxvETQnJyuSOQwsHycqfs=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
Expand Down
19 changes: 19 additions & 0 deletions hardlinkfilemap/linkinfo_freebsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package hardlinkfilemap

import (
"errors"
"os"
"strconv"
"syscall"
)

func LinkInfo(fi os.FileInfo, _ string) (string, uint64, error) {
sys, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
return "", 0, errors.New("failed to get file identifier")
}

return strconv.FormatUint(sys.Dev, 10) + "|" + strconv.FormatUint(sys.Ino, 10),
uint64(sys.Nlink),
nil
}
Loading