Skip to content

Commit

Permalink
Add action for pull_request and open CGO flag when compiling (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmreadelf authored Nov 6, 2022
1 parent 48c2c15 commit 97b84d5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
38 changes: 15 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
name: Release
on:
push:
tags:
- '*'
tags:
- '*'
pull_request:
types: [opened, reopened, synchronize]
jobs:
build:
runs-on: "ubuntu-latest"
container: "debian:10.3"
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [14]
os: ["ubuntu-20.04", "macos-11", "windows-2019"]
steps:
- name: Set up Go 1.18.x
uses: actions/setup-go@v2
with:
go-version: 1.18.x
id: go

- name: Instasll tools
shell: bash
run: "apt update && apt install make curl gcc ca-certificates zip git -y"

- name: Install gox
run: go install github.com/mitchellh/gox@master

- name: Instasll node apt repo
shell: bash
run: "curl -sL https://deb.nodesource.com/setup_14.x | bash -"

- name: Instasll node
shell: bash
run: "apt install nodejs -y"
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14

- name: Step pnpm
uses: pnpm/[email protected]
Expand All @@ -44,17 +36,17 @@ jobs:
run: make build-frontend

- name: Build go binary
shell: bash
run: gox -osarch='darwin/arm64 darwin/amd64 windows/arm64 windows/amd64 linux/arm64 linux/amd64' -ldflags="
-X main.Version=$(git describe --tags $(git rev-parse HEAD))
-X main.Commit=$(git rev-parse HEAD)" ./
run: make release-build

- name: compress go binary
if: github.ref_type == 'tag'
shell: bash
run: for i in edgeRec_*; do zip "$(echo $i | sed 's/\..*//').zip" $i; done
run: for i in edgeRec_*; do zip "$(echo $i | sed 's/\..*//').zip" $i || 7z a -tzip "$(echo $i | sed 's/\..*//').zip" $i; done

- name: Upload Release
if: github.ref_type == 'tag'
uses: softprops/action-gh-release@v1
with:
files: edgeRec*.zip
draft: true

8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.PHONY: lint build build-frontend

default: build
commit := $(shell git describe --match= --always --dirty)
version := $(shell git describe --tags --always --dirty)

## run lint to format golang code
lint:
Expand All @@ -14,4 +16,8 @@ build-frontend:

## build golang backend
build: build-frontend
go build -o edgeRec main.go
CGO_ENABLED=1 go build -o edgeRec main.go

## build golang backend
release-build: build-frontend
CGO_ENABLED=1 go build -ldflags=" -X main.Version=$(version) -X main.Commit=$(commit)" -o "edgeRec_$$(go env GOOS)_$$(go env GOARCH)" main.go

0 comments on commit 97b84d5

Please sign in to comment.