Skip to content

Commit 2eccc0a

Browse files
ci: allow building from prepare-release without adding git hash suffix
Gradually trying to work out a reasonable release workflow. Something like: - Update version number etc on branch "prepare-release" - Trigger release workflow: This generates a source archive and a draft GitHub release object. The GitHub release has a propsed tag that comes from the version in libjsonnet.h. - Trigger Python publish workflow: This generates Python packages, then waits for approval before publishing to PyPI. - Fill in release notes in GitHub. Do any last minute checks. Consider actually downloading the release artifacts and checking them locally. - Approve the Python publish workflow. - Publish the GitHub release (which will create the version tag) - Fast-forward master to the new version. It's a little ugly, but the benefits here are: - All the final build artifacts are generated before any publishing so they can be checked (manually or otherwise). - Release notes can be edited in GitHub. - The tag is created at publish time.
1 parent fcead49 commit 2eccc0a

File tree

2 files changed

+5
-33
lines changed

2 files changed

+5
-33
lines changed

.github/workflows/create_archive.sh

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515

1616
set -o errexit -o nounset -o pipefail
1717

18-
# Set by GH actions, see
19-
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
2018
JSONNET_VERSION="$(grep -Ee '^\s*#\s*define\s+LIB_JSONNET_VERSION\s+"[^"]+"\s*$' include/libjsonnet.h | sed -E -e 's/[^"]+"([^"]+)".*/\1/')"
2119

20+
# GITHUB_REF is set by GH actions, see
21+
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
22+
2223
VERSION_SUFFIX=
23-
if [[ "${GITHUB_REF_TYPE}" != 'tag' || "${GITHUB_REF_NAME}" != "${JSONNET_VERSION}" ]]; then
24+
if [[ ( "${GITHUB_REF_TYPE}" != 'branch' || "${GITHUB_REF_NAME}" != "prepare-release" ) &&
25+
( "${GITHUB_REF_TYPE}" != 'tag' || "${GITHUB_REF_NAME}" != "${JSONNET_VERSION}" ) ]]; then
2426
>&2 echo 'WARNING: Jsonnet library version in header does not match release ref. Adding commit suffix.'
2527
VERSION_SUFFIX="-${GITHUB_SHA:0:9}"
2628
fi
@@ -34,31 +36,3 @@ ARCHIVE_SHA=$(shasum -a 256 "$ARCHIVE" | awk '{print $1}')
3436
echo "archive_sha256=${ARCHIVE_SHA}" >> "$GITHUB_OUTPUT"
3537
echo "jsonnet_version=${JSONNET_VERSION}" >> "$GITHUB_OUTPUT"
3638
echo "jsonnet_version_permanent=${JSONNET_VERSION}${VERSION_SUFFIX}" >> "$GITHUB_OUTPUT"
37-
38-
cat > bazel_dep_release_notes.txt << EOF
39-
### Importing Jsonnet in a project that uses Bazel
40-
41-
#### Using Bzlmod with Bazel 6
42-
43-
Add to your \`MODULE.bazel\` file:
44-
45-
\`\`\`starlark
46-
bazel_dep(name = "jsonnet", version = "${JSONNET_VERSION}")
47-
\`\`\`
48-
49-
#### Using WORKSPACE
50-
51-
Paste this snippet into your \`WORKSPACE\` file:
52-
53-
\`\`\`starlark
54-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
55-
56-
http_archive(
57-
name = "jsonnet",
58-
sha256 = "${ARCHIVE_SHA}",
59-
strip_prefix = "${PREFIX}",
60-
url = "https://github.com/google/jsonnet/releases/download/${JSONNET_VERSION}/${ARCHIVE}",
61-
)
62-
\`\`\`
63-
64-
EOF

.github/workflows/release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,4 @@ jobs:
4242
prerelease: ${{ inputs.prerelease }}
4343
draft: true
4444
fail_on_unmatched_files: true
45-
body_path: bazel_dep_release_notes.txt
46-
append_body: true
4745
files: jsonnet-*.tar.gz

0 commit comments

Comments
 (0)