From 0fb2e4e4ccfbf440d4ee18562f90725d4bcc9470 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Thu, 4 Jun 2020 17:13:42 +0300 Subject: [PATCH] mdbx-ci: engage github-actions to make release-assets. Resolves https://github.com/erthink/libmdbx/issues/86 Change-Id: I87417c03bf0d657ece47a59aabbd3cb5bfaa81ec --- .github/workflows/release-assets.yml | 54 ++++++++++++++++++++++++++++ GNUmakefile | 13 +++++-- Makefile | 2 +- 3 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release-assets.yml diff --git a/.github/workflows/release-assets.yml b/.github/workflows/release-assets.yml new file mode 100644 index 00000000..934ab93b --- /dev/null +++ b/.github/workflows/release-assets.yml @@ -0,0 +1,54 @@ +# Based on the https://github.com/actions/upload-release-asset example + +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +name: Upload Release Asset + +jobs: + build: + name: Upload Release Asset + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build assets + run: | + make release-assets + - id: name + run: | + echo "::set-output name=tarball::$(ls *.tar.gz)" + echo "::set-output name=zip::$(ls *.zip)" + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: true + prerelease: true + - name: Upload tarball + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ steps.name.outputs.tarball }} + asset_name: amalgamated.tar.gz + # asset_label: Amalgamated source tarball + asset_content_type: application/tar+gzip + - name: Upload zip + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ steps.name.outputs.zip }} + asset_name: amalgamated.zip + # asset_label: Amalgamated source zip-archive + asset_content_type: application/zip diff --git a/GNUmakefile b/GNUmakefile index 5d02dce8..e9a8786c 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -128,6 +128,7 @@ CXX ?= g++ CXXSTD ?= $(shell $(CXX) -std=c++17 -c test/test.cc -o /dev/null 2>/dev/null && echo -std=c++17 || echo -std=c++11) CXXFLAGS := $(CXXSTD) $(filter-out -std=gnu11,$(CFLAGS)) TAR ?= $(shell which gnu-tar || echo tar) +ZIP ?= $(shell which zip || echo "echo 'Please install zip'") CLANG_FORMAT ?= $(shell (which clang-format-12 || which clang-format-11 || which clang-format-10 || which clang-format) 2>/dev/null) reformat: @@ -145,6 +146,7 @@ MDBX_GIT_TIMESTAMP = $(shell git show --no-patch --format=%cI HEAD || echo 'Plea MDBX_GIT_DESCRIBE = $(shell git describe --tags --long --dirty=-dirty || echo 'Please fetch tags and/or install latest git version') MDBX_VERSION_SUFFIX = $(shell set -o pipefail; echo -n '$(MDBX_GIT_DESCRIBE)' | tr -c -s '[a-zA-Z0-9]' _) MDBX_BUILD_SOURCERY = $(shell set -o pipefail; $(MAKE) -s src/version.c && (openssl dgst -r -sha256 src/version.c || sha256sum src/version.c || shasum -a 256 src/version.c) 2>/dev/null | cut -d ' ' -f 1 || echo 'Please install openssl or sha256sum or shasum')_$(MDBX_VERSION_SUFFIX) +MDBX_DIST_DIR = libmdbx-$(MDBX_VERSION_SUFFIX) check: test dist @@ -238,13 +240,18 @@ mdbx-dylib.o: src/config.h src/version.c src/alloy.c $(ALLOY_DEPS) $(lastword $( mdbx-static.o: src/config.h src/version.c src/alloy.c $(ALLOY_DEPS) $(lastword $(MAKEFILE_LIST)) $(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -ULIBMDBX_EXPORTS -c src/alloy.c -o $@ -.PHONY: dist +.PHONY: dist release-assets dist: libmdbx-sources-$(MDBX_VERSION_SUFFIX).tar.gz $(lastword $(MAKEFILE_LIST)) -libmdbx-sources-$(MDBX_VERSION_SUFFIX).tar.gz: $(addprefix dist/, $(DIST_SRC) $(DIST_EXTRA)) $(addprefix dist/man1/,$(MANPAGES)) - $(TAR) -c $(shell LC_ALL=C $(TAR) --help | grep -q -- '--owner' && echo '--owner=0 --group=0') -f - -C dist $(DIST_SRC) $(DIST_EXTRA) | gzip -c > $@ \ +release-assets: libmdbx-sources-$(MDBX_VERSION_SUFFIX).tar.gz libmdbx-sources-$(MDBX_VERSION_SUFFIX).zip + +libmdbx-sources-$(MDBX_VERSION_SUFFIX).tar.gz: $(addprefix dist/, $(DIST_SRC) $(DIST_EXTRA)) + $(TAR) -c $(shell LC_ALL=C $(TAR) --help | grep -q -- '--owner' && echo '--owner=0 --group=0') -f - -C dist $(DIST_SRC) $(DIST_EXTRA) | gzip -c -9 > $@ \ && rm dist/@tmp-shared_internals.inc +libmdbx-sources-$(MDBX_VERSION_SUFFIX).zip: $(addprefix dist/, $(DIST_SRC) $(DIST_EXTRA)) + rm -rf $@ && (cd dist && $(ZIP) -9 ../$@ $(DIST_SRC) $(DIST_EXTRA)) || rm -rf $@ + dist/mdbx.h: mdbx.h src/version.c $(lastword $(MAKEFILE_LIST)) mkdir -p dist && cp $< $@ diff --git a/Makefile b/Makefile index 187b748f..1898655e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -all bench bench-quartet build-test check clean clean-bench cross-gcc cross-qemu dist gcc-analyzer install mdbx memcheck reformat strip test test-asan test-fault test-leak test-singleprocess test-ubsan test-valgrind tools: +all bench bench-quartet build-test check clean clean-bench cross-gcc cross-qemu dist gcc-analyzer install mdbx memcheck reformat release-assets strip test test-asan test-fault test-leak test-singleprocess test-ubsan test-valgrind tools: @CC=$(CC) \ CXX=`if test -n "$(CXX)" && which "$(CXX)" > /dev/null; then echo "$(CXX)"; elif test -n "$(CCC)" && which "$(CCC)" > /dev/null; then echo "$(CCC)"; else echo "c++"; fi` \ `which gmake || which gnumake || echo 'echo "GNU Make is required"; exit 2;'` \