Skip to content

Commit

Permalink
#9 Prepare for versioned release (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
docktermj authored Jul 26, 2023
1 parent 39e412e commit 2b0ce22
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 10 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/make-github-release-assets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: make-github-release-assets.yaml

on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"

jobs:
build:
name: Publish binaries
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
- run: make package
- name: Upload files to release assets
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/explai*
file_glob: true
tag: ${{ github.ref }}
overwrite: true
13 changes: 13 additions & 0 deletions .github/workflows/pr-closed-automation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

name: 'pr closed automation'

on:
pull_request:
types: [closed]

jobs:
move-pr-to-done:
uses: Senzing/build-resources/.github/workflows/move-pr-to-done.yaml@main
secrets:
SENZING_GITHUB_PROJECT_RW_TOKEN: ${{ secrets.SENZING_GITHUB_PROJECT_RW_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
go.work

.history
target/
42 changes: 40 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Makefile for explain.

# Detect the operating system and architecture
include Makefile.osdetect

# "Simple expanded" variables (':=')

# PROGRAM_NAME is the name of the GIT repository.
Expand All @@ -16,6 +19,10 @@ BUILD_ITERATION := $(shell git log $(BUILD_TAG)..HEAD --oneline | wc -l | sed 's
GIT_REMOTE_URL := $(shell git config --get remote.origin.url)
GO_PACKAGE_NAME := $(shell echo $(GIT_REMOTE_URL) | sed -e 's|^git@github.com:|github.com/|' -e 's|\.git$$||' -e 's|Senzing|senzing|')

# Optionally include platform-specific settings
-include Makefile.$(OSTYPE)
-include Makefile.$(OSTYPE)_$(OSARCH)

# Recursive assignment ('=')

CC = gcc
Expand Down Expand Up @@ -49,7 +56,22 @@ dependencies:


.PHONY: build
build: build-linux
build: build-darwin build-linux build-scratch build-windows


.PHONY: build-darwin
build-darwin:
@GOOS=darwin \
GOARCH=amd64 \
go build \
-ldflags \
"-X 'main.buildIteration=${BUILD_ITERATION}' \
-X 'main.buildVersion=${BUILD_VERSION}' \
-X 'main.programName=${PROGRAM_NAME}' \
" \
-o $(GO_PACKAGE_NAME)
@mkdir -p $(TARGET_DIRECTORY)/darwin || true
@mv $(GO_PACKAGE_NAME) $(TARGET_DIRECTORY)/darwin


.PHONY: build-linux
Expand Down Expand Up @@ -86,6 +108,22 @@ build-scratch:
@mkdir -p $(TARGET_DIRECTORY)/scratch || true
@mv $(GO_PACKAGE_NAME) $(TARGET_DIRECTORY)/scratch


.PHONY: build-windows
build-windows:
@GOOS=windows \
GOARCH=amd64 \
go build \
-ldflags \
"-X 'main.buildIteration=${BUILD_ITERATION}' \
-X 'main.buildVersion=${BUILD_VERSION}' \
-X 'main.programName=${PROGRAM_NAME}' \
" \
-o $(GO_PACKAGE_NAME).exe
@mkdir -p $(TARGET_DIRECTORY)/windows || true
@mv $(GO_PACKAGE_NAME).exe $(TARGET_DIRECTORY)/windows


# -----------------------------------------------------------------------------
# Test
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -186,4 +224,4 @@ print-make-variables:
help:
@echo "Build $(PROGRAM_NAME) version $(BUILD_VERSION)-$(BUILD_ITERATION)".
@echo "All targets:"
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
@$(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
4 changes: 4 additions & 0 deletions Makefile.darwin
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SENZING_DIR ?= /Applications/Senzing.app/Contents/Resources/app/g2
SENZING_TOOLS_SENZING_DIRECTORY ?= $(SENZING_DIR)

DYLD_LIBRARY_PATH := $(SENZING_TOOLS_SENZING_DIRECTORY)/lib:$(SENZING_TOOLS_SENZING_DIRECTORY)/lib/macos
35 changes: 35 additions & 0 deletions Makefile.osdetect
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ifeq ($(OS),Windows_NT)
OSTYPE = windows
ifeq ($(PROCESSOR_ARCHITECTURE), AMD64)
OSARCH = x86_64
endif
ifeq ($(PROCESSOR_ARCHITECTURE), ARM64)
OSARCH = arm4
endif
else
UNAME_OSTYPE = $(shell uname -s)
ifeq ($(UNAME_OSTYPE),Linux)
OSTYPE = linux
UNAME_ARCH = $(shell uname -p)
ifeq ($(UNAME_ARCH),x86_64)
OSARCH = x86_64
endif
ifeq ($(UNAME_ARCH),arm64)
OSARCH = arm64
endif
endif
ifeq ($(UNAME_OSTYPE),Darwin)
OSTYPE = darwin
UNAME_ARCH = $(shell uname -m)
ifeq ($(UNAME_ARCH),x86_64)
OSARCH = x86_64
endif
ifeq ($(UNAME_ARCH),arm64)
OSARCH = arm64
endif
endif
endif




30 changes: 22 additions & 8 deletions package.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Stages
# -----------------------------------------------------------------------------

ARG IMAGE_GO_BUILDER=golang:1.20.0
ARG IMAGE_GO_BUILDER=golang:1.20.6
ARG IMAGE_FPM_BUILDER=dockter/fpm:latest
ARG IMAGE_FINAL=alpine

Expand All @@ -11,10 +11,10 @@ ARG IMAGE_FINAL=alpine
# -----------------------------------------------------------------------------

FROM ${IMAGE_GO_BUILDER} as go_builder
ENV REFRESHED_AT=2023-02-22
ENV REFRESHED_AT=2023-07-26
LABEL Name="senzing/explain-builder" \
Maintainer="support@senzing.com" \
Version="0.0.5"
Version="0.1.1"

# Build arguments.

Expand Down Expand Up @@ -53,10 +53,10 @@ RUN mkdir -p /output \
# -----------------------------------------------------------------------------

FROM ${IMAGE_FPM_BUILDER} as fpm_builder
ENV REFRESHED_AT=2023-02-22
ENV REFRESHED_AT=2023-07-26
LABEL Name="senzing/explain-fpm-builder" \
Maintainer="support@senzing.com" \
Version="0.0.5"
Version="0.1.1"

# Use arguments from prior stage.

Expand All @@ -67,9 +67,11 @@ ARG GO_PACKAGE_NAME

# Copy files from prior stage.

COPY --from=go_builder "/output/linux/*" "/output/linux/"
COPY --from=go_builder "/output/darwin/*" "/output/darwin/"
COPY --from=go_builder "/output/linux/*" "/output/linux/"
COPY --from=go_builder "/output/windows/*" "/output/linux/"

# Create RPM package.
# Create Linux RPM package.

RUN fpm \
--input-type dir \
Expand All @@ -80,7 +82,7 @@ RUN fpm \
--iteration ${BUILD_ITERATION} \
/output/linux=/usr/bin

# Create DEB package.
# Create Linux DEB package.

RUN fpm \
--deb-no-default-config-files \
Expand All @@ -92,6 +94,18 @@ RUN fpm \
--version ${BUILD_VERSION} \
/output/linux/=/usr/bin

# Create Darwin osxpkg package.

# RUN fpm \
# --input-type dir \
# --iteration ${BUILD_ITERATION} \
# --name ${PROGRAM_NAME} \
# --osxpkg-identifier-prefix com.senzing \
# --output-type osxpkg \
# --package /output/${PROGRAM_NAME}-${BUILD_VERSION}.pkg \
# --version ${BUILD_VERSION} \
# /output/darwin/=/usr/bin

# -----------------------------------------------------------------------------
# Stage: final
# -----------------------------------------------------------------------------
Expand Down

0 comments on commit 2b0ce22

Please sign in to comment.