Skip to content

Commit 4e541c8

Browse files
authored
refactor: move 'git archive' config to .gitattributes (#101)
1 parent 84fcf22 commit 4e541c8

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

.gitattributes

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
1+
# In code review, collapse generated files
12
docs/*.md linguist-generated=true
3+
4+
#################################
5+
# Configuration for 'git archive'
6+
# See https://git-scm.com/docs/git-archive#ATTRIBUTES
7+
8+
# Don't include examples in the distribution artifact, to reduce size.
9+
# You may want to add additional exclusions for folders or files that users don't need.
10+
examples export-ignore
11+
12+
# Occasionally there's a need to "stamp" the release version into a file
13+
mylang/version.bzl export-subst

.github/workflows/release_prep.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
22

33
set -o errexit -o nounset -o pipefail
44

5-
# Don't include examples in the distribution artifact, to reduce size.
6-
# You may want to add additional exclusions for folders or files that users don't need.
7-
# NB: this mechanism relies on a `git archive` feature, which is much simpler and less
8-
# error-prone than using Bazel to build a release artifact from sources in the repository.
9-
# See https://git-scm.com/docs/git-archive#ATTRIBUTES
10-
echo >>.git/info/attributes "examples export-ignore"
11-
125
# Set by GH actions, see
136
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
147
TAG=${GITHUB_REF_NAME}
158
# The prefix is chosen to match what GitHub generates for source archives
9+
# This guarantees that users can easily switch from a released artifact to a source archive
10+
# with minimal differences in their code (e.g. strip_prefix remains the same)
1611
PREFIX="rules_mylang-${TAG:1}"
1712
ARCHIVE="rules_mylang-$TAG.tar.gz"
13+
14+
# NB: configuration for 'git archive' is in /.gitattributes
1815
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
1916
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
2017

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Features:
1010
- includes stardoc API documentation generator
1111
- includes typical toolchain setup
1212
- CI configured with GitHub Actions
13-
- Release using GitHub Actions just by pushing a tag
13+
- release using GitHub Actions just by pushing a tag
14+
- the release artifact doesn't need to be built by Bazel, but can still exclude files and stamp the version
1415

1516
See https://docs.bazel.build/versions/main/skylark/deploying.html#readme
1617

0 commit comments

Comments
 (0)