From ee3b3390f82abc53a1bf22c0bfb25f911cff7ea0 Mon Sep 17 00:00:00 2001 From: Francis Charette Migneault Date: Tue, 3 Dec 2024 14:02:56 -0500 Subject: [PATCH] add targets to generate tar/zip from src --- .dockerignore | 6 ++++++ .github/workflows/zenodo.yml | 12 +++++++----- .gitignore | 8 +++++++- Makefile | 37 ++++++++++++++++++++++++++++++++++-- config/.gitignore | 7 ++++++- 5 files changed, 61 insertions(+), 9 deletions(-) diff --git a/.dockerignore b/.dockerignore index c01312ef7..8b7b70cec 100644 --- a/.dockerignore +++ b/.dockerignore @@ -91,7 +91,13 @@ src ## Project process results workflows **/*.tif + +## build/release +archive +*.zip +*.tar.gz **/*.zip +**/*.tag.gz ## Project local configurations !config/*.example diff --git a/.github/workflows/zenodo.yml b/.github/workflows/zenodo.yml index 8068739d0..db3019b1c 100644 --- a/.github/workflows/zenodo.yml +++ b/.github/workflows/zenodo.yml @@ -12,15 +12,17 @@ jobs: with: fetch-depth: "0" - name: Download Archive - env: - tarball: ${{ github.event.release.tarball_url }} - zipball: ${{ github.event.release.zipball_url }} + # We don't use releases, but tags. Therefore, we have to make the zip ourselves. + # env: + # tarball: ${{ github.event.release.tarball_url }} + # zipball: ${{ github.event.release.zipball_url }} + # Add the suffix to the name of the file so type is recognized when # downloading from Zenodo .tar.gz for tarball and .zip for zipball. # Archiving the zipball will cause Zenodo to show a preview of the contents while using tarball will not. run: | - name=$(basename ${{ env.zipball }}).zip - curl -L ${{ env.zipball }} > $name + make generate-archive + name=$(basename *.zip) echo "ZENODO_ARCHIVE=${name}" >> $GITHUB_ENV - name: Generate Changelog diff --git a/.gitignore b/.gitignore index a8a853161..f680d158e 100644 --- a/.gitignore +++ b/.gitignore @@ -93,8 +93,14 @@ response.varfile ## project process results *.tif -*.zip ./workflow[s] +## build/release +archive +*.zip +*.tar.gz +**/*.zip +**/*.tag.gz + ## old project sources [Bb]in diff --git a/Makefile b/Makefile index ede81bdd3..d8b96cf13 100644 --- a/Makefile +++ b/Makefile @@ -90,6 +90,7 @@ endif # Tests REPORTS_DIR := $(APP_ROOT)/reports +ARCHIVE_DIR := $(APP_ROOT)/archive # end of configuration @@ -300,7 +301,14 @@ install-dev-npm: install-npm install-npm-remarklint install-npm-remarklint ## i clean: clean-all ## alias for 'clean-all' target .PHONY: clean-all -clean-all: clean-build clean-cache clean-docs-dirs clean-src clean-reports clean-test ## run all cleanup targets +clean-all: clean-archive clean-build clean-cache clean-docs-dirs clean-src clean-reports clean-test ## run all cleanup targets + +.PHONY: clean-archive +clean-archive: ## remove archive files and directories + @-echo "Removing archives..." + @-rm "$(APP_ROOT)"/*.tar.gz + @-rm "$(APP_ROOT)"/*.zip + @-rm -fr "$(ARCHIVE_DIR)" .PHONY: clean-build clean-build: ## remove the temporary build files @@ -759,7 +767,7 @@ extract-changes: ## uses the specified VERSION to extract its sub-section in CHA ' .PHONY: generate-changes-html -generate-changes-html: extract-changes +generate-changes-html: extract-changes ## extract CHANGES.rst section as HTML using the specified VERSION @[ "${VERSION}" ] || ( echo ">> 'VERSION' is not set. It is required to extract changes."; exit 1 ) @-echo "Checking necessary Sphinx dependency ..." @pip show sphinx >/dev/null || bash -c '$(CONDA_CMD) $(MAKE) -C "$(APP_ROOT)" install-doc' @@ -770,6 +778,31 @@ generate-changes-html: extract-changes "$(REPORTS_DIR)/CHANGES_${VERSION}.rst" "$(REPORTS_DIR)/CHANGES_${VERSION}.html" @-echo "Generates changes: $(REPORTS_DIR)/CHANGES_${VERSION}.html" +.PHONY: generate-archive +generate-archive: ## generate ZIP and TAR.GZ archives using current contents + @-echo "Generating archives" + @tar \ + -C "$(APP_ROOT)" \ + --exclude=.git \ + --exclude=.github \ + --exclude-vcs \ + --exclude-vcs-ignores \ + --exclude=*.zip \ + --exclude=*.tar.gz \ + -cvzf "$(APP_NAME)-$(APP_VERSION).tar.gz" \ + --transform 's,^\.,$(APP_NAME)-$(APP_VERSION),' \ + . + @cd "$(APP_ROOT)" && \ + mkdir -p "$(ARCHIVE_DIR)" && \ + cp "$(APP_NAME)-$(APP_VERSION).tar.gz" "$(ARCHIVE_DIR)/$(APP_NAME)-$(APP_VERSION).tar.gz" && \ + cd "$(ARCHIVE_DIR)" && \ + tar -xzf "$(APP_NAME)-$(APP_VERSION).tar.gz" && \ + rm "$(APP_NAME)-$(APP_VERSION).tar.gz" && \ + zip -r "$(APP_NAME)-$(APP_VERSION).zip" * && \ + mv "$(APP_NAME)-$(APP_VERSION).zip" "$(APP_ROOT)" && \ + cd "$(APP_ROOT)" && \ + rm -fr "$(ARCHIVE_DIR)" + ## -- Docker targets ------------------------------------------------------------------------------------------------ ## .PHONY: docker-info diff --git a/config/.gitignore b/config/.gitignore index 3e167b701..230d117ee 100644 --- a/config/.gitignore +++ b/config/.gitignore @@ -1,4 +1,9 @@ # ignore custom configs -*.* +*.txt +*.env +*.cfg +*.ini +*.yml +*.json !*.example !.gitignore