diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index a91f2db..b1ed416 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -9,6 +9,7 @@ env: BINARY_NAME: git-project-manager GO_MOD_PATH: gitea.libretechconsulting.com/rmcguire/git-project-manager GO_GIT_HOST: gitea.libretechconsulting.com + PLATFORMS: linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 jobs: release: @@ -27,20 +28,25 @@ jobs: VERSION: ${{ github.ref_name }} run: make all - - name: Upload Binary to Generic Registry + - name: Upload Binaries to Generic Registry env: API_TOKEN: ${{ secrets.API_TOKEN }} run: | - echo "Pushing ./$BINARY_PATH/$BINARY_NAME to ${GITHUB_SERVER_URL} packages for ${GITHUB_REPOSITORY_OWNER} as ${PACKAGE_NAME}@${{ github.ref_name }}" - if [ -f ./${BINARY_PATH}/${BINARY_NAME} ]; then - curl -X PUT \ - -H "Authorization: token ${API_TOKEN}" \ - --upload-file ./${BINARY_PATH}/${BINARY_NAME} \ - "${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/generic/${PACKAGE_NAME}/${{ github.ref_name }}/${BINARY_NAME}" - else - echo "Error: Binary ./${BINARY_PATH}/${BINARY_NAME} not found." - exit 1 - fi + for platform in $PLATFORMS; do + OS=$(echo $platform | cut -d/ -f1) + ARCH=$(echo $platform | cut -d/ -f2) + BINARY_FILE="${BINARY_PATH}/${PACKAGE_NAME}-${OS}-${ARCH}" + echo "Uploading $BINARY_FILE" + if [ -f "$BINARY_FILE" ]; then + curl -X PUT \ + -H "Authorization: token ${API_TOKEN}" \ + --upload-file "$BINARY_FILE" \ + "${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/generic/${PACKAGE_NAME}/${{ github.ref_name }}/${PACKAGE_NAME}-${OS}-${ARCH}" + else + echo "Error: Binary $BINARY_FILE not found." + exit 1 + fi + done - name: Generate and Upload Package to Go Registry env: diff --git a/Makefile b/Makefile index b9ca9c9..71075f2 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,9 @@ CMD_NAME := git-project-manager .PHONY: all test build install docs clean VERSION ?= development # Default to "development" if VERSION is not set +PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 +OUTPUT_DIR := bin +PKG := gitea.libretechconsulting.com/rmcguire/git-project-manager all: test build install docs @@ -10,10 +13,18 @@ test: go test -v ./... build: test - go build -ldflags "-X gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd.Version=$(VERSION)" -o bin/${CMD_NAME} + @echo "Building for platforms: $(PLATFORMS)" + @for platform in $(PLATFORMS); do \ + OS=$$(echo $$platform | cut -d/ -f1); \ + ARCH=$$(echo $$platform | cut -d/ -f2); \ + OUTPUT="$(OUTPUT_DIR)/$(CMD_NAME)-$$OS-$$ARCH"; \ + GOOS=$$OS GOARCH=$$ARCH go build -ldflags "-X $(PKG)/cmd.Version=$(VERSION)" -o $$OUTPUT; \ + echo "Built $$OUTPUT"; \ + done + go build -ldflags "-X $(PKG)/cmd.Version=$(VERSION)" -o bin/${CMD_NAME} install: - go install -v -ldflags "-X gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd.Version=$(VERSION)" . + go install -v -ldflags "-X $(PKG)/cmd.Version=$(VERSION)" . docs: bin/${CMD_NAME} docs md