From 5b260dfa3c0456417262fb183ba6fb8910825f6e Mon Sep 17 00:00:00 2001 From: lwthiker Date: Sat, 14 May 2022 10:09:03 +0300 Subject: [PATCH 1/6] Add compiled binaries to GitHub releases --- .github/workflows/build-and-test-make.yml | 36 ++++++++++++++++++++++- Makefile.in | 12 +++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test-make.yml b/.github/workflows/build-and-test-make.yml index cf96dfec..23d439d9 100644 --- a/.github/workflows/build-and-test-make.yml +++ b/.github/workflows/build-and-test-make.yml @@ -4,6 +4,8 @@ on: push: branches: - main + tags: + - "v*.*.*" pull_request: branches: - main @@ -23,9 +25,11 @@ jobs: - os: ubuntu-20.04 capture_interface: eth0 make: make + release_name: x86_64-linux-gnu - os: macos-11 capture_interface: en0 make: gmake + release_name: x86_64-macos steps: - uses: actions/setup-python@v3 @@ -143,4 +147,34 @@ jobs: cd tests # sudo is needed for capturing packets python_bin=$(which python3) - sudo $python_bin -m pytest . --log-cli-level DEBUG --install-dir ${{ runner.temp}}/install --capture-interface ${{ matrix.capture_interface }} + sudo $python_bin -m pytest . --log-cli-level DEBUG --install-dir ${{ runner.temp }}/install --capture-interface ${{ matrix.capture_interface }} + + # If it's a tag, create a release and upload the binaries. + # For that we recompile curl-impersonate statically. + - name: Recompile statically for release assets + if: startsWith(github.ref, 'refs/tags/') + run: | + ${{ matrix.make }} chrome-clean + ${{ matrix.make }} firefox-clean + rm -Rf ${{ runner.temp }}/install + mkdir ${{ runner.temp }}/install + ./configure --prefix=${{ runner.temp }}/install --enable-static + ${{ matrix.make }} chrome-build + ${{ matrix.make }} chrome-checkbuild + ${{ matrix.make }} chrome-install + ${{ matrix.make }} firefox-build + ${{ matrix.make }} firefox-checkbuild + ${{ matrix.make }} firefox-install + + - name: Create tar release files + if: startsWith(github.ref, 'refs/tags/') + run: | + cd ${{ runner.temp }}/install/bin + tar -c -z -f ${{ runner.temp }}/curl-impersonate-${{ github.ref_name }}.${{ matrix.release_name }}.tar.gz curl-impersonate-ff curl-impersonate-chrome curl_* + echo "release_file=${{ runner.temp }}/curl-impersonate-${{ github.ref_name }}.${{ matrix.release_name }}.tar.gz" >> $GITHUB_ENV + + - name: Upload release files + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: ${{ env.release_file }} diff --git a/Makefile.in b/Makefile.in index 871c68fa..5e6662fb 100644 --- a/Makefile.in +++ b/Makefile.in @@ -73,6 +73,11 @@ firefox-uninstall: ## Uninstall the Firefox version of curl-impersonate after 'm rm -Rf @bindir@/curl_ff* .PHONY: firefox-uninstall +firefox-clean: ## Clean build artifacts of the Firefox version. Use after re-running './configure' + cd $(CURL_VERSION) + $(MAKE) clean MAKEFLAGS= + rm .firefox + chrome-build: $(CURL_VERSION)/.chrome ## Build the Chrome version of curl-impersonate cd $(CURL_VERSION) # Don't pass this Makefile's MAKEFLAGS @@ -102,7 +107,12 @@ chrome-uninstall: ## Uninstall the Chrome version of curl-impersonate after 'mak rm -Rf @bindir@/curl_chrome* @bindir@/curl_edge* @bindir@/curl_safari* .PHONY: chrome-uninstall -clean: ## Remove build artifacts +chrome-clean: ## Clean build artifacts of the Chrome version. Use after re-running './configure' + cd $(CURL_VERSION) + $(MAKE) clean MAKEFLAGS= + rm .chrome + +clean: ## Remove all build artifacts, including dependencies rm -Rf brotli-$(BROTLI_VERSION).tar.gz brotli-$(BROTLI_VERSION) rm -Rf $(NSS_VERSION).tar.gz $(NSS_VERSION) rm -Rf boringssl.zip boringssl From 53a87e0d9d60646dfc4fbc0523be5b56bb4af9d1 Mon Sep 17 00:00:00 2001 From: lwthiker Date: Sat, 14 May 2022 10:10:34 +0300 Subject: [PATCH 2/6] Add forgotten '.PHONY' declarations in Makefile.in --- Makefile.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.in b/Makefile.in index 5e6662fb..23e2b6fc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -77,6 +77,7 @@ firefox-clean: ## Clean build artifacts of the Firefox version. Use after re-run cd $(CURL_VERSION) $(MAKE) clean MAKEFLAGS= rm .firefox +.PHONY: firefox-clean chrome-build: $(CURL_VERSION)/.chrome ## Build the Chrome version of curl-impersonate cd $(CURL_VERSION) @@ -111,6 +112,7 @@ chrome-clean: ## Clean build artifacts of the Chrome version. Use after re-runni cd $(CURL_VERSION) $(MAKE) clean MAKEFLAGS= rm .chrome +.PHONY: chrome-clean clean: ## Remove all build artifacts, including dependencies rm -Rf brotli-$(BROTLI_VERSION).tar.gz brotli-$(BROTLI_VERSION) From b0e9d4c91efb78213bb8fc2fddfdf5ecd4543599 Mon Sep 17 00:00:00 2001 From: lwthiker Date: Sat, 14 May 2022 17:58:22 +0300 Subject: [PATCH 3/6] Use 'rm -f' in Makefile.in Use 'rm -f' to ignore non-existant file errors. --- Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index 23e2b6fc..c9e13aa2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -76,7 +76,7 @@ firefox-uninstall: ## Uninstall the Firefox version of curl-impersonate after 'm firefox-clean: ## Clean build artifacts of the Firefox version. Use after re-running './configure' cd $(CURL_VERSION) $(MAKE) clean MAKEFLAGS= - rm .firefox + rm -f .firefox .PHONY: firefox-clean chrome-build: $(CURL_VERSION)/.chrome ## Build the Chrome version of curl-impersonate @@ -111,7 +111,7 @@ chrome-uninstall: ## Uninstall the Chrome version of curl-impersonate after 'mak chrome-clean: ## Clean build artifacts of the Chrome version. Use after re-running './configure' cd $(CURL_VERSION) $(MAKE) clean MAKEFLAGS= - rm .chrome + rm -f .chrome .PHONY: chrome-clean clean: ## Remove all build artifacts, including dependencies From 201a5472efee12e96c0ced614673791d04c3e729 Mon Sep 17 00:00:00 2001 From: lwthiker Date: Sat, 14 May 2022 18:48:28 +0300 Subject: [PATCH 4/6] Add option to strip binaries before installation And use 'install' instead of 'cp' for installing the wrapper scripts. --- Makefile.in | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index c9e13aa2..3d4aaa02 100644 --- a/Makefile.in +++ b/Makefile.in @@ -64,9 +64,19 @@ firefox-install: ## Install the Firefox version of curl-impersonate after build cd $(CURL_VERSION) $(MAKE) install-exec MAKEFLAGS= # Wrapper scripts for the Firefox version (e.g. 'curl_ff98') - cp -f $(srcdir)/firefox/curl_ff* @bindir@ + install $(srcdir)/firefox/curl_ff* @bindir@ .PHONY: firefox-install +firefox-install-strip: ## Like 'firefox-install', but strip binaries for smaller size + cd $(CURL_VERSION) + $(MAKE) install-exec MAKEFLAGS= + # We could have used 'install-strip' but then the docs would be installed as well. + # Instead strip manually. + strip @bindir@/curl-impersonate-ff + # Wrapper scripts for the Firefox version (e.g. 'curl_ff98') + install $(srcdir)/firefox/curl_ff* @bindir@ +.PHONY: firefox-install-strip + firefox-uninstall: ## Uninstall the Firefox version of curl-impersonate after 'make install' cd $(CURL_VERSION) $(MAKE) uninstall MAKEFLAGS= @@ -99,9 +109,19 @@ chrome-install: ## Install the Chrome version of curl-impersonate after build cd $(CURL_VERSION) $(MAKE) install-exec MAKEFLAGS= # Wrapper scripts for the Chrome version (e.g. 'curl_chrome99') - cp -f $(srcdir)/chrome/curl_chrome* $(srcdir)/chrome/curl_edge* $(srcdir)/chrome/curl_safari* @bindir@ + install $(srcdir)/chrome/curl_chrome* $(srcdir)/chrome/curl_edge* $(srcdir)/chrome/curl_safari* @bindir@ .PHONY: chrome-install +chrome-install-strip: ## Like 'chrome-install', but strip binaries for smaller size + cd $(CURL_VERSION) + $(MAKE) install-exec MAKEFLAGS= + # We could have used 'install-strip' but then the docs would be installed as well. + # Instead strip manually. + strip @bindir@/curl-impersonate-chrome + # Wrapper scripts for the Chrome version (e.g. 'curl_chrome99') + install $(srcdir)/chrome/curl_chrome* $(srcdir)/chrome/curl_edge* $(srcdir)/chrome/curl_safari* @bindir@ +.PHONY: chrome-install-strip + chrome-uninstall: ## Uninstall the Chrome version of curl-impersonate after 'make install' cd $(CURL_VERSION) $(MAKE) uninstall MAKEFLAGS= From e0429606594b22e9e6a87cab202582ff97b2769d Mon Sep 17 00:00:00 2001 From: lwthiker Date: Sat, 14 May 2022 18:48:55 +0300 Subject: [PATCH 5/6] Update README.md about pre-compiled binaries --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index d57569eb..92f761c4 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ See [Advanced usage](#Advanced-usage) for more options. ## Installation There are two versions of `curl-impersonate` for technical reasons. The **chrome** version is used to impersonate Chrome, Edge and Safari. The **firefox** version is used to impersonate Firefox. +### Pre-compiled binaries +Pre-compiled binaries for Linux and macOS (Intel) are available at the [GitHub releases](https://github.com/lwthiker/curl-impersonate/releases) page. + +These binaries are statically compiled with libcurl(-impersonate) for ease of use. If you wish to use libcurl-impersonate, please build from source. + ### Building from source See [INSTALL.md](INSTALL.md). From 7167328e3795189eca323b260173a8f33614f549 Mon Sep 17 00:00:00 2001 From: lwthiker Date: Sat, 14 May 2022 18:50:18 +0300 Subject: [PATCH 6/6] Publish stripped binaries to GitHub release assets To reduce size of built binaries, strip the binaries before publishing them. --- .github/workflows/build-and-test-make.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test-make.yml b/.github/workflows/build-and-test-make.yml index 23d439d9..3ca182d2 100644 --- a/.github/workflows/build-and-test-make.yml +++ b/.github/workflows/build-and-test-make.yml @@ -161,10 +161,10 @@ jobs: ./configure --prefix=${{ runner.temp }}/install --enable-static ${{ matrix.make }} chrome-build ${{ matrix.make }} chrome-checkbuild - ${{ matrix.make }} chrome-install + ${{ matrix.make }} chrome-install-strip ${{ matrix.make }} firefox-build ${{ matrix.make }} firefox-checkbuild - ${{ matrix.make }} firefox-install + ${{ matrix.make }} firefox-install-strip - name: Create tar release files if: startsWith(github.ref, 'refs/tags/')