Skip to content

Commit

Permalink
add build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricedesaxe committed Jul 18, 2024
1 parent 26bfbab commit a5e4af1
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: publish
on:
push:
tags:
- '*'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 1
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.22.5
- name: Make all
run: make all
- name: Upload release binaries
uses: actions/upload-artifact@v2
with:
name: release-binaries
path: ./bin/
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/
asset_name: release-it
asset_content_type: application/zip
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Version := $(shell git describe --tags --dirty)
GitCommit := $(shell git rev-parse HEAD)
LDFLAGS := "-s -w -X main.Version=$(Version) -X main.GitCommit=$(GitCommit)"

.PHONY: all
all: gofmt vendor dist

.PHONY: gofmt
gofmt:
@test -z $(shell gofmt -l ./ | tee /dev/stderr) || (echo "[WARN] Fix formatting issues with 'make fmt'" && exit 1)

.PHONY: vendor
vendor:
go mod vendor

.PHONY: dist
dist:
mkdir -p bin/
CGO_ENABLED=0 GOOS=linux go build -mod=vendor -a -ldflags $(LDFLAGS) -installsuffix cgo -o bin/release-it-amd64
CGO_ENABLED=0 GOOS=darwin go build -mod=vendor -a -ldflags $(LDFLAGS) -installsuffix cgo -o bin/release-it-darwin
GOARM=7 GOARCH=arm CGO_ENABLED=0 GOOS=linux go build -mod=vendor -a -ldflags $(LDFLAGS) -installsuffix cgo -o bin/release-it-arm
GOARCH=arm64 CGO_ENABLED=0 GOOS=linux go build -mod=vendor -a -ldflags $(LDFLAGS) -installsuffix cgo -o bin/release-it-arm64
GOOS=windows CGO_ENABLED=0 go build -mod=vendor -a -ldflags $(LDFLAGS) -installsuffix cgo -o bin/release-it.exe

test:
go test ./... -v -race
Binary file added bin/release-it-amd64
Binary file not shown.
Binary file added bin/release-it-arm
Binary file not shown.
Binary file added bin/release-it-arm64
Binary file not shown.
Binary file added bin/release-it-darwin
Binary file not shown.
Binary file added bin/release-it.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# github.com/a-h/templ v0.2.747
## explicit; go 1.21

0 comments on commit a5e4af1

Please sign in to comment.