From 43d3fb3eba9a17df8178cac79dab5033f8f340f3 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Tue, 23 May 2023 17:12:48 +0200 Subject: [PATCH] ci: add binary releases pipelines (#358) --- .github/release.yml | 24 ++++++++ .github/workflows/release.yaml | 81 ++++++++++++++++++++++++++ .github/workflows/release.yml.disabled | 26 --------- .gitignore | 2 + .goreleaser.yaml | 15 ----- Makefile | 8 +++ 6 files changed, 115 insertions(+), 41 deletions(-) create mode 100644 .github/release.yml create mode 100644 .github/workflows/release.yaml delete mode 100644 .github/workflows/release.yml.disabled delete mode 100644 .goreleaser.yaml diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..c86866c --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,24 @@ +# .github/release.yml + +changelog: + exclude: + labels: + - ignore-for-release + categories: + - title: Breaking Changes 🛠 + labels: + - Semver-Major + - breaking-change + - title: "Bug fixes :bug:" + labels: + - bug + - title: Exciting New Features 🎉 + labels: + - Semver-Minor + - enhancement + - title: 👒 Dependencies + labels: + - dependencies + - title: Other Changes + labels: + - "*" \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..7444304 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,81 @@ +name: Build and Release + +on: push + +jobs: + build-linux: + strategy: + matrix: + include: + - build: 'avx2' + defines: '' + - build: 'avx' + defines: '-DLLAMA_AVX2=OFF' + - build: 'avx512' + defines: '-DLLAMA_AVX512=ON' + runs-on: ubuntu-latest + steps: + - name: Clone + uses: actions/checkout@v3 + with: + submodules: true + - name: Dependencies + run: | + sudo apt-get update + sudo apt-get install build-essential ffmpeg + - name: Build + id: build + env: + CMAKE_ARGS: "${{ matrix.define }}" + BUILD_ID: "${{ matrix.build }}" + run: | + make dist + - uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.build }} + path: release/ + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + release/* + + build-macOS: + strategy: + matrix: + include: + - build: 'avx2' + defines: '' + - build: 'avx' + defines: '-DLLAMA_AVX2=OFF' + - build: 'avx512' + defines: '-DLLAMA_AVX512=ON' + runs-on: macOS-latest + steps: + - name: Clone + uses: actions/checkout@v3 + with: + submodules: true + + - name: Dependencies + run: | + brew update + brew install sdl2 ffmpeg + - name: Build + id: build + env: + CMAKE_ARGS: "${{ matrix.define }}" + BUILD_ID: "${{ matrix.build }}" + run: | + make dist + - uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.build }} + path: release/ + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + release/* \ No newline at end of file diff --git a/.github/workflows/release.yml.disabled b/.github/workflows/release.yml.disabled deleted file mode 100644 index 460a2a4..0000000 --- a/.github/workflows/release.yml.disabled +++ /dev/null @@ -1,26 +0,0 @@ -name: goreleaser - -on: - push: - tags: - - 'v*' - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.18 - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 - with: - version: latest - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 12c461c..10f3a35 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,7 @@ local-ai models/* test-models/ +release/ + # just in case .DS_Store diff --git a/.goreleaser.yaml b/.goreleaser.yaml deleted file mode 100644 index 6446f90..0000000 --- a/.goreleaser.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# Make sure to check the documentation at http://goreleaser.com -project_name: local-ai -builds: - - ldflags: - - -w -s - env: - - CGO_ENABLED=0 - goos: - - linux - - darwin - - windows - goarch: - - amd64 - - arm64 - binary: '{{ .ProjectName }}' \ No newline at end of file diff --git a/Makefile b/Makefile index bd97efd..4a9ae10 100644 --- a/Makefile +++ b/Makefile @@ -17,9 +17,12 @@ CGO_LDFLAGS?= CUDA_LIBPATH?=/usr/local/cuda/lib64/ STABLEDIFFUSION_VERSION?=c0748eca3642d58bcf9521108bcee46959c647dc GO_TAGS?= +BUILD_ID?=git OPTIONAL_TARGETS?= +OS := $(shell uname -s) +ARCH := $(shell uname -m) GREEN := $(shell tput -Txterm setaf 2) YELLOW := $(shell tput -Txterm setaf 3) WHITE := $(shell tput -Txterm setaf 7) @@ -186,6 +189,7 @@ clean: ## Remove build related file rm -rf ./bloomz rm -rf ./whisper.cpp rm -rf $(BINARY_NAME) + rm -rf release/ ## Build: @@ -195,6 +199,10 @@ build: prepare ## Build the project $(info ${GREEN}I GO_TAGS: ${YELLOW}$(GO_TAGS)${RESET}) CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=${C_INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} $(GOCMD) build -tags "$(GO_TAGS)" -x -o $(BINARY_NAME) ./ +dist: build + mkdir -p release + cp $(BINARY_NAME) release/$(BINARY_NAME)-$(BUILD_ID)-$(OS)-$(ARCH) + generic-build: ## Build the project using generic BUILD_TYPE="generic" $(MAKE) build