git-archive-all as a GitHub Action - Wrapper for git-archive, taking into account .gitattributes
MIT License
This repository contains a GitHub Action based on git-archive-all, to archive
a git project along with all its submodules, taking into account any exclusion
specified in .gitattributes
.
output-files
:project.zip project.tar.gz
. The output format for the archive is deduced from the filetar
, bz2
, tgz
, txz
,bz2
, gz
, xz
, and zip
.base-repo
:
Main Git repository to archive, defaults to the path of the current working
directory.
prefix
:
Prefix to prepend to each filename in the archive, defaults to the base name
of the output file without its extension (in the example above: project
).
For example, if using output-files: project.zip
and passing no prefix
,
the generated archive contains a root directory named project
. Note that
explicitly passing an empty prefix is the same as not setting the option, and
falls back to the default behaviour. To have all compressed items at the root
of the generated archive, pass '/'
as a prefix.
export-ignore
(boolean):
Follow export-ignore
attributes from .gitattributes
, enabled by default.
force-submodules
(boolean):
Force git submodule init && git submodule update
at each level before
iterating submodules, enabled by default.
extra-includes
:
Space-separated list of additional files to include in the archive, empty by
default.
compression-level
(number, 0 to 9):
Compression level to use; interpretation depends on the output format. Set to
9
by default. Currently incompatible with txz
and xz
output formats.
verbose
(boolean):
Set verbose mode, enabled by default.
This GitHub Action produces no output.
It uses no secret.
It does not use any particular environment variable.
name: release
on:
push:
tags:
- '**'
jobs:
draft-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout project source code
uses: actions/checkout@v3
with:
path: project
- name: Package source code including submodules
uses: qmonnet/git-archive-all-action@v1
with:
output-files: srcs-full-${{ github.ref_name }}.tar.gz srcs-full-${{ github.ref_name }}.zip
base-repo: project
- name: Create draft release and add artifacts
uses: softprops/action-gh-release@v1
with:
draft: true
files: srcs-full-*
Contrarily to git archive
, the .gitattributes
rules using a directory
name to exclude some paths from exports do not work, a wildcard must be
specified after the directory name and the /
.
For example, the following will result in git archive
skipping all files in
the assets
directory, but will be ignored by git_archive_all.py
:
assets/ export-ignore
The same thing can be achieved with this GitHub Action by using a wildcard instead:
assets/** export-ignore
The list of output files is space-separated, but in YAML, we can also use the
folded style operator (>
) to rewrite the above example as follows:
output-files: >-
srcs-full-${{ github.ref_name }}.tar.gz
srcs-full-${{ github.ref_name }}.zip
I'd rather not maintain a separate version of the script, so please consider
submitting any contribution for git_archive_all.py
to its upstream
repository, and we can pull the changes here after that.
Credits for the git_archive_all.py
script go to Ilya Kulakov and to
the other contributors of that project.