Skip to content

Commit ecbfa22

Browse files
authored
Final changes to release workflow to make submodule releases possible. (#1043)
* chmod +x for buildozer download. * fix module name expansion * fix path t module.bazl * missing s * no rpm test * flips * hack out the disk cache * release_ruleset needs a revamp * reroot * commentary * auto-create versoin from release * update release tools to form download URL correctly
1 parent 3338d64 commit ecbfa22

6 files changed

Lines changed: 40 additions & 17 deletions

File tree

.github/workflows/release_module.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
env:
3939
SUBDIR: "${{ inputs.subdir }}"
4040
VERSION: "${{ inputs.version }}"
41-
MODULE: "rules_pkg_${SUBDIR}"
41+
MODULE: "rules_pkg_${{ inputs.subdir }}"
4242

4343
GIT_AUTHOR_NAME: "${{ github.actor }}"
4444
GIT_AUTHOR_EMAIL: "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
@@ -50,7 +50,9 @@ jobs:
5050
curl -o "${RUNNER_TEMP}/buildozer" -L "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildozer-linux-amd64"
5151
chmod a+x "${RUNNER_TEMP}/buildozer"
5252
"${RUNNER_TEMP}/buildozer" "set version ${VERSION}" "//${SUBDIR}/MODULE.bazel:${MODULE}" || true
53-
git add "${MODULE}/MODULE.bazel"
53+
git add "${SUBDIR}/MODULE.bazel"
54+
sed -i -e "s/@AUTO_VERSION@/${VERSION}/" ${SUBDIR}/version.bzl
55+
git add "${SUBDIR}/version.bzl"
5456
git commit -m "Release `${MODULE}-${VERSION}`"
5557
5658
# 3. Push release tag.
@@ -67,4 +69,10 @@ jobs:
6769
# This will run release_prep.sh to do the dirty work.
6870
# TODO: https://github.com/bazelbuild/rules_pkg/issues/1031
6971
release_files: "bazel-bin/distro/rules_pkg_${{ inputs.subdir }}-*.tgz"
70-
tag_name: "rule_pkg_${{ inputs.subdir }}-${{ inputs.version }}"
72+
tag_name: "rules_pkg_${{ inputs.subdir }}-${{ inputs.version }}"
73+
# We only do a partial test. The problem is that RPM does not work on the github runners
74+
# so we must skip, but the release_ruleset flow appends cache flags to the command. That
75+
# makes the syntax 'bazel test //... -- -//test/rpm/... =disk_cache-flag' impossible.
76+
# It doesn't matter. We have to do the full test anyway before hitting this, so everything
77+
# should still work, if we only changed the version in the module.
78+
bazel_test_command: "bazel test --build_tests_only //tests/tar/... //tests/zip/..."

.github/workflows/release_prep.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ set -o errexit -o nounset -o pipefail
55
# Passed as argument when invoking the script.
66
TAG="${1}"
77

8-
# Get back to the root
9-
cd ../../
8+
# Get back to the root, because sometimes we are in .github/workflows, but other times we are not.
9+
# That seems plainly dumb, but working around it is far less effort than writing new workflows
10+
# where this is not a problem.
11+
if [[ ! -f MODULE.bazel ]] ; then
12+
cd ..
13+
fi
14+
if [[ ! -f MODULE.bazel ]] ; then
15+
cd ..
16+
fi
1017

1118
case "${TAG}" in
1219
[0-9]* )

distro/BUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ print_rel_notes(
150150
outs = ["rules_pkg_providers_relnotes.txt"],
151151
artifact_name = "rules_pkg_providers-%s.tgz" % providers_version,
152152
org = "bazelbuild",
153-
repo = "rules_pkg_providers",
153+
release_name = "rules_pkg_providers-%s" % providers_version,
154+
repo = "rules_pkg",
154155
version = providers_version,
155156
)

pkg/releasing/defs.bzl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@ def print_rel_notes(
55
name,
66
repo,
77
version,
8-
artifact_name = None,
98
outs = None,
10-
setup_file = "",
9+
artifact_name = None,
10+
changelog = None,
1111
deps_method = "",
12-
toolchains_method = "",
12+
mirror_host = None,
1313
org = "bazelbuild",
14-
changelog = None,
15-
mirror_host = None):
14+
release_name = None,
15+
setup_file = "",
16+
toolchains_method = ""):
1617
if not artifact_name:
1718
artifact_name = ":%s-%s.tar.gz" % (repo, version)
19+
if not release_name:
20+
release_name = ":%s-%s" % (repo, version)
1821

1922
# Must use Label to get a path relative to the rules_pkg repository,
2023
# instead of the calling BUILD file.
@@ -26,6 +29,7 @@ def print_rel_notes(
2629
"--repo=%s" % repo,
2730
"--version=%s" % version,
2831
"--tarball=$(location %s)" % artifact_name,
32+
"--release_name='%s'" % release_name,
2933
]
3034
if setup_file:
3135
cmd.append("--setup_file=%s" % setup_file)

pkg/releasing/print_rel_notes.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424

2525

2626
def print_notes(org, repo, version, tarball_path, mirror_host=None,
27-
deps_method=None, setup_file=None, toolchains_method=None,
28-
changelog=''):
27+
deps_method=None, release_name=None, setup_file=None,
28+
toolchains_method=None, changelog=''):
2929
file_name = os.path.basename(tarball_path)
3030
sha256 = release_tools.get_package_sha256(tarball_path)
3131

3232
url = 'https://github.com/%s/%s/releases/download/%s/%s' % (
33-
org, repo, version, file_name)
33+
org, repo, release_name, file_name)
3434
mirror_url = 'https://%s/github.com/%s/%s/releases/download/%s/%s' % (
3535
mirror_host, org, repo, version, file_name) if mirror_host else None
3636
workspace_stanza = release_tools.workspace_content(
@@ -70,10 +70,10 @@ def print_notes(org, repo, version, tarball_path, mirror_host=None,
7070
}))
7171
if mirror_url:
7272
file = os.path.basename(tarball_path)
73-
path = 'github.com/{org}/{repo}/releases/download/{version}/{file}'.format(
73+
path = 'github.com/{org}/{repo}/releases/download/{release_name}/{file}'.format(
7474
org=org,
7575
repo=repo,
76-
version=version,
76+
release_name=release_name,
7777
file=file
7878
)
7979

@@ -109,6 +109,8 @@ def main():
109109
'--repo', default=None, required=True, help='Repo name')
110110
parser.add_argument(
111111
'--version', default=None, required=True, help='Release version')
112+
parser.add_argument(
113+
'--release_name', default=None, required=True, help='The release name: usually submodule-version')
112114
parser.add_argument(
113115
'--tarball_path', default=None,
114116
required=True, help='path to release tarball')
@@ -139,6 +141,7 @@ def main():
139141
deps_method=options.deps_method,
140142
changelog=changelog,
141143
mirror_host=options.mirror_host,
144+
release_name=options.release_name,
142145
setup_file=options.setup_file,
143146
toolchains_method=options.toolchains_method)
144147

providers/version.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""The version of rules_pkg_providers."""
22

3-
version = "1.0.0"
3+
version = "@AUTO_VERSION@"

0 commit comments

Comments
 (0)