Skip to content

Commit

Permalink
add targets to generate tar/zip from src
Browse files Browse the repository at this point in the history
  • Loading branch information
fmigneault committed Dec 3, 2024
1 parent c514077 commit ee3b339
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ src
## Project process results
workflows
**/*.tif

## build/release
archive
*.zip
*.tar.gz
**/*.zip
**/*.tag.gz

## Project local configurations
!config/*.example
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/zenodo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
37 changes: 35 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ endif

# Tests
REPORTS_DIR := $(APP_ROOT)/reports
ARCHIVE_DIR := $(APP_ROOT)/archive

# end of configuration

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion config/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# ignore custom configs
*.*
*.txt
*.env
*.cfg
*.ini
*.yml
*.json
!*.example
!.gitignore

0 comments on commit ee3b339

Please sign in to comment.