diff --git a/.github/workflows/release_module.yml b/.github/workflows/release_module.yml index 3810176d..58447968 100644 --- a/.github/workflows/release_module.yml +++ b/.github/workflows/release_module.yml @@ -38,7 +38,7 @@ jobs: env: SUBDIR: "${{ inputs.subdir }}" VERSION: "${{ inputs.version }}" - MODULE: "rules_pkg_${SUBDIR}" + MODULE: "rules_pkg_${{ inputs.subdir }}" GIT_AUTHOR_NAME: "${{ github.actor }}" GIT_AUTHOR_EMAIL: "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" @@ -50,7 +50,9 @@ jobs: curl -o "${RUNNER_TEMP}/buildozer" -L "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildozer-linux-amd64" chmod a+x "${RUNNER_TEMP}/buildozer" "${RUNNER_TEMP}/buildozer" "set version ${VERSION}" "//${SUBDIR}/MODULE.bazel:${MODULE}" || true - git add "${MODULE}/MODULE.bazel" + git add "${SUBDIR}/MODULE.bazel" + sed -i -e "s/@AUTO_VERSION@/${VERSION}/" ${SUBDIR}/version.bzl + git add "${SUBDIR}/version.bzl" git commit -m "Release `${MODULE}-${VERSION}`" # 3. Push release tag. @@ -67,4 +69,10 @@ jobs: # This will run release_prep.sh to do the dirty work. # TODO: https://github.com/bazelbuild/rules_pkg/issues/1031 release_files: "bazel-bin/distro/rules_pkg_${{ inputs.subdir }}-*.tgz" - tag_name: "rule_pkg_${{ inputs.subdir }}-${{ inputs.version }}" + tag_name: "rules_pkg_${{ inputs.subdir }}-${{ inputs.version }}" + # We only do a partial test. The problem is that RPM does not work on the github runners + # so we must skip, but the release_ruleset flow appends cache flags to the command. That + # makes the syntax 'bazel test //... -- -//test/rpm/... =disk_cache-flag' impossible. + # It doesn't matter. We have to do the full test anyway before hitting this, so everything + # should still work, if we only changed the version in the module. + bazel_test_command: "bazel test --build_tests_only //tests/tar/... //tests/zip/..." diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh index 0aa194d1..58777e93 100755 --- a/.github/workflows/release_prep.sh +++ b/.github/workflows/release_prep.sh @@ -5,8 +5,15 @@ set -o errexit -o nounset -o pipefail # Passed as argument when invoking the script. TAG="${1}" -# Get back to the root -cd ../../ +# Get back to the root, because sometimes we are in .github/workflows, but other times we are not. +# That seems plainly dumb, but working around it is far less effort than writing new workflows +# where this is not a problem. +if [[ ! -f MODULE.bazel ]] ; then + cd .. +fi +if [[ ! -f MODULE.bazel ]] ; then + cd .. +fi case "${TAG}" in [0-9]* ) diff --git a/distro/BUILD b/distro/BUILD index dd431f42..aa0862fd 100644 --- a/distro/BUILD +++ b/distro/BUILD @@ -150,6 +150,7 @@ print_rel_notes( outs = ["rules_pkg_providers_relnotes.txt"], artifact_name = "rules_pkg_providers-%s.tgz" % providers_version, org = "bazelbuild", - repo = "rules_pkg_providers", + release_name = "rules_pkg_providers-%s" % providers_version, + repo = "rules_pkg", version = providers_version, ) diff --git a/pkg/releasing/defs.bzl b/pkg/releasing/defs.bzl index 52f3cd49..bd90e551 100644 --- a/pkg/releasing/defs.bzl +++ b/pkg/releasing/defs.bzl @@ -5,16 +5,19 @@ def print_rel_notes( name, repo, version, - artifact_name = None, outs = None, - setup_file = "", + artifact_name = None, + changelog = None, deps_method = "", - toolchains_method = "", + mirror_host = None, org = "bazelbuild", - changelog = None, - mirror_host = None): + release_name = None, + setup_file = "", + toolchains_method = ""): if not artifact_name: artifact_name = ":%s-%s.tar.gz" % (repo, version) + if not release_name: + release_name = ":%s-%s" % (repo, version) # Must use Label to get a path relative to the rules_pkg repository, # instead of the calling BUILD file. @@ -26,6 +29,7 @@ def print_rel_notes( "--repo=%s" % repo, "--version=%s" % version, "--tarball=$(location %s)" % artifact_name, + "--release_name='%s'" % release_name, ] if setup_file: cmd.append("--setup_file=%s" % setup_file) diff --git a/pkg/releasing/print_rel_notes.py b/pkg/releasing/print_rel_notes.py index b9c4545c..eb5d27bc 100644 --- a/pkg/releasing/print_rel_notes.py +++ b/pkg/releasing/print_rel_notes.py @@ -24,13 +24,13 @@ def print_notes(org, repo, version, tarball_path, mirror_host=None, - deps_method=None, setup_file=None, toolchains_method=None, - changelog=''): + deps_method=None, release_name=None, setup_file=None, + toolchains_method=None, changelog=''): file_name = os.path.basename(tarball_path) sha256 = release_tools.get_package_sha256(tarball_path) url = 'https://github.com/%s/%s/releases/download/%s/%s' % ( - org, repo, version, file_name) + org, repo, release_name, file_name) mirror_url = 'https://%s/github.com/%s/%s/releases/download/%s/%s' % ( mirror_host, org, repo, version, file_name) if mirror_host else None workspace_stanza = release_tools.workspace_content( @@ -70,10 +70,10 @@ def print_notes(org, repo, version, tarball_path, mirror_host=None, })) if mirror_url: file = os.path.basename(tarball_path) - path = 'github.com/{org}/{repo}/releases/download/{version}/{file}'.format( + path = 'github.com/{org}/{repo}/releases/download/{release_name}/{file}'.format( org=org, repo=repo, - version=version, + release_name=release_name, file=file ) @@ -109,6 +109,8 @@ def main(): '--repo', default=None, required=True, help='Repo name') parser.add_argument( '--version', default=None, required=True, help='Release version') + parser.add_argument( + '--release_name', default=None, required=True, help='The release name: usually submodule-version') parser.add_argument( '--tarball_path', default=None, required=True, help='path to release tarball') @@ -139,6 +141,7 @@ def main(): deps_method=options.deps_method, changelog=changelog, mirror_host=options.mirror_host, + release_name=options.release_name, setup_file=options.setup_file, toolchains_method=options.toolchains_method) diff --git a/providers/version.bzl b/providers/version.bzl index ead02a6e..f05dc987 100644 --- a/providers/version.bzl +++ b/providers/version.bzl @@ -1,3 +1,3 @@ """The version of rules_pkg_providers.""" -version = "1.0.0" +version = "@AUTO_VERSION@"