-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added release automation
- Loading branch information
Showing
8 changed files
with
149 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: goreleaser | ||
|
||
on: | ||
pull_request: | ||
push: | ||
# run only against tags | ||
tags: | ||
- "*" | ||
|
||
permissions: | ||
contents: 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 | ||
version: "~> v2" | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution | ||
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,5 @@ go.work | |
|
||
main | ||
backup | ||
|
||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
version: 2 | ||
|
||
before: | ||
hooks: | ||
- go mod tidy | ||
- mockery --config=.mockery.yaml | ||
|
||
builds: | ||
- id: "asbackup" | ||
main: cmd/asbackup/main.go | ||
binary: "asbackup" | ||
goos: | ||
- linux | ||
- darwin | ||
- windows | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
env: | ||
- CGO_ENABLED=0 | ||
ldflags: | ||
- -s -w -X 'main.appVersion={{.Version}}' -X 'main.commitHash={{.Commit}}' | ||
- id: "asrestore" | ||
main: cmd/asrestore/main.go | ||
binary: "asrestore" | ||
goos: | ||
- linux | ||
- darwin | ||
- windows | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
env: | ||
- CGO_ENABLED=0 | ||
ldflags: | ||
- -s -w -X 'main.appVersion={{.Version}}' -X 'main.commitHash={{.Commit}}' | ||
- id: "backup-go" | ||
skip: true | ||
|
||
archives: | ||
- id: "asbackup" | ||
format: tar.gz | ||
name_template: >- | ||
{{ .Binary }}_ | ||
{{ .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 | ||
- id: "asrestore" | ||
format: tar.gz | ||
name_template: >- | ||
{{ .Binary }}_ | ||
{{ .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 | ||
- id: "backup-go" | ||
format: tar.gz | ||
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 }} | ||
release: | ||
# for tests, remove this line when everything is ready. | ||
draft: true | ||
skip_upload: true | ||
|
||
header: | | ||
## Release {{ .Version }} ({{ .Date }}) | ||
- asbackup (CLI tool) | ||
- asrestore (CLI tool) | ||
- backup-go (library) | ||
changelog: | ||
disable: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
VERSION := dev | ||
COMMIT := $(shell git rev-parse --short HEAD) | ||
LDFLAGS := -ldflags "-X 'main.appVersion=$(VERSION)' -X 'main.commitHash=$(COMMIT)'" | ||
|
||
.PHONY: test | ||
test: | ||
go test -v ./... | ||
|
@@ -12,8 +16,9 @@ coverage: | |
.PHONY: clean | ||
clean: mocks-clean | ||
rm -f coverage.cov | ||
rm -Rf dist | ||
|
||
# Install mockery for generating test mocks | ||
# Install mockery for generating test mocks. | ||
.PHONY: mockery-install | ||
mockery-install: | ||
go install github.com/vektra/mockery/[email protected] | ||
|
@@ -29,4 +34,20 @@ mocks-generate: mockery-install | |
.PHONY: mocks-clean | ||
mocks-clean: | ||
@echo "Cleaning up all 'mocks' directories..." | ||
@find . -type d -name 'mocks' -exec rm -rf {} + | ||
@find . -type d -name 'mocks' -exec rm -rf {} + | ||
|
||
# Build release locally. | ||
.PHONY: release-test | ||
release-test: | ||
@echo "Testing release with version $(VERSION)..." | ||
goreleaser build --snapshot | ||
|
||
|
||
# Build CLI tools. | ||
.PHONY: build | ||
build: | ||
mkdir dist | ||
@echo "Building asbackup with version $(VERSION)..." | ||
go build -o dist/asbackup cmd/asbackup/main.go | ||
@echo "Building asrestore with version $(VERSION)..." | ||
go build -o dist/asrestore cmd/asbackup/main.go |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters