Skip to content

Commit 14f5d8e

Browse files
authored
Add source archive and snippet to release (#1089)
1 parent e328686 commit 14f5d8e

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2023 The Bazel Authors. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -o errexit -o nounset -o pipefail
17+
18+
# Set by GH actions, see
19+
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
20+
TAG=${GITHUB_REF_NAME}
21+
# A prefix is added to better match the GitHub generated archives.
22+
PREFIX="jsonnet-${TAG}"
23+
ARCHIVE="jsonnet-$TAG.tar.gz"
24+
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
25+
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
26+
27+
cat > release_notes.txt << EOF
28+
### Importing Jsonnet in a project that uses Bazel
29+
30+
#### Using Bzlmod with Bazel 6
31+
32+
Add to your \`MODULE.bazel\` file:
33+
34+
\`\`\`starlark
35+
bazel_dep(name = "jsonnet", version = "${TAG}")
36+
\`\`\`
37+
38+
#### Using WORKSPACE
39+
40+
Paste this snippet into your \`WORKSPACE\` file:
41+
42+
\`\`\`starlark
43+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
44+
45+
http_archive(
46+
name = "jsonnet",
47+
sha256 = "${SHA}",
48+
strip_prefix = "${PREFIX}",
49+
url = "https://github.com/google/jsonnet/releases/download/${TAG}/jsonnet-${TAG}.tar.gz",
50+
)
51+
\`\`\`
52+
53+
EOF

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright 2023 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Cut a release whenever a new tag is pushed to the repo.
16+
name: Release
17+
18+
on:
19+
push:
20+
tags:
21+
- "*.*.*"
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v2
29+
- name: Create release archive and notes
30+
run: .github/workflows/create_archive_and_notes.sh
31+
- name: Release
32+
uses: softprops/action-gh-release@v1
33+
with:
34+
# Use GH feature to populate the changelog automatically
35+
generate_release_notes: true
36+
body_path: release_notes.txt
37+
fail_on_unmatched_files: true
38+
files: jsonnet-*.tar.gz

0 commit comments

Comments
 (0)