Skip to content

Commit

Permalink
FMWK-579-release-automation
Browse files Browse the repository at this point in the history
- added release automation
  • Loading branch information
filkeith committed Oct 27, 2024
1 parent f48210a commit 3fe57d4
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 103 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ go.work

main
backup

dist/
90 changes: 90 additions & 0 deletions .goreleaser.yaml
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
25 changes: 23 additions & 2 deletions Makefile
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 ./...
Expand All @@ -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]
Expand All @@ -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
40 changes: 0 additions & 40 deletions cmd/asbackup/.goreleaser.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions cmd/asbackup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,3 @@ build:
# Clean the build
clean:
rm -f $(OUTPUT)
rm -Rf dist

# Build release locally
release-test:
@echo "Testing release of $(OUTPUT) with version $(VERSION)..."
goreleaser build --snapshot

# Releasing
release:
@echo "Releasing $(OUTPUT) with version $(VERSION)..."
goreleaser release
40 changes: 0 additions & 40 deletions cmd/asrestore/.goreleaser.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions cmd/asrestore/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,3 @@ build:
clean:
rm -f $(OUTPUT)
rm -Rf dist

# Build release locally
release-test:
@echo "Testing release of $(OUTPUT) with version $(VERSION)..."
goreleaser build --snapshot

# Releasing
release:
@echo "Releasing $(OUTPUT) with version $(VERSION)..."
goreleaser release

0 comments on commit 3fe57d4

Please sign in to comment.